mymobilesite.communication
Class SaslMessage

java.lang.Object
  extended by org.ksoap2.SoapEnvelope
      extended by mymobilesite.communication.LibertyMessage
          extended by mymobilesite.communication.SaslMessage

public class SaslMessage
extends LibertyMessage

This class is responsible for handling the communication with the authentication service.

Author:
Gunn Olaussen & Kirsti N. Torgersen

Field Summary
private  ResourceOffering disco
           
private static char LOWERCASE
           
private  boolean needAnotherRequest
           
private  Element request
           
private static char SELECT
           
private  java.lang.String[][] transformations
           
private static char TRUNCATION
           
private  java.lang.String un
           
private static char UPPERCASE
           
 
Fields inherited from class mymobilesite.communication.LibertyMessage
correlationHeader, offering, receivedMessageID, sa, sb, securityHeader, sentMessageID, wsse
 
Fields inherited from class org.ksoap2.SoapEnvelope
bodyIn, bodyOut, enc, ENC, ENC2001, encodingStyle, env, ENV, ENV2001, headerIn, headerOut, VER10, VER11, VER12, version, xsd, XSD, XSD1999, xsi, XSI, XSI1999
 
Constructor Summary
SaslMessage()
          The constructor creates an empty SaslMessage.
 
Method Summary
private  void createRequest(java.lang.String pwd, boolean second)
          This method creates the request that is to be set to the authentication service at the Identity Provider.
protected  void processResponse(Element element)
          This method processes the current element and stores the ResourceOffering for the Discovery Service so that it can be returned to the LibertyProtocol later.
 ResourceOffering sendRequest(java.lang.String un, java.lang.String pwd, AuthTransport session)
          This method constructs the SaslRequest, sends it and processes the response.
private  java.lang.String transform(java.lang.String text)
          In some cases the authentication service may specify that the password provided by the user should be transformed in some way.
 
Methods inherited from class mymobilesite.communication.LibertyMessage
createCorrelationHeader, createSecurityHeader, processCorrelationHeader, processResponseBody
 
Methods inherited from class org.ksoap2.SoapEnvelope
parse, parseBody, parseHeader, setOutputSoapObject, stringToBoolean, write, writeBody, writeHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UPPERCASE

private static final char UPPERCASE
See Also:
Constant Field Values

LOWERCASE

private static final char LOWERCASE
See Also:
Constant Field Values

SELECT

private static final char SELECT
See Also:
Constant Field Values

TRUNCATION

private static final char TRUNCATION
See Also:
Constant Field Values

transformations

private java.lang.String[][] transformations

request

private Element request

un

private java.lang.String un

disco

private ResourceOffering disco

needAnotherRequest

private boolean needAnotherRequest
Constructor Detail

SaslMessage

public SaslMessage()
The constructor creates an empty SaslMessage.

Method Detail

sendRequest

public ResourceOffering sendRequest(java.lang.String un,
                                    java.lang.String pwd,
                                    AuthTransport session)
                             throws MessageException
This method constructs the SaslRequest, sends it and processes the response. If everything is successful it returns the ResourceOffering for the Discovery Service.

Parameters:
un - String The username to be authenticated.
pwd - String The password provided by the user.
session - AuthTransport The transport to be used in the communication with the authentication service.
Returns:
ResourceOffering The ResourceOffering for the DiscoveryService.
Throws:
MessageException - If something wrong happens or the authentication fails, an exception with the apporpriate error code is thrown.

createRequest

private void createRequest(java.lang.String pwd,
                           boolean second)
This method creates the request that is to be set to the authentication service at the Identity Provider.

Parameters:
pwd - String The password provided by the user.
second - boolean If this parameter is true it means that this message is sent in response to a previously received message.

processResponse

protected void processResponse(Element element)
                        throws MessageException
This method processes the current element and stores the ResourceOffering for the Discovery Service so that it can be returned to the LibertyProtocol later.

Specified by:
processResponse in class LibertyMessage
Parameters:
current - Element The element that is to be processed.
Throws:
MessageException - If the authentication is rejected or the message is invalid.

transform

private java.lang.String transform(java.lang.String text)
                            throws MessageException
In some cases the authentication service may specify that the password provided by the user should be transformed in some way. This method takes care of these transformation by transforming the text according to the methods specified in the transformations variable.

Parameters:
text - String The text that should be transformed.
Returns:
String The transformed text.
Throws:
MessageException - If one of the methods are invalid it means that the message they arrived in is invalid. Consequently a MessageException with an appropriate error code is thrown.