uk.ac.cam.ucs.webauth
Class WLSResponse

java.lang.Object
  extended byuk.ac.cam.ucs.webauth.WLSResponse
All Implemented Interfaces:
Principal

public class WLSResponse
extends Object
implements Principal

Represents an authentication response message.

Version:
$Revision: 1.5 $ $Date: 2005/03/09 18:07:39 $

Constructor Summary
WLSResponse(String token)
          Constructs a new WLSResponse object from a string representation of a response.
 
Method Summary
 boolean equals(Object object)
          Tests for equality of the principle (only) between two WLSResponse objects.
 String getAuth()
          Returns a text token representing the authentication method used to establish the identity carried in this response if authentication was successfully established by interaction with the user.
 String getId()
          Returns the unique ID from this response.
 Date getIssue()
          Returns the date/time this response message was issued
 String getKId()
          Returns a tring which identifies the RSA key used to form a signature supplied with this response.
 int getLife()
          Returns the remaining life of any single sign-on session established by the user on the WLS server.
 String getMsg()
          Returns the message string from this response.
 String getName()
          An alias for getPrincipal.
 String getParams()
          Returns the params value from the response.
 String getPrincipal()
          Returns the principal (user-id) from this response.
 String getRawData()
          Returns the raw data from this response, less the key-id and signature.
 String getSig()
          Returns the response signature string.
 HashSet getSSO()
          Returns a set of text token representing the authentication method(s) used to establish the identity carried in this response if authentication was successfully established based on previous successful authentication interaction(s) with the user.
 int getStatus()
          Returns the numeric status code from this response.
 URL getURL()
          Returns the URL from this response.
 int getVer()
          Returns the protocol version number from this response.
 int hashCode()
          Returns a hash code for the identity of the user described by this response (not for the response itself)
 String toFullString()
          Returns a human-readable string representation this response mesage
 String toString()
          An alias for getPrincipal.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WLSResponse

public WLSResponse(String token)
            throws WLSException
Constructs a new WLSResponse object from a string representation of a response. This method does not attempt to validate the response message it is parsing (see #WLSValidate WLSValidate) but does throw errors if presented with unparsable input.

Parameters:
token - a Response message in string form
Throws:
WLSException - when presented with unparsable input
Method Detail

getVer

public int getVer()
Returns the protocol version number from this response. This will not be greater than the protocol version number of the coresponding request

Returns:
the version number, or -1 if the protocol version number was missing from this response

getStatus

public int getStatus()
Returns the numeric status code from this response. This is a three digit numeric code indicating the status of the authentication request. '200' indicates success

Returns:
the status code, or -1 if the status code was missing from this response
See Also:
#statusString, WLS

getMsg

public String getMsg()
Returns the message string from this response. This is a message further describing the status of the authentication request, suitable for display to end-user. string.

Returns:
the message, or null if the message was missing from this response

getIssue

public Date getIssue()
Returns the date/time this response message was issued

Returns:
the date/time, or null if the issue date/time was missing from this response

getId

public String getId()
Returns the unique ID from this response. This, combined with 'issue' provides a unique identifier for this particular response mesage. This ID is not unguessable.

Returns:
the unique ID, or null if the unique ID was missing from this response

getURL

public URL getURL()
Returns the URL from this response. This should be value of the 'url' parameter from the coresponding request.

Returns:
the URL, or null if the URL was missing from this response

getPrincipal

public String getPrincipal()
Returns the principal (user-id) from this response.

Returns:
the principal, or null if the principal was missing from this response

getAuth

public String getAuth()
Returns a text token representing the authentication method used to establish the identity carried in this response if authentication was successfully established by interaction with the user. Otherwise empty. The only defined value for an authentication type pwd representing an authentication using username and password. Elements starting 'x-' are reserved for experimental use by prior agreement.

Returns:
the first-hand authentication method token, or null if no first-hand authentication method was included in the response

getSSO

public HashSet getSSO()
Returns a set of text token representing the authentication method(s) used to establish the identity carried in this response if authentication was successfully established based on previous successful authentication interaction(s) with the user. The only defined value for an authentication type pwd representing an authentication using username and password. Elements starting 'x-' are reserved for experimental use by prior agreement.

Returns:
a set of authentication method tokens, or null if no SSO authentication methods were included in this response.

getLife

public int getLife()
Returns the remaining life of any single sign-on session established by the user on the WLS server. A client should use this to establish an upper limit to the lifetime of any session that it establishes. This inforation need not be included in a reply, in which case life will be set to 0.

Returns:
life (in seconds), or -1 if no life parameter was included in this response

getParams

public String getParams()
Returns the params value from the response. This is a copy of the 'params' parameter from the coresponding request.

Returns:
a string representation of the params value, or null if no params parameter was included in this response

getKId

public String getKId()
Returns a tring which identifies the RSA key used to form a signature supplied with this response. Typically these will be a string representation of small numbers. This information is only required if a signature is present (see getSig).

Returns:
the key identity, or null if no key identifier was included in this response

getSig

public String getSig()
Returns the response signature string. A signature is only required if the status is 200 and is optional otherwise.

This is a public-key signature of the response data, except for 'kid' and 'signature'. It is formed by first concatenating the string representations of the parameters using '!' as a separator character. If the characters '!' or '%' appear in any field value they MUST be replaced by their %-encoded representation before concatenation. Characters other than '!' and '%' MUST NOT be encoded at this stage. The signature is then derived using this concatenation, the private key identified by 'kid', the SHA-1 hash algorithm and the 'RSASSA-PKCS1-v1_5' scheme as specified in PKCS #1 v2.1 [RFC 3447] and the resulting signature encoded using the base64 scheme [RFC 1521] except that the characters '+', '/', and '=' are replaced by '-', '.' and '_' to reduce the URL-encoding overhead.

Returns:
the string representating the signature, or null if this response was not signed

getRawData

public String getRawData()
Returns the raw data from this response, less the key-id and signature. This is exactly the data over which the signature sghould be calculated.

Returns:
a string representing the raw data, or null if there was no raw data

getName

public String getName()
An alias for getPrincipal. Returns the principal (user-id) from this response

Specified by:
getName in interface Principal
Returns:
the principal, or null if the principal was missing from this response

hashCode

public int hashCode()
Returns a hash code for the identity of the user described by this response (not for the response itself)

Specified by:
hashCode in interface Principal
Returns:
a hash code

equals

public boolean equals(Object object)
Tests for equality of the principle (only) between two WLSResponse objects.

Specified by:
equals in interface Principal
Returns:
boolean equality

toString

public String toString()
An alias for getPrincipal. Returns the principal (user-id) from the response

Specified by:
toString in interface Principal
Returns:
the principal, or null if the principal was missing from this response

toFullString

public String toFullString()
Returns a human-readable string representation this response mesage

Returns:
string representation of this response