org.openid4java.message
Class Message

java.lang.Object
  extended by org.openid4java.message.Message
Direct Known Subclasses:
AssociationRequest, AssociationResponse, AuthFailure, AuthImmediateFailure, AuthRequest, AuthSuccess, DirectError, IndirectError, VerifyResponse

public class Message
extends java.lang.Object

Author:
Marius Scurtescu, Johnny Bufu

Field Summary
protected  java.lang.String _destinationUrl
           
static java.lang.String MODE_CANCEL
           
static java.lang.String MODE_IDRES
           
static java.lang.String MODE_SETUP_NEEDED
           
static java.lang.String OPENID2_NS
           
 
Constructor Summary
protected Message()
           
protected Message(ParameterList params)
           
 
Method Summary
 void addExtension(MessageExtension extension)
          Adds a set of extension-specific parameters to a message.
static void addExtensionFactory(java.lang.Class clazz)
          Adds a new extension factory.
static Message createMessage()
           
static Message createMessage(ParameterList params)
           
 java.lang.String getDestinationUrl(boolean httpGet)
          Gets the URL where the message should be sent, where applicable.
 MessageExtension getExtension(java.lang.String typeUri)
          Gets a MessageExtension for the specified Type URI if an implementation is available, or null otherwise.
 java.lang.String getExtensionAlias(java.lang.String extensionTypeUri)
          Retrieves the extension alias that will be used for the extension identified by the supplied extension type URI.
static MessageExtensionFactory getExtensionFactory(java.lang.String typeUri)
          Gets a MessageExtensionFactory for the specified Type URI if an implementation is available, or null otherwise.
 java.util.Set getExtensions()
          Gets a set of extension Type URIs that are present in the message.
protected  Parameter getParameter(java.lang.String name)
           
 java.util.Map getParameterMap()
           
protected  java.util.List getParameters()
           
 java.lang.String getParameterValue(java.lang.String name)
           
 java.util.List getRequiredFields()
           
 boolean hasExtension(java.lang.String typeUri)
          Returns true if the message has parameters for the specified extension type URI.
static boolean hasExtensionFactory(java.lang.String typeUri)
          Returns true if there is an extension factory available for extension identified by the specified Type URI, or false otherwise.
 boolean hasParameter(java.lang.String name)
           
 java.lang.String keyValueFormEncoding()
           
protected  void set(java.lang.String name, java.lang.String value)
           
 void validate()
          Checks that all required parameters are present
 java.lang.String wwwFormEncoding()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_IDRES

public static final java.lang.String MODE_IDRES
See Also:
Constant Field Values

MODE_CANCEL

public static final java.lang.String MODE_CANCEL
See Also:
Constant Field Values

MODE_SETUP_NEEDED

public static final java.lang.String MODE_SETUP_NEEDED
See Also:
Constant Field Values

OPENID2_NS

public static final java.lang.String OPENID2_NS
See Also:
Constant Field Values

_destinationUrl

protected java.lang.String _destinationUrl
Constructor Detail

Message

protected Message()

Message

protected Message(ParameterList params)
Method Detail

createMessage

public static Message createMessage()
                             throws MessageException
Throws:
MessageException

createMessage

public static Message createMessage(ParameterList params)
                             throws MessageException
Throws:
MessageException

getParameter

protected Parameter getParameter(java.lang.String name)

getParameterValue

public java.lang.String getParameterValue(java.lang.String name)

hasParameter

public boolean hasParameter(java.lang.String name)

set

protected void set(java.lang.String name,
                   java.lang.String value)

getParameters

protected java.util.List getParameters()

getParameterMap

public java.util.Map getParameterMap()

validate

public void validate()
              throws MessageException
Checks that all required parameters are present

Throws:
MessageException

getRequiredFields

public java.util.List getRequiredFields()

keyValueFormEncoding

public java.lang.String keyValueFormEncoding()

wwwFormEncoding

public java.lang.String wwwFormEncoding()

getDestinationUrl

public java.lang.String getDestinationUrl(boolean httpGet)
Gets the URL where the message should be sent, where applicable. Null for received messages.

Parameters:
httpGet - If true, the wwwFormEncoding() is appended to the destination URL; the return value should be used with a GET-redirect. If false, the verbatim destination URL is returned, which should be used with a FORM POST redirect.
See Also:
wwwFormEncoding()

addExtensionFactory

public static void addExtensionFactory(java.lang.Class clazz)
                                throws MessageException
Adds a new extension factory.

Parameters:
clazz - The implementation class for the extension factory, must implement MessageExtensionFactory.
Throws:
MessageException

hasExtensionFactory

public static boolean hasExtensionFactory(java.lang.String typeUri)
Returns true if there is an extension factory available for extension identified by the specified Type URI, or false otherwise.

Parameters:
typeUri - The Type URI that identifies an extension.

getExtensionFactory

public static MessageExtensionFactory getExtensionFactory(java.lang.String typeUri)
Gets a MessageExtensionFactory for the specified Type URI if an implementation is available, or null otherwise.

Parameters:
typeUri - The Type URI that identifies a extension.
See Also:
Message

hasExtension

public boolean hasExtension(java.lang.String typeUri)
Returns true if the message has parameters for the specified extension type URI.

Parameters:
typeUri - The URI that identifies the extension.

getExtensions

public java.util.Set getExtensions()
Gets a set of extension Type URIs that are present in the message.


getExtensionAlias

public java.lang.String getExtensionAlias(java.lang.String extensionTypeUri)
Retrieves the extension alias that will be used for the extension identified by the supplied extension type URI.

If the message contains no parameters for the specified extension, null will be returned.

Parameters:
extensionTypeUri - The URI that identifies the extension
Returns:
The extension alias associated with the extension specifid by the Type URI

addExtension

public void addExtension(MessageExtension extension)
                  throws MessageException
Adds a set of extension-specific parameters to a message.

The parameter names must NOT contain the "openid." prefix; it will be generated dynamically, ensuring there are no conflicts between extensions.

Parameters:
extension - A MessageExtension containing parameters to be added to the message
Throws:
MessageException

getExtension

public MessageExtension getExtension(java.lang.String typeUri)
                              throws MessageException
Gets a MessageExtension for the specified Type URI if an implementation is available, or null otherwise.

The returned object will contain the parameters from the message belonging to the specified extension.

Parameters:
typeUri - The Type URI that identifies a extension.
Throws:
MessageException


Copyright © 2011 Sxip. All Rights Reserved.