org.jboss.soa.esb.services.security.auth.ws
Class SOAPSecurityHeaderVisitor

java.lang.Object
  extended by org.jboss.soa.esb.services.security.auth.ws.SOAPSecurityHeaderVisitor
All Implemented Interfaces:
org.milyn.delivery.ContentHandler, org.milyn.delivery.sax.SAXElementVisitor, org.milyn.delivery.sax.SAXVisitAfter, org.milyn.delivery.sax.SAXVisitBefore, org.milyn.delivery.sax.SAXVisitChildren, org.milyn.delivery.sax.SAXVisitor, org.milyn.delivery.Visitor
Direct Known Subclasses:
SamlVisitor

public abstract class SOAPSecurityHeaderVisitor
extends java.lang.Object
implements org.milyn.delivery.sax.SAXElementVisitor

SOAPSecurityHeaderVisitor is a Smooks Visitor that will add a SOAP Security Header to a SOAP Envelope. The Security Header can be any xml header returned by the abstract method getHeaderToInsert().

Author:
Daniel Bevenius

Constructor Summary
SOAPSecurityHeaderVisitor()
           
 
Method Summary
protected abstract  java.lang.String getHeaderToInsert()
          Should be implemented by subclasses and return the security header to be inserted into the SOAP Security Header.
 void initialize()
           
 void onChildElement(org.milyn.delivery.sax.SAXElement element, org.milyn.delivery.sax.SAXElement childElement, org.milyn.container.ExecutionContext executionContext)
          No Operation implemented.
 void onChildText(org.milyn.delivery.sax.SAXElement element, org.milyn.delivery.sax.SAXText text, org.milyn.container.ExecutionContext executionContext)
          Will write the SAXTex.
 SOAPSecurityHeaderVisitor setAddSecurityXmlNSAttribute(boolean add)
          Determines if an xmlns attribute should be added to a created Security Header element.
 SOAPSecurityHeaderVisitor setHeaderElementName(java.lang.String name)
          The name of the SOAP Header element.
 SOAPSecurityHeaderVisitor setHeaderNS(java.lang.String ns)
          The namespace(ns) of the SOAP Envelope.
 SOAPSecurityHeaderVisitor setSecurityElementName(java.lang.String securityElementName)
          This is the name of the Security element header.
 SOAPSecurityHeaderVisitor setSecurityNS(java.lang.String securityNS)
          The namespace(ns) of the SOAP Secuirty Headerl.
 SOAPSecurityHeaderVisitor setSecurityPrefix(java.lang.String prefix)
          This is the Security Header prefix which will be used when creating a new Security header.
 void visitAfter(org.milyn.delivery.sax.SAXElement element, org.milyn.container.ExecutionContext executionContext)
          Will create a new Security header element if one does not exist and add the header, the String returned from getHeaderToInsert(), into the newly created Security header.
 void visitBefore(org.milyn.delivery.sax.SAXElement element, org.milyn.container.ExecutionContext executionContext)
          Will simply write the start of the element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SOAPSecurityHeaderVisitor

public SOAPSecurityHeaderVisitor()
Method Detail

getHeaderToInsert

protected abstract java.lang.String getHeaderToInsert()
Should be implemented by subclasses and return the security header to be inserted into the SOAP Security Header.

Returns:
String The header to be inserted into the SOAP Security Header.

initialize

@Initialize
public void initialize()

visitBefore

public void visitBefore(org.milyn.delivery.sax.SAXElement element,
                        org.milyn.container.ExecutionContext executionContext)
                 throws org.milyn.SmooksException,
                        java.io.IOException
Will simply write the start of the element.

Specified by:
visitBefore in interface org.milyn.delivery.sax.SAXVisitBefore
Parameters:
element - The current SAXElement.
executionContext - Smooks ExecutionContext.
Throws:
org.milyn.SmooksException
java.io.IOException

onChildText

public void onChildText(org.milyn.delivery.sax.SAXElement element,
                        org.milyn.delivery.sax.SAXText text,
                        org.milyn.container.ExecutionContext executionContext)
                 throws org.milyn.SmooksException,
                        java.io.IOException
Will write the SAXTex.

Specified by:
onChildText in interface org.milyn.delivery.sax.SAXVisitChildren
Parameters:
element - The current SAXElement.
text - The SAXText to write.
executionContext - Smooks ExecutionContext.
Throws:
org.milyn.SmooksException
java.io.IOException

visitAfter

public void visitAfter(org.milyn.delivery.sax.SAXElement element,
                       org.milyn.container.ExecutionContext executionContext)
                throws org.milyn.SmooksException,
                       java.io.IOException
Will create a new Security header element if one does not exist and add the header, the String returned from getHeaderToInsert(), into the newly created Security header. If a Security header does exist the header, the String returned from getHeaderToInsert(), will be inserted into the existing header.

Specified by:
visitAfter in interface org.milyn.delivery.sax.SAXVisitAfter
Parameters:
element - The current SAXElement.
text - The SAXText to write.
executionContext - Smooks ExecutionContext.
Throws:
org.milyn.SmooksException
java.io.IOException

onChildElement

public void onChildElement(org.milyn.delivery.sax.SAXElement element,
                           org.milyn.delivery.sax.SAXElement childElement,
                           org.milyn.container.ExecutionContext executionContext)
                    throws org.milyn.SmooksException,
                           java.io.IOException
No Operation implemented.

Specified by:
onChildElement in interface org.milyn.delivery.sax.SAXVisitChildren
Throws:
org.milyn.SmooksException
java.io.IOException

setSecurityElementName

@ConfigParam(defaultVal="Security")
public SOAPSecurityHeaderVisitor setSecurityElementName(java.lang.String securityElementName)
This is the name of the Security element header. This will be used for matching a pre-existing Security header element in a SOAP Envelope and also used when creating a new Security header (that is if one does not exist). For example: Envelope/Header/Security

Parameters:
securityElementName - The name of the Security header element
Returns:
SOAPSecurityHeaderVisitor To support method chaining.

setHeaderElementName

@ConfigParam(defaultVal="Header")
public SOAPSecurityHeaderVisitor setHeaderElementName(java.lang.String name)
The name of the SOAP Header element.

Parameters:
name - The name of the SOAP Header element.
Returns:
SOAPSecurityHeaderVisitor To support method chaining.

setHeaderNS

@ConfigParam(defaultVal="http://schemas.xmlsoap.org/soap/envelope/")
public SOAPSecurityHeaderVisitor setHeaderNS(java.lang.String ns)
The namespace(ns) of the SOAP Envelope. Used to support different version.

Parameters:
ns - The SOAP Envelope namespace.
Returns:
SOAPSecurityHeaderVisitor To support method chaining.

setSecurityNS

@ConfigParam(defaultVal="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd")
public SOAPSecurityHeaderVisitor setSecurityNS(java.lang.String securityNS)
The namespace(ns) of the SOAP Secuirty Headerl. Used to support different version.

Parameters:
ns - The SOAP SecurityHeader namespace.
Returns:
SOAPSecurityHeaderVisitor To support method chaining.

setSecurityPrefix

@ConfigParam(defaultVal="wsse")
public SOAPSecurityHeaderVisitor setSecurityPrefix(java.lang.String prefix)
This is the Security Header prefix which will be used when creating a new Security header. For example, setting this to sec would generate a Security Header looking like:
 

Parameters:
prefix - The prefix for the Security Header element.
Returns:
SOAPSecurityHeaderVisitor To support method chaining.

setAddSecurityXmlNSAttribute

@ConfigParam(defaultVal="false",
             decoder=org.milyn.javabean.decoders.BooleanDecoder.class)
public SOAPSecurityHeaderVisitor setAddSecurityXmlNSAttribute(boolean add)
Determines if an xmlns attribute should be added to a created Security Header element. This might not be needed or desired if you know that this declaration exist in the higher up in the SOAP Envelope.

Parameters:
add - True will add the xmlns attribute to a created Security Header element. False will not.
Returns:
SOAPSecurityHeaderVisitor To support method chaining.