com.sun.xml.ws.security.opt.impl.incoming
Class GenericSecuredHeader

java.lang.Object
  extended by com.sun.xml.ws.message.AbstractHeaderImpl
      extended by com.sun.xml.ws.security.opt.impl.incoming.GenericSecuredHeader
All Implemented Interfaces:
Header, NamespaceContextInfo, SecuredHeader

public class GenericSecuredHeader
extends AbstractHeaderImpl
implements SecuredHeader, NamespaceContextInfo

Author:
K.Venugopal@sun.com

Nested Class Summary
protected static class GenericSecuredHeader.Attribute
           
 
Field Summary
 
Fields inherited from class com.sun.xml.ws.message.AbstractHeaderImpl
EMPTY_ATTS
 
Constructor Summary
GenericSecuredHeader(XMLStreamReader reader, SOAPVersion soapVersion, StreamReaderBufferCreator creator, HashMap nsDecl, XMLInputFactory staxIF, boolean encHeaderContent)
           
 
Method Summary
 String getAttribute(String nsUri, String localName)
          Gets the attribute value on the header element.
 HashMap<String,String> getInscopeNSContext()
          map of all inscope namespace declarations.
 String getLocalPart()
          Gets the local name of this header element.
 String getNamespaceURI()
          Gets the namespace URI of this header element.
 String getRole(SOAPVersion soapVersion)
          Gets the value of the soap:role attribute (or soap:actor for SOAP 1.1).
 String getStringContent()
          Used to obtain value XYZ from a header that looks like "<header>XYZ</header>".
 boolean hasEncData()
           
 boolean hasID(String id)
           
 boolean isIgnorable(SOAPVersion soapVersion, Set<String> roles)
          Checks if this header is ignorable for us (IOW, make sure that this header has a problematic "mustUnderstand" header value that we have to reject.)
 boolean isRelay()
          True if this header is to be relayed if not processed.
<T> T
readAsJAXB(Bridge<T> bridge)
          Reads the header as a JAXB object by using the given unmarshaller.
<T> T
readAsJAXB(Unmarshaller um)
          Reads the header as a JAXB object by using the given unmarshaller.
 XMLStreamReader readHeader()
          Reads the header as a XMLStreamReader
 void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler)
          Writes out the header as SAX events.
 void writeTo(SOAPMessage saaj)
          Writes out the header to the given SOAPMessage.
 void writeTo(XMLStreamWriter w)
          Writes out the header as a fragment.
 
Methods inherited from class com.sun.xml.ws.message.AbstractHeaderImpl
getAttribute, parseBool, readAsEPR, readAsJAXB, readAsJAXB
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericSecuredHeader

public GenericSecuredHeader(XMLStreamReader reader,
                            SOAPVersion soapVersion,
                            StreamReaderBufferCreator creator,
                            HashMap nsDecl,
                            XMLInputFactory staxIF,
                            boolean encHeaderContent)
                     throws XMLStreamBufferException,
                            XMLStreamException
Throws:
XMLStreamBufferException
XMLStreamException
Method Detail

hasEncData

public boolean hasEncData()

hasID

public boolean hasID(String id)
Specified by:
hasID in interface SecuredHeader
Parameters:
id - true if the SecuredHeader refers to id.
Returns:

isIgnorable

public final boolean isIgnorable(SOAPVersion soapVersion,
                                 Set<String> roles)
Description copied from interface: Header
Checks if this header is ignorable for us (IOW, make sure that this header has a problematic "mustUnderstand" header value that we have to reject.)

This method is used as a part of the mustUnderstanx processing. At the end of the processing, the JAX-WS identifies a list of Headers that were not understood. This method is invoked on those Headers, to verify that we don't need to report an error for it.

specifically, this method has to perform the following tasks:

Specified by:
isIgnorable in interface Header
Overrides:
isIgnorable in class AbstractHeaderImpl
Parameters:
soapVersion - The caller specifies the SOAP version that the pipeline is working against. Often each Header implementation already knows the SOAP version anyway, but this allows some Headers to avoid keeping it. That's why this redundant parameter is passed in.
roles - The set of role values that the current JAX-WS pipeline is assuming. Note that SOAP 1.1 and SOAP 1.2 use different strings for the same role, and the caller is responsible for supplying a proper value depending on the active SOAP version in use.
Returns:
true if no error needs to be reported. False if an error needs to be raised. See the method javadoc for more discussion.

getRole

public String getRole(SOAPVersion soapVersion)
Description copied from interface: Header
Gets the value of the soap:role attribute (or soap:actor for SOAP 1.1).

If the attribute is omitted, the value defaults to SOAPVersion.implicitRole.

Specified by:
getRole in interface Header
Overrides:
getRole in class AbstractHeaderImpl
Parameters:
soapVersion - The caller specifies the SOAP version that the pipeline is working against. Often each Header implementation already knows the SOAP version anyway, but this allows some Headers to avoid keeping it. That's why this redundant parameter is passed in.
Returns:
never null. This string need not be interned.

isRelay

public boolean isRelay()
Description copied from interface: Header
True if this header is to be relayed if not processed. For SOAP 1.1 messages, this method always return false.

IOW, this method returns true if there's @soap:relay='true' is present.

Implementation Note

The implementation needs to check for both "true" and "1", but because attribute values are normalized, it doesn't have to consider " true", " 1 ", and so on.

Specified by:
isRelay in interface Header
Overrides:
isRelay in class AbstractHeaderImpl
Returns:
false.

getNamespaceURI

public String getNamespaceURI()
Description copied from interface: Header
Gets the namespace URI of this header element.

Specified by:
getNamespaceURI in interface Header
Returns:
this string must be interned.

getLocalPart

public String getLocalPart()
Description copied from interface: Header
Gets the local name of this header element.

Specified by:
getLocalPart in interface Header
Returns:
this string must be interned.

getAttribute

public String getAttribute(String nsUri,
                           String localName)
Description copied from interface: Header
Gets the attribute value on the header element.

Specified by:
getAttribute in interface Header
Parameters:
nsUri - The namespace URI of the attribute. Can be empty.
localName - The local name of the attribute.
Returns:
if the attribute is found, return the whitespace normalized value. (meaning no leading/trailing space, no consequtive whitespaces in-between.) Otherwise null. Note that the XML parsers are responsible for whitespace-normalizing attributes, so Header implementation doesn't have to do anything.

readHeader

public XMLStreamReader readHeader()
                           throws XMLStreamException
Reads the header as a XMLStreamReader

Specified by:
readHeader in interface Header
Returns:
must not null.
Throws:
XMLStreamException

writeTo

public void writeTo(XMLStreamWriter w)
             throws XMLStreamException
Description copied from interface: Header
Writes out the header as a fragment.

Specified by:
writeTo in interface Header
Throws:
XMLStreamException - if the operation fails for some reason. This leaves the writer to an undefined state.

writeTo

public void writeTo(SOAPMessage saaj)
             throws SOAPException
Description copied from interface: Header
Writes out the header to the given SOAPMessage.

Sometimes a Message needs to produce itself as SOAPMessage, in which case each header needs to turn itself into a header.

Specified by:
writeTo in interface Header
Throws:
SOAPException - if the operation fails for some reason. This leaves the writer to an undefined state.

writeTo

public void writeTo(ContentHandler contentHandler,
                    ErrorHandler errorHandler)
             throws SAXException
Description copied from interface: Header
Writes out the header as SAX events.

Sometimes a Message needs to produce SAX events, and this method is necessary for headers to participate to it.

A header is responsible for producing the SAX events for its part, including startPrefixMapping and endPrefixMapping, but not startDocument/endDocument.

Note that SAX contract requires that any error that does NOT originate from ContentHandler (meaning any parsing error and etc) must be first reported to ErrorHandler. If the SAX event production cannot be continued and the processing needs to abort, the code may then throw the same SAXParseException reported to ErrorHandler.

Specified by:
writeTo in interface Header
Parameters:
contentHandler - The ContentHandler that receives SAX events.
errorHandler - The ErrorHandler that receives parsing errors.
Throws:
SAXException

getStringContent

public String getStringContent()
Description copied from interface: Header
Used to obtain value XYZ from a header that looks like "<header>XYZ</header>". The primary use of this header for now is to access certain Addressing headers quickly.

Specified by:
getStringContent in interface Header
Overrides:
getStringContent in class AbstractHeaderImpl
Returns:
Can be empty but always non-null.

readAsJAXB

public <T> T readAsJAXB(Unmarshaller um)
             throws JAXBException
Description copied from interface: Header
Reads the header as a JAXB object by using the given unmarshaller.

Specified by:
readAsJAXB in interface Header
Overrides:
readAsJAXB in class AbstractHeaderImpl
Throws:
JAXBException

readAsJAXB

public <T> T readAsJAXB(Bridge<T> bridge)
             throws JAXBException
Description copied from interface: Header
Reads the header as a JAXB object by using the given unmarshaller.

Specified by:
readAsJAXB in interface Header
Overrides:
readAsJAXB in class AbstractHeaderImpl
Throws:
JAXBException

getInscopeNSContext

public HashMap<String,String> getInscopeNSContext()
Description copied from interface: NamespaceContextInfo
map of all inscope namespace declarations.

Specified by:
getInscopeNSContext in interface NamespaceContextInfo
Returns:
HashMap of all inscope namespaces.


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.