Oracle Fusion Middleware
Oracle WebLogic SIP Server API Reference
11g Release 1 (10.3.4)

Part Number E17873-02

com.bea.wcp.sip.util
Class DigestUtils

java.lang.Object
  extended by com.bea.wcp.sip.util.DigestUtils

public final class DigestUtils
extends java.lang.Object

Conveneince methods for Digest authentication process.


Method Summary
static java.lang.String byteToHex(byte b)
          Method that converts one byte data into a two-digit hexadecimal string.
static java.lang.String createDigestResponseWithHA1(java.lang.String username, java.lang.String ha1, java.util.Map challengeMap, java.lang.String sipMethod, java.lang.String sipUri, java.lang.String qop, java.lang.String nonceCnt, java.lang.String cnonce, java.lang.String entityBody)
          This method creates the DIGEST authentication response for the client, using the HA1 and other parameters that are passed in.
static java.lang.String createDigestResponseWithPassword(java.lang.String username, java.lang.String password, java.util.Map challengeMap, java.lang.String sipMethod, java.lang.String sipUri, java.lang.String qop, java.lang.String nonceCnt, java.lang.String cnonce, java.lang.String entityBody)
          This method creates the DIGEST authentication response for the client, using the clear text password and other parameters that are passed in.
static java.lang.String getDigest(java.lang.String ha1, java.lang.String nonce, java.lang.String nonceCount, java.lang.String clientNonce, java.lang.String qop, java.lang.String ha2)
          Calculates the HTTP digest.
static java.lang.String getDigest(java.lang.String ha1, java.lang.String nonce, java.lang.String nonceCount, java.lang.String clientNonce, java.lang.String qop, java.lang.String method, java.lang.String digestUri)
          Calculates the HTTP digest.
static java.lang.String getDigest(java.lang.String ha1, java.lang.String nonce, java.lang.String nonceCount, java.lang.String clientNonce, java.lang.String qop, java.lang.String method, java.lang.String digestUri, java.lang.String entityBody)
          Calculates the HTTP digest.
static java.lang.String getHA1(java.lang.String username, java.lang.String realm, java.lang.String passwd)
          Retrieves the HA1 for Digest authentication.
static java.lang.String getHash(java.lang.String input)
          Returns an MD5 hash of the input String.
static java.lang.String getMD5SessHA1(java.lang.String username, java.lang.String realm, java.lang.String passwd, java.lang.String nonce, java.lang.String cnonce)
          Retrieves the HA1 for Digest authentication.
static java.util.HashMap<java.lang.String,java.lang.String> parseDigestChallenge(java.lang.String challenge)
          This method is a convenience method to break the value of "WWW-Authenticate" or "Proxy-Authenticate" header into key value pairs.
static java.lang.String stringToHex(java.lang.String str)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getHA1

public static java.lang.String getHA1(java.lang.String username,
                                      java.lang.String realm,
                                      java.lang.String passwd)
Retrieves the HA1 for Digest authentication.

Parameters:
username - User name
realm - realm
passwd - Password
Returns:
HA1 String

getMD5SessHA1

public static java.lang.String getMD5SessHA1(java.lang.String username,
                                             java.lang.String realm,
                                             java.lang.String passwd,
                                             java.lang.String nonce,
                                             java.lang.String cnonce)
Retrieves the HA1 for Digest authentication. A1 = H( unq(username-value) ":" unq(realm-value) ":" passwd ) ":" unq(nonce-value) ":" unq(cnonce-value)

Parameters:
username - User name
realm - realm
passwd - Password
Returns:
HA1 String H(A1)

getDigest

@NotNull
public static java.lang.String getDigest(java.lang.String ha1,
                                                 java.lang.String nonce,
                                                 java.lang.String nonceCount,
                                                 java.lang.String clientNonce,
                                                 java.lang.String qop,
                                                 java.lang.String method,
                                                 java.lang.String digestUri,
                                                 java.lang.String entityBody)
Calculates the HTTP digest.

Parameters:
ha1 - HA1 string
nonce - Nonce (any string)
nonceCount - Nonce count (any number of digits)
clientNonce - Client nonce (any string)
qop - Quality of Protection (either 'auth' or 'auth-int')
method - Method name (GET, etc.)
digestUri - URI of the subscriber
entityBody - body
Returns:
HTTP digest string

getDigest

@NotNull
public static java.lang.String getDigest(java.lang.String ha1,
                                                 java.lang.String nonce,
                                                 java.lang.String nonceCount,
                                                 java.lang.String clientNonce,
                                                 java.lang.String qop,
                                                 java.lang.String method,
                                                 java.lang.String digestUri)
Calculates the HTTP digest.

Parameters:
ha1 - HA1 string
nonce - Nonce (any string)
nonceCount - Nonce count (any number of digits)
clientNonce - Client nonce (any string)
qop - Quality of Protection ('auth' or 'auth-int')
method - Method name (GET, etc.)
digestUri - URI of the subscriber
Returns:
HTTP digest string

getDigest

@NotNull
public static java.lang.String getDigest(java.lang.String ha1,
                                                 java.lang.String nonce,
                                                 java.lang.String nonceCount,
                                                 java.lang.String clientNonce,
                                                 java.lang.String qop,
                                                 java.lang.String ha2)
Calculates the HTTP digest.

Parameters:
ha1 - HA1 string
nonce - Nonce (any string)
nonceCount - Nonce count (any number of digits)
clientNonce - Client nonce (any string)
qop - Quality of Protection ('auth' or 'auth-int')
ha2 - HA2 string
Returns:
HTTP digest string

getHash

public static java.lang.String getHash(@NotNull
                                       java.lang.String input)
Returns an MD5 hash of the input String.

Parameters:
input - String
Returns:
MD5 hash

parseDigestChallenge

public static java.util.HashMap<java.lang.String,java.lang.String> parseDigestChallenge(java.lang.String challenge)
This method is a convenience method to break the value of "WWW-Authenticate" or "Proxy-Authenticate" header into key value pairs.

Parameters:
challenge - value of "WWW-Authenticate" or "Proxy-Authenticate" header
Returns:
HashMap of key value pairs

createDigestResponseWithHA1

public static java.lang.String createDigestResponseWithHA1(java.lang.String username,
                                                           java.lang.String ha1,
                                                           java.util.Map challengeMap,
                                                           java.lang.String sipMethod,
                                                           java.lang.String sipUri,
                                                           java.lang.String qop,
                                                           java.lang.String nonceCnt,
                                                           java.lang.String cnonce,
                                                           java.lang.String entityBody)
This method creates the DIGEST authentication response for the client, using the HA1 and other parameters that are passed in. The return value can be used to set the value of "Authorization" or "Proxy-Authorization" header.

Parameters:
username - username String
ha1 - HA1 String
challengeMap - key-value pairs extracted from the digest challenge
sipMethod - SIP method
sipUri - SIP URI
qop - Quality of protection string - must be chosen from the qop values sent by the server
nonceCnt - nonce count - required only when qop is present
cnonce - client nonce - required only when qop is present
entityBody - entity body - needed only when qop="auth-int"
Returns:
String Client's digest response

createDigestResponseWithPassword

public static java.lang.String createDigestResponseWithPassword(java.lang.String username,
                                                                java.lang.String password,
                                                                java.util.Map challengeMap,
                                                                java.lang.String sipMethod,
                                                                java.lang.String sipUri,
                                                                java.lang.String qop,
                                                                java.lang.String nonceCnt,
                                                                java.lang.String cnonce,
                                                                java.lang.String entityBody)
This method creates the DIGEST authentication response for the client, using the clear text password and other parameters that are passed in. The return value can be used to set the value of "Authorization" or "Proxy-Authorization" header.

Parameters:
username - username String
password - password in clear-text
challengeMap - key-value pairs extracted from the digest challenge
sipMethod - SIP method
sipUri - SIP URI
qop - Quality of protection string - must be chosen from the qop values sent by the server
nonceCnt - nonce count - required only when qop is present
cnonce - client nonce - required only when qop is present
entityBody - entity body - needed only when qop="auth-int"
Returns:
String Client's digest response

byteToHex

public static java.lang.String byteToHex(byte b)
Method that converts one byte data into a two-digit hexadecimal string.

Parameters:
b - input byte
Returns:
hex string

stringToHex

@NotNull
public static java.lang.String stringToHex(java.lang.String str)
Parameters:
str -
Returns:
hex string

Copyright 1996, 2010, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Oracle Fusion Middleware
Oracle WebLogic SIP Server API Reference
11g Release 1 (10.3.4)

Part Number E17873-02