MjSip Stack
v1.6

org.zoolu.sip.authentication
Class DigestAuthentication

java.lang.Object
  |
  +--org.zoolu.sip.authentication.DigestAuthentication

public class DigestAuthentication
extends java.lang.Object

The HTTP Digest Authentication as defined in RFC2617. It can be used to i) calculate an authentication response from an authentication request, or ii) validate an authentication response.
in the former case the DigestAuthentication is created based on a WwwAuthenticationHeader (or ProxyAuthenticationHeader), while in the latter case it is created based on an AuthorizationHeader (or ProxyAuthorizationHeader).


Field Summary
protected  java.lang.String algorithm
           
protected  java.lang.String body
           
protected  java.lang.String cnonce
           
protected  java.lang.String method
           
protected  java.lang.String nc
           
protected  java.lang.String nonce
           
protected  java.lang.String opaque
           
protected  java.lang.String passwd
           
protected  java.lang.String qop
           
protected  java.lang.String realm
           
protected  java.lang.String response
           
protected  java.lang.String uri
           
protected  java.lang.String username
           
 
Constructor Summary
protected DigestAuthentication()
          Costructs a new DigestAuthentication.
  DigestAuthentication(java.lang.String method, AuthorizationHeader ah, java.lang.String body, java.lang.String passwd)
          Costructs a new DigestAuthentication.
  DigestAuthentication(java.lang.String method, java.lang.String uri, WwwAuthenticateHeader ah, java.lang.String qop, java.lang.String body, java.lang.String username, java.lang.String passwd)
          Costructs a new DigestAuthentication.
 
Method Summary
 boolean checkResponse()
          Whether the digest-response in the 'response' parameter in correct.
 AuthorizationHeader getAuthorizationHeader()
          Gets a new AuthorizationHeader based on current authentication attributes.
 ProxyAuthorizationHeader getProxyAuthorizationHeader()
          Gets a new ProxyAuthorizationHeader based on current authentication attributes.
 java.lang.String getResponse()
          Calculates the digest-response.
static void main(java.lang.String[] args)
          Main method.
 java.lang.String toString()
          Gets a String representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

method

protected java.lang.String method

username

protected java.lang.String username

passwd

protected java.lang.String passwd

realm

protected java.lang.String realm

nonce

protected java.lang.String nonce

opaque

protected java.lang.String opaque

algorithm

protected java.lang.String algorithm

qop

protected java.lang.String qop

uri

protected java.lang.String uri

cnonce

protected java.lang.String cnonce

nc

protected java.lang.String nc

response

protected java.lang.String response

body

protected java.lang.String body
Constructor Detail

DigestAuthentication

protected DigestAuthentication()
Costructs a new DigestAuthentication.

DigestAuthentication

public DigestAuthentication(java.lang.String method,
                            AuthorizationHeader ah,
                            java.lang.String body,
                            java.lang.String passwd)
Costructs a new DigestAuthentication.

DigestAuthentication

public DigestAuthentication(java.lang.String method,
                            java.lang.String uri,
                            WwwAuthenticateHeader ah,
                            java.lang.String qop,
                            java.lang.String body,
                            java.lang.String username,
                            java.lang.String passwd)
Costructs a new DigestAuthentication.
Method Detail

toString

public java.lang.String toString()
Gets a String representation of the object.
Overrides:
toString in class java.lang.Object

checkResponse

public boolean checkResponse()
Whether the digest-response in the 'response' parameter in correct.

getAuthorizationHeader

public AuthorizationHeader getAuthorizationHeader()
Gets a new AuthorizationHeader based on current authentication attributes.

getProxyAuthorizationHeader

public ProxyAuthorizationHeader getProxyAuthorizationHeader()
Gets a new ProxyAuthorizationHeader based on current authentication attributes.

getResponse

public java.lang.String getResponse()
Calculates the digest-response.

If the "qop" value is "auth" or "auth-int":
KD ( H(A1), unq(nonce) ":" nc ":" unq(cnonce) ":" unq(qop) ":" H(A2) )

If the "qop" directive is not present:
KD ( H(A1), unq(nonce) ":" H(A2) )


main

public static void main(java.lang.String[] args)
Main method. It tests DigestAuthentication with the example provided in the RFC2617.

MjSip Stack
v1.6