discovery
Class DiscoResponse

java.lang.Object
  extended by discovery.DiscoResponse

public class DiscoResponse
extends java.lang.Object

The class DiscoResponse is used to create the reponse message. It needs to create the header and the body. The body contains the offerings or an status code indicating error. This also creates the tokens and a signature of the assertion.

Author:
Gunn Olaussen & Kirsti N. Torgersen

Field Summary
private  java.security.cert.X509Certificate cert
           
private static java.lang.String disco
           
private static java.lang.String ds
           
private  javax.xml.soap.SOAPEnvelope env
           
private  java.lang.String issuerid
           
private static java.lang.String keystoreFile
           
private  javax.xml.soap.SOAPMessage message
           
private  ResourceOffering[] offerings
           
private  java.security.PrivateKey privateKey
           
private  DiscoQuery query
           
private static java.lang.String saml
           
static java.lang.String STATUS_FAILED
           
static java.lang.String STATUS_OK
           
private  java.lang.String statusCode
           
private static int TIME_TO_LIVE
           
 
Constructor Summary
DiscoResponse(DiscoQuery query, ResourceOffering[] offerings, java.lang.String statusCode)
          The constructor creates the message and initialises variables that are used in message creation.
 
Method Summary
private  void addOfferings(javax.xml.soap.SOAPElement queryResponse)
          This appends the offerings to the response element by calling a method in ResourceOffering which adds offerings (stored in a Node) to a SOAPElement.
private  void createBody()
          When creating the body the method adds the status element and an element which holds the content of the response.
private  void createHeaders()
          This method creates the header by adding all the required fields such as the correlation and timestamp.
private  void createSignature(javax.xml.soap.SOAPElement assertion)
          This method signs an authorisation assertion without the signature element and adds the signature to the assertion.
private  void createTokens(javax.xml.soap.SOAPElement queryResponse)
          This method creates an authorisation assertion for each resource offering returned.
private  java.lang.String prepareAssertion(java.lang.String assertion)
          This method removes line breaks to make the assertion similar at all times when using it for signing and signature verification.
private  void setStatusFailed()
          Used to set the status code of this message to failed if something went wrong during the message creation.
 java.lang.String toString()
          Returns a string representation of this request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATUS_OK

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

STATUS_FAILED

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

disco

private static final java.lang.String disco
See Also:
Constant Field Values

saml

private static final java.lang.String saml
See Also:
Constant Field Values

ds

private static final java.lang.String ds
See Also:
Constant Field Values

TIME_TO_LIVE

private static final int TIME_TO_LIVE
See Also:
Constant Field Values

keystoreFile

private static final java.lang.String keystoreFile
See Also:
Constant Field Values

query

private DiscoQuery query

privateKey

private java.security.PrivateKey privateKey

offerings

private ResourceOffering[] offerings

statusCode

private java.lang.String statusCode

issuerid

private java.lang.String issuerid

message

private javax.xml.soap.SOAPMessage message

env

private javax.xml.soap.SOAPEnvelope env

cert

private java.security.cert.X509Certificate cert
Constructor Detail

DiscoResponse

public DiscoResponse(DiscoQuery query,
                     ResourceOffering[] offerings,
                     java.lang.String statusCode)
The constructor creates the message and initialises variables that are used in message creation. It calls two other methods to create the header and body of the message.

Parameters:
query - DiscoQuery The request message related to this response
offerings - ResourceOffering[] The offerings that was found for this user
statusCode - String The status code which indicates the type of message to be sent
Method Detail

setStatusFailed

private void setStatusFailed()
Used to set the status code of this message to failed if something went wrong during the message creation. This also removes anything added to the message and creates an error message.


createHeaders

private void createHeaders()
                    throws javax.xml.soap.SOAPException
This method creates the header by adding all the required fields such as the correlation and timestamp.

Throws:
javax.xml.soap.SOAPException

createBody

private void createBody()
                 throws javax.xml.soap.SOAPException,
                        java.security.GeneralSecurityException
When creating the body the method adds the status element and an element which holds the content of the response. If the status is OK, then methods to add the offerings and tokens are called.

Throws:
javax.xml.soap.SOAPException
java.security.GeneralSecurityException

addOfferings

private void addOfferings(javax.xml.soap.SOAPElement queryResponse)
                   throws javax.xml.soap.SOAPException
This appends the offerings to the response element by calling a method in ResourceOffering which adds offerings (stored in a Node) to a SOAPElement.

Throws:
javax.xml.soap.SOAPException

createTokens

private void createTokens(javax.xml.soap.SOAPElement queryResponse)
                   throws javax.xml.soap.SOAPException,
                          java.security.GeneralSecurityException
This method creates an authorisation assertion for each resource offering returned.

Throws:
javax.xml.soap.SOAPException
java.security.GeneralSecurityException

prepareAssertion

private java.lang.String prepareAssertion(java.lang.String assertion)
This method removes line breaks to make the assertion similar at all times when using it for signing and signature verification.


createSignature

private void createSignature(javax.xml.soap.SOAPElement assertion)
                      throws javax.xml.soap.SOAPException,
                             java.security.GeneralSecurityException
This method signs an authorisation assertion without the signature element and adds the signature to the assertion.

Throws:
javax.xml.soap.SOAPException
java.security.GeneralSecurityException

toString

public java.lang.String toString()
Returns a string representation of this request.

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()