uk.ac.cam.ucs.webauth
Class WebauthResponse

java.lang.Object
  |
  +--uk.ac.cam.ucs.webauth.WebauthResponse

public class WebauthResponse
extends Object

Represents an authentication response message.

Version:
$Revision: 1.10 $ $Date: 2005/03/31 15:09:19 $
See Also:
The Cambridge Web Authentication System: WAA->WLS communication protocol

Field Summary
static int BAD_VERSION
          Status code indicating that the authentication server does not support the version of the protocol used in the authentication response.
static int CANCELED
          Status code indicating that the user actively abandoned the authentication process by selecting a cancel button or similar process.
static int DECLINED
          Status code indicating that the authentication server declines to provide authentication services on this occasion.
static int IACT_REQUIRED
          Status code indicating that a request specified 'iact' as 'no' but either the user is not currently identified to the WLS or the user has asked to be notified before responses that identify him/her are issued.
static int NO_COMMON_AUTH
          Status code indicating that the authentication server does not support any of the authentication types specified in the 'aauth' parameter of the authentication request.
static int REQUEST_ERROR
          Status code indicating tha tthere was a problem decoding the request parameters that is not covered by a more specific status - perhaps an unrecognised parameter.
static int SUCCESS
          Status code representing successfull authentication
static int UNAUTHORIZED
          Status code indicating that this application is not authorised to use the targeted authentication server.
 
Constructor Summary
WebauthResponse(String token)
          Constructs a new WebauthResponse object from a string representation of a response.
 
Method Summary
 String get(String field)
          Returns the string value of the specified field from this response
 Collection getColl(String field)
          Returns a java.util.collection containing the comma-seperated strings from the specified field from this response
 long getDate(String field)
          Returns the value of the specified response field as a long value that represents a Date object.
 Iterator getFieldNames()
          Returns a java.util.Iterator of all the field names that this response contains.
 int getInt(String field)
          Returns an integer value expressing the value of the specified field from this response
 String getRawData()
          Returns the raw data from this response, less the key-id and signature.
 int length()
          Returns the number of fields found in the response
static String statusString(int status)
          Returns a String description of a int status code
static String statusString(String status)
          Returns a String description of a String status code
 String toString()
          Returns a human-readable string representation this response mesage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUCCESS

public static final int SUCCESS
Status code representing successfull authentication

CANCELED

public static final int CANCELED
Status code indicating that the user actively abandoned the authentication process by selecting a cancel button or similar process. Note that users can equally abandoned the authentication process by directing their browser elsewhere after an authentication request in which case no response will be forthcoming.

NO_COMMON_AUTH

public static final int NO_COMMON_AUTH
Status code indicating that the authentication server does not support any of the authentication types specified in the 'aauth' parameter of the authentication request.

BAD_VERSION

public static final int BAD_VERSION
Status code indicating that the authentication server does not support the version of the protocol used in the authentication response. This status code will only ever be sent in a response with the 'ver' field' set to 1.

REQUEST_ERROR

public static final int REQUEST_ERROR
Status code indicating tha tthere was a problem decoding the request parameters that is not covered by a more specific status - perhaps an unrecognised parameter.

IACT_REQUIRED

public static final int IACT_REQUIRED
Status code indicating that a request specified 'iact' as 'no' but either the user is not currently identified to the WLS or the user has asked to be notified before responses that identify him/her are issued.

UNAUTHORIZED

public static final int UNAUTHORIZED
Status code indicating that this application is not authorised to use the targeted authentication server.

DECLINED

public static final int DECLINED
Status code indicating that the authentication server declines to provide authentication services on this occasion.
Constructor Detail

WebauthResponse

public WebauthResponse(String token)
Constructs a new WebauthResponse object from a string representation of a response. This method does not attempt to validate the response message it is parsing (see WebauthValidator).
Parameters:
token - a Response message in string form
Method Detail

statusString

public static String statusString(String status)
Returns a String description of a String status code
Parameters:
status - String status code
Returns:
text description

statusString

public static String statusString(int status)
Returns a String description of a int status code
Parameters:
status - int status code
Returns:
text description

length

public int length()
Returns the number of fields found in the response
Returns:
the number of fields

getFieldNames

public Iterator getFieldNames()
Returns a java.util.Iterator of all the field names that this response contains.
Returns:
an Iterator of all the field names

get

public String get(String field)
Returns the string value of the specified field from this response
Parameters:
field - a field name from the response
Returns:
the string value of the specified field; or "" if the specified field was not present in the response.

getInt

public int getInt(String field)
           throws WebauthException
Returns an integer value expressing the value of the specified field from this response
Parameters:
field - a field name from the response
Returns:
an integer expressing the value of the response field or -1 if the response doesn't have a field of this name or it was empty
Throws:
WebauthException - if the field can't be converted into an int

getDate

public long getDate(String field)
             throws WebauthException
Returns the value of the specified response field as a long value that represents a Date object. The date is returned as the number of milliseconds since January 1, 1970 GMT.
Parameters:
field - a field name from the response
Returns:
a long value representing the date specified in the field expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the response doesn't have a field of this name or it was empty
Throws:
WebauthException - if the field can't be converted into an date

getColl

public Collection getColl(String field)
Returns a java.util.collection containing the comma-seperated strings from the specified field from this response
Parameters:
field - a field name from the response
Returns:
a java.utils.Collection containing the comma-seperated strings from the specified response field. Returns an empty collection if the response doesn't have a field of this name or it was empty

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 should be calculated.
Returns:
a string representing the raw data, or an empty string if there was no raw data

toString

public String toString()
Returns a human-readable string representation this response mesage
Overrides:
toString in class Object
Returns:
string representation of this response