org.openid4java.message.ax
Class FetchResponse

java.lang.Object
  extended by org.openid4java.message.ax.AxMessage
      extended by org.openid4java.message.ax.FetchResponse
All Implemented Interfaces:
MessageExtension, MessageExtensionFactory

public class FetchResponse
extends AxMessage

Implements the extension for Attribute Exchange fetch responses.

Author:
Marius Scurtescu, Johnny Bufu

Field Summary
private  int _attrAliasGen
           
private static org.apache.commons.logging.Log _log
           
private static boolean DEBUG
           
 
Fields inherited from class org.openid4java.message.ax.AxMessage
_parameters, OPENID_NS_AX
 
Constructor Summary
protected FetchResponse()
          Constructs a Fetch Response with an empty parameter list.
protected FetchResponse(ParameterList params)
          Constructs a FetchResponse from a parameter list.
 
Method Summary
 java.lang.String addAttribute(java.lang.String typeUri, java.lang.String value)
          Adds an attribute to the FetchResponse, without the caller having to specify an alias.
 void addAttribute(java.lang.String alias, java.lang.String typeUri, java.lang.String value)
          Adds an attribute to the fetch response.
 void addAttributes(java.util.Map attributes)
          Adds the attributes in the supplied Map to the FetchResponse.
private  boolean checkAttributes()
           
static FetchResponse createFetchResponse()
          Constructs a Fetch Response with an empty parameter list.
static FetchResponse createFetchResponse(FetchRequest req, java.util.Map userData)
          Creates a FetchResponse from a FetchRequest message and the data released by the user.
static FetchResponse createFetchResponse(ParameterList params)
           
 java.util.List getAttributeAliases()
          Gets a list of attribute aliases.
 java.util.Map getAttributes()
          Gets a map with attribute aliases -> list of values.
 java.util.Map getAttributeTypes()
          Gets a map with attribute aliases -> attribute type URI.
 java.lang.String getAttributeValue(java.lang.String alias)
          Gets the (first) for the specified attribute alias.
 java.util.List getAttributeValues(java.lang.String alias)
          Returns a list with the attribute value(s) associated for the specified attribute alias.
 int getCount(java.lang.String alias)
          Gets the number of values provided in the fetch response for the specified attribute alias.
 java.lang.String getUpdateUrl()
          Gets the optional 'update_url' parameter if available, or null otherwise.
private  boolean isValid()
          Checks the validity of the extension.
private  void setCount(java.lang.String alias, int count)
          Sets the number of values provided in the fetch response for the specified attribute alias.
 void setUpdateUrl(java.lang.String updateUrl)
          Sets the optional 'update_url' parameter where the OP can later re-post fetch-response updates for the values of the requested attributes.
 
Methods inherited from class org.openid4java.message.ax.AxMessage
getExtension, getParameters, getParameterValue, getTypeUri, providesIdentifier, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log

private static org.apache.commons.logging.Log _log

DEBUG

private static final boolean DEBUG

_attrAliasGen

private int _attrAliasGen
Constructor Detail

FetchResponse

protected FetchResponse()
Constructs a Fetch Response with an empty parameter list.


FetchResponse

protected FetchResponse(ParameterList params)
Constructs a FetchResponse from a parameter list.

The parameter list can be extracted from a received message with the getExtensionParams method of the Message class, and MUST NOT contain the "openid.." prefix.

Method Detail

createFetchResponse

public static FetchResponse createFetchResponse()
Constructs a Fetch Response with an empty parameter list.


createFetchResponse

public static FetchResponse createFetchResponse(ParameterList params)
                                         throws MessageException
Throws:
MessageException

createFetchResponse

public static FetchResponse createFetchResponse(FetchRequest req,
                                                java.util.Map userData)
                                         throws MessageException
Creates a FetchResponse from a FetchRequest message and the data released by the user.

Parameters:
req - FetchRequest message.
userData - The userData may be a Map or a Map values>. The attribute values are provided by the calling application. If a list of values is specified per attribute, at most n will be sent, where n is the number of attribute values requested in the FetchRequest.
Returns:
Properly formed FetchResponse.
Throws:
MessageException

addAttribute

public void addAttribute(java.lang.String alias,
                         java.lang.String typeUri,
                         java.lang.String value)
                  throws MessageException
Adds an attribute to the fetch response.

Parameters:
alias - The alias identifier that will be associated with the attribute type URI.
typeUri - The attribute type URI.
value - The value of the attribute.
Throws:
MessageException

addAttribute

public java.lang.String addAttribute(java.lang.String typeUri,
                                     java.lang.String value)
Adds an attribute to the FetchResponse, without the caller having to specify an alias. An alias in the form "attrNN" will be automatically generated.

Parameters:
typeUri - The attribute type URI.
value - The attribute value.
Returns:
The generated attribute alias.

addAttributes

public void addAttributes(java.util.Map attributes)
Adds the attributes in the supplied Map to the FetchResponse. A requested count of 1 is assumed for each attribute in the map.

Parameters:
attributes - Map.

getAttributeValues

public java.util.List getAttributeValues(java.lang.String alias)
Returns a list with the attribute value(s) associated for the specified attribute alias.

Parameters:
alias - The attribute alias.
Returns:
List of attribute values.

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String alias)
Gets the (first) for the specified attribute alias.


getAttributeAliases

public java.util.List getAttributeAliases()
Gets a list of attribute aliases.


getAttributes

public java.util.Map getAttributes()
Gets a map with attribute aliases -> list of values.


getAttributeTypes

public java.util.Map getAttributeTypes()
Gets a map with attribute aliases -> attribute type URI.


getCount

public int getCount(java.lang.String alias)
Gets the number of values provided in the fetch response for the specified attribute alias.

Parameters:
alias - The attribute alias.

setCount

private void setCount(java.lang.String alias,
                      int count)
Sets the number of values provided in the fetch response for the specified attribute alias. The value must be greater than 1.

Parameters:
alias - The attribute alias.
count - The number of values.

setUpdateUrl

public void setUpdateUrl(java.lang.String updateUrl)
                  throws MessageException
Sets the optional 'update_url' parameter where the OP can later re-post fetch-response updates for the values of the requested attributes.

Parameters:
updateUrl - The URL where the RP accepts later updates for the requested attributes.
Throws:
MessageException

getUpdateUrl

public java.lang.String getUpdateUrl()
Gets the optional 'update_url' parameter if available, or null otherwise.


isValid

private boolean isValid()
Checks the validity of the extension.

Used when constructing a extension from a parameter list.

Returns:
True if the extension is valid, false otherwise.

checkAttributes

private boolean checkAttributes()


Copyright 2006-2007 Sxip Identity Corporation