org.openliberty.wsc
Class WSFMessage

java.lang.Object
  extended by org.openliberty.wsc.WSFMessage

public class WSFMessage
extends java.lang.Object

WSFMessage is an openLiberty ID-WSF-specific implementation of an authentication message

Author:
curtis, asa

Field Summary
private  java.lang.String actionString
          This is the action that the message is intended to perform
protected static org.opensaml.xml.XMLObjectBuilderFactory builderFactory
          XMLObject builder factory.
private  boolean endpointUpdated
          When an EndpointUpdate header is received and processed, this is set to true
private  org.opensaml.ws.soap.soap11.Envelope envelope
          SOAP Request
protected static org.apache.log4j.Logger log
           
protected static org.opensaml.xml.io.MarshallerFactory marshallerFactory
          XMLObject marshaller factory.
protected static org.opensaml.xml.parse.BasicParserPool parser
          Parser manager used to parse XML.
private  RedirectRequest redirectRequest
          If the SOAP Response contains a Fault with a RedirectRequest element, it is stored here.
private  org.opensaml.ws.soap.soap11.Envelope responseEnvelope
          SOAP Response
private  BaseServiceClient serviceClient
          This is the Service Client that is invoking a particular WSFMessage.
private  java.util.List<java.lang.String> signatureIds
          Holds the reference IDs of the elements to be included in any signature
protected static org.opensaml.xml.io.UnmarshallerFactory unmarshallerFactory
          XMLObject marshaller factory.
 
Constructor Summary
private WSFMessage(BaseServiceClient serviceClient)
           
 
Method Summary
 void addSOAP11Attributes(org.opensaml.xml.AttributeExtensibleXMLObject obj, boolean mustUnderstand)
           
 void addWSUIdAttribute(org.opensaml.xml.AttributeExtensibleXMLObject obj, java.lang.String id)
          This method adds an id to an AttributeExtensibleXMLObject and then places that Id in signatureIds for signig
static org.opensaml.ws.soap.soap11.Envelope buildSOAPEnvelope()
          This method creates the Basic SOAP Envelope
static WSFMessage createWSFMessage(BaseServiceClient serviceClient, java.lang.String actionString)
          Factory method to create a WSFMessage from an EPR.
 org.opensaml.ws.soap.soap11.Envelope getRequestEnvelope()
           
 org.opensaml.ws.soap.soap11.Envelope getResponseEnvelope()
           
protected  BaseServiceClient getServiceClient()
           
 java.util.List<java.lang.String> getSignatureIds()
          Holds the reference ids of the SOAP Body element (the element itself), the security token associated with the signature, and all headers in the message that have been defined in the Liberty SOAP Bindings specification, including both required and optional header blocks.
private  void handleEndpointUpdatedState()
          After an EndpointUpdate, the original message is invoked again, with a different EPR
private  boolean handleInappropriateCredentials()
          Handles the InappropriateCredentials Fault.
private  void handleRedirectRequestState()
          If the WSC resends its request it MUST set the value of the wsa:RelatesTo SOAP Header to the same value of the wsa:MessageID SOAP Header of the SOAP Fault that carried the <RedirectRequest> element.
 boolean hasRedirectRequestBeenIssued()
          The RedirectRequest element instructs the WSC to redirect the user to the WSP.
 boolean hasUpdatedEndpointReference()
          This boolean indicates that there is an updated endpoint reference that needs to be processed by the service client.
private  void initializeRequestEnvelope()
           
 void invoke()
          Invoke the WSFMessage sending the SOAP requestEvelope and placing the response in the responseEnvelope.
static java.lang.String prettyPrintRequestMessage(WSFMessage message)
          Prints a nice looking output of the request message
static java.lang.String prettyPrintResponseMessage(WSFMessage message)
          Prints a nice looking output of the response message
private  boolean processEndpointUpdated()
          This method handles the creation of a new EndpointReference from an EndpointUpdate element.
private  void processResponse(java.lang.String responseString)
          This method will take care of all of the responsibilities required of a WSC when receiving a response from a WSP.
 void setHeaderProcessingContext(ProcessingContext processingContext)
          Adds this ProcessingContext to the header or replaces an existing ProcessingContext with this one
 void setRequestEnvelope(org.opensaml.ws.soap.soap11.Envelope envelope)
           
 void setResponseEnvelope(org.opensaml.ws.soap.soap11.Envelope envelope)
           
protected  void setServiceClient(BaseServiceClient serviceClient)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log

parser

protected static org.opensaml.xml.parse.BasicParserPool parser
Parser manager used to parse XML.


marshallerFactory

protected static org.opensaml.xml.io.MarshallerFactory marshallerFactory
XMLObject marshaller factory.


unmarshallerFactory

protected static org.opensaml.xml.io.UnmarshallerFactory unmarshallerFactory
XMLObject marshaller factory.


builderFactory

protected static org.opensaml.xml.XMLObjectBuilderFactory builderFactory
XMLObject builder factory.


serviceClient

private BaseServiceClient serviceClient
This is the Service Client that is invoking a particular WSFMessage. It is referenced here so that we can do EPR updates.


envelope

private org.opensaml.ws.soap.soap11.Envelope envelope
SOAP Request


responseEnvelope

private org.opensaml.ws.soap.soap11.Envelope responseEnvelope
SOAP Response


actionString

private java.lang.String actionString
This is the action that the message is intended to perform


signatureIds

private java.util.List<java.lang.String> signatureIds
Holds the reference IDs of the elements to be included in any signature


redirectRequest

private RedirectRequest redirectRequest
If the SOAP Response contains a Fault with a RedirectRequest element, it is stored here.


endpointUpdated

private boolean endpointUpdated
When an EndpointUpdate header is received and processed, this is set to true

Constructor Detail

WSFMessage

private WSFMessage(BaseServiceClient serviceClient)
Method Detail

addWSUIdAttribute

public void addWSUIdAttribute(org.opensaml.xml.AttributeExtensibleXMLObject obj,
                              java.lang.String id)
This method adds an id to an AttributeExtensibleXMLObject and then places that Id in signatureIds for signig

http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd

  <xsd:attribute name="Id" type="xsd:ID">
      <xsd:annotation>
          <xsd:documentation>
              This global attribute supports annotating arbitrary elements with an ID.
           </xsd:documentation>
      </xsd:annotation>
  </xsd:attribute>
  


addSOAP11Attributes

public void addSOAP11Attributes(org.opensaml.xml.AttributeExtensibleXMLObject obj,
                                boolean mustUnderstand)

createWSFMessage

public static WSFMessage createWSFMessage(BaseServiceClient serviceClient,
                                          java.lang.String actionString)
                                   throws org.opensaml.xml.parse.XMLParserException,
                                          org.opensaml.xml.io.UnmarshallingException
Factory method to create a WSFMessage from an EPR.

Returns:
Throws:
org.opensaml.xml.io.UnmarshallingException
org.opensaml.xml.parse.XMLParserException

initializeRequestEnvelope

private void initializeRequestEnvelope()
                                throws org.opensaml.xml.parse.XMLParserException,
                                       org.opensaml.xml.io.UnmarshallingException
Throws:
org.opensaml.xml.parse.XMLParserException
org.opensaml.xml.io.UnmarshallingException

getSignatureIds

public java.util.List<java.lang.String> getSignatureIds()
Holds the reference ids of the SOAP Body element (the element itself), the security token associated with the signature, and all headers in the message that have been defined in the Liberty SOAP Bindings specification, including both required and optional header blocks.

Returns:

getServiceClient

protected BaseServiceClient getServiceClient()

setServiceClient

protected void setServiceClient(BaseServiceClient serviceClient)

setHeaderProcessingContext

public void setHeaderProcessingContext(ProcessingContext processingContext)
Adds this ProcessingContext to the header or replaces an existing ProcessingContext with this one

Parameters:
processingContext -

invoke

public void invoke()
            throws java.io.IOException,
                   org.opensaml.xml.io.MarshallingException,
                   org.opensaml.xml.parse.XMLParserException,
                   org.opensaml.xml.io.UnmarshallingException,
                   WSCException,
                   java.security.GeneralSecurityException
Invoke the WSFMessage sending the SOAP requestEvelope and placing the response in the responseEnvelope. Signing is done based on the message level setting of "signed"

Throws:
java.io.IOException
org.opensaml.xml.io.MarshallingException
org.opensaml.xml.parse.XMLParserException
org.opensaml.xml.io.UnmarshallingException
WSCException
java.security.GeneralSecurityException

processResponse

private void processResponse(java.lang.String responseString)
                      throws org.opensaml.xml.parse.XMLParserException,
                             org.opensaml.xml.io.UnmarshallingException,
                             WSCException,
                             java.io.IOException,
                             org.opensaml.xml.io.MarshallingException,
                             java.security.GeneralSecurityException
This method will take care of all of the responsibilities required of a WSC when receiving a response from a WSP.

e.g. Fault:

         <se:Fault xmlns:sb-ext="urn:liberty:sb:2004-04">
             <faultcode>se:Client</faultcode>
             <faultstring>soap fault</faultstring>
              <detail namespace="urn:liberty:sb:2003-08">
                <lu:Status xmlns:lu="urn:liberty:util:2006-08" code="IDStarMsgNotUnderstood"/>
             </detail>
          </se:Fault>
 

Parameters:
responseString -
Throws:
org.opensaml.xml.parse.XMLParserException
org.opensaml.xml.io.UnmarshallingException
WSCException
org.opensaml.xml.io.MarshallingException
java.io.IOException
java.security.GeneralSecurityException

handleInappropriateCredentials

private boolean handleInappropriateCredentials()
Handles the InappropriateCredentials Fault.

In the case of a Fault with a Status code "InappropriateCredentials" this method examines the CredentialsContext header and attempts to renegotiate with the DS for a more appropriate SecurityMechanism or reauthenticate with the AS in the case of a RequestedAuthnContext element being present in the CredentialsContext header.

Returns:

processEndpointUpdated

private boolean processEndpointUpdated()
This method handles the creation of a new EndpointReference from an EndpointUpdate element.

For a COMPLETE Update:

If updateType is not present or has the value urn:liberty:sb:2006-08:EndpointUpdate:Complete, the <wsa:EndpointUpdate> is a completely specified endpoint reference.

For a PARTIAL Update:

1. Take the <wsa:Address> from the <wsa:EndpointUpdate>. If the value is urn:liberty:sb:2006-08:EndpointUpdate:NoChange, then take the <wsa:Address> from the original endpoint reference.

2. Take the <wsa:ReferenceParameters> from the <wsa:EndpointUpdate>, if present. Then, if <wsa:ReferenceParameters> is present in the orginal endpoint reference, take each direct child from that element that does not match an element already taken from the update (comparing the namespace qualified names of the elements).

3. Take the <wsa:Metadata> from the <wsa:EndpointUpdate>, if present. Then, if <wsa:Metadata> is present in the orginal endpoint reference, take each direct child from that element that does not match an element already taken from the update (comparing the namespace qualified names of the elements).

4. Take any extension elements from the <wsa:EndpointUpdate>, if present. Then, if any extension elements are present in the orginal endpoint reference, take each one that does not match * @return


handleEndpointUpdatedState

private void handleEndpointUpdatedState()
                                 throws org.opensaml.xml.parse.XMLParserException,
                                        org.opensaml.xml.io.UnmarshallingException
After an EndpointUpdate, the original message is invoked again, with a different EPR

Throws:
org.opensaml.xml.io.UnmarshallingException
org.opensaml.xml.parse.XMLParserException

handleRedirectRequestState

private void handleRedirectRequestState()
                                 throws org.opensaml.xml.parse.XMLParserException,
                                        org.opensaml.xml.io.UnmarshallingException
If the WSC resends its request it MUST set the value of the wsa:RelatesTo SOAP Header to the same value of the wsa:MessageID SOAP Header of the SOAP Fault that carried the <RedirectRequest> element.

(From Section 7 [LibertySOAPBinding] document http://www.projectliberty.org/specs )

Throws:
org.opensaml.xml.io.UnmarshallingException
org.opensaml.xml.parse.XMLParserException

prettyPrintRequestMessage

public static java.lang.String prettyPrintRequestMessage(WSFMessage message)
Prints a nice looking output of the request message

Parameters:
message -

prettyPrintResponseMessage

public static java.lang.String prettyPrintResponseMessage(WSFMessage message)
Prints a nice looking output of the response message

Parameters:
message -

buildSOAPEnvelope

public static org.opensaml.ws.soap.soap11.Envelope buildSOAPEnvelope()
                                                              throws org.opensaml.xml.parse.XMLParserException,
                                                                     org.opensaml.xml.io.UnmarshallingException
This method creates the Basic SOAP Envelope

Read in a SOAP Envelope and unmarshall it Currently being built by reading in SOAP template file (is) This may ultimately be built from scratch to improve performance

Parameters:
is -
Returns:
Throws:
org.opensaml.xml.parse.XMLParserException
org.opensaml.xml.io.UnmarshallingException

getRequestEnvelope

public org.opensaml.ws.soap.soap11.Envelope getRequestEnvelope()

setRequestEnvelope

public void setRequestEnvelope(org.opensaml.ws.soap.soap11.Envelope envelope)

getResponseEnvelope

public org.opensaml.ws.soap.soap11.Envelope getResponseEnvelope()

setResponseEnvelope

public void setResponseEnvelope(org.opensaml.ws.soap.soap11.Envelope envelope)

hasRedirectRequestBeenIssued

public boolean hasRedirectRequestBeenIssued()
The RedirectRequest element instructs the WSC to redirect the user to the WSP. It is an indication of the WSP that it cannot service a request made by the WSC before it obtains some more information from the user. If the SOAP response contains a Fault with the <RedirectRequest> element, this will return true.


hasUpdatedEndpointReference

public boolean hasUpdatedEndpointReference()
This boolean indicates that there is an updated endpoint reference that needs to be processed by the service client.

Returns: