Class SecurityHeaderWrapper
- java.lang.Object
-
- com.sun.xml.ws.security.opt.impl.message.SecurityHeaderWrapper
-
- All Implemented Interfaces:
com.sun.xml.ws.api.message.Header
public class SecurityHeaderWrapper extends Object implements com.sun.xml.ws.api.message.Header
- Author:
- K.Venugopal@sun.com
-
-
Constructor Summary
Constructors Constructor Description SecurityHeaderWrapper(SecurityHeader sh)Creates a new instance of HeaderWrapper
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description StringgetAttribute(String nsUri, String localName)Gets the attribute value on the header element.StringgetAttribute(QName name)Gets the attribute value on the header element.StringgetLocalPart()Gets the local name of this header element.StringgetNamespaceURI()Gets the namespace URI of this header element.StringgetRole(com.sun.xml.ws.api.SOAPVersion soapVersion)Gets the value of the soap:role attribute (or soap:actor for SOAP 1.1).StringgetStringContent()booleanisIgnorable(com.sun.xml.ws.api.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.)booleanisRelay()True if this header is to be relayed if not processed.com.sun.xml.ws.api.addressing.WSEndpointReferencereadAsEPR(com.sun.xml.ws.api.addressing.AddressingVersion expected)<T> TreadAsJAXB(com.sun.xml.bind.api.Bridge<T> bridge)Reads the header as a JAXB object by using the given unmarshaller.<T> TreadAsJAXB(com.sun.xml.bind.api.Bridge<T> bridge, com.sun.xml.bind.api.BridgeContext context)Deprecated.UsereadAsJAXB(Bridge).<T> TreadAsJAXB(com.sun.xml.ws.spi.db.XMLBridge<T> arg0)<T> TreadAsJAXB(javax.xml.bind.Unmarshaller unmarshaller)Reads the header as a JAXB object by using the given unmarshaller.XMLStreamReaderreadHeader()Reads the header as aXMLStreamReader.voidwriteTo(javax.xml.soap.SOAPMessage saaj)Writes out the header to the given SOAPMessage.voidwriteTo(XMLStreamWriter w)Writes out the header.voidwriteTo(ContentHandler contentHandler, ErrorHandler errorHandler)Writes out the header as SAX events.
-
-
-
Constructor Detail
-
SecurityHeaderWrapper
public SecurityHeaderWrapper(SecurityHeader sh)
Creates a new instance of HeaderWrapper
-
-
Method Detail
-
isIgnorable
public boolean isIgnorable(com.sun.xml.ws.api.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.)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 thoseHeaders, to verify that we don't need to report an error for it.specifically, this method has to perform the following tasks:
- If this header does not have
mustUnderstandas "1" nor "true", then this method must return true. - Otherwise, check the role attribute (for SOAP 1.2) or the actor attribute (for SOAP 1.1).
When those attributes are absent, the default values have to be assumed.
See
getRole(SOAPVersion)for how the values are defaulted. Now, see if therolesset contains the value. If so, this method must return false (indicating that an error is in order.) - Otherwise return true (since we don't play the role this header is intended for.)
- Specified by:
isIgnorablein interfacecom.sun.xml.ws.api.message.Header- Parameters:
soapVersion- The caller specifies the SOAP version that the pipeline is working against. Often eachHeaderimplementation already knows the SOAP version anyway, but this allows someHeaders 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.
- If this header does not have
-
getRole
public String getRole(com.sun.xml.ws.api.SOAPVersion soapVersion)
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:
getRolein interfacecom.sun.xml.ws.api.message.Header- Parameters:
soapVersion- The caller specifies the SOAP version that the pipeline is working against. Often eachHeaderimplementation already knows the SOAP version anyway, but this allows someHeaders 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()
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:
isRelayin interfacecom.sun.xml.ws.api.message.Header- Returns:
- false.
-
getNamespaceURI
public String getNamespaceURI()
Gets the namespace URI of this header element.- Specified by:
getNamespaceURIin interfacecom.sun.xml.ws.api.message.Header- Returns:
- this string must be interned.
-
getLocalPart
public String getLocalPart()
Gets the local name of this header element.- Specified by:
getLocalPartin interfacecom.sun.xml.ws.api.message.Header- Returns:
- this string must be interned.
-
getAttribute
public String getAttribute(String nsUri, String localName)
Gets the attribute value on the header element.- Specified by:
getAttributein interfacecom.sun.xml.ws.api.message.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
Headerimplementation doesn't have to do anything.
-
getAttribute
public String getAttribute(QName name)
Gets the attribute value on the header element.This is a convenience method that calls into
getAttribute(String, String)- Specified by:
getAttributein interfacecom.sun.xml.ws.api.message.Header- Parameters:
name- Never null.- See Also:
getAttribute(String, String)
-
readHeader
public XMLStreamReader readHeader() throws XMLStreamException
Reads the header as aXMLStreamReader.The returned parser points at the start element of this header. (IOW,
XMLStreamReader.getEventType()would returnXMLStreamConstants.START_ELEMENT.Performance Expectation
For some
Headerimplementations, this operation is a non-trivial operation. Therefore, use of this method is discouraged unless the caller is interested in reading the whole header.Similarly, if the caller wants to use this method only to do the API conversion (such as simply firing SAX events from
XMLStreamReader), then the JAX-WS team requests that you talk to us.Messages that come from tranport usually provides a reasonably efficient implementation of this method.
- Specified by:
readHeaderin interfacecom.sun.xml.ws.api.message.Header- Returns:
- must not null.
- Throws:
XMLStreamException
-
readAsJAXB
public <T> T readAsJAXB(javax.xml.bind.Unmarshaller unmarshaller) throws javax.xml.bind.JAXBExceptionReads the header as a JAXB object by using the given unmarshaller.- Specified by:
readAsJAXBin interfacecom.sun.xml.ws.api.message.Header- Throws:
javax.xml.bind.JAXBException
-
readAsJAXB
public <T> T readAsJAXB(com.sun.xml.bind.api.Bridge<T> bridge, com.sun.xml.bind.api.BridgeContext context) throws javax.xml.bind.JAXBExceptionDeprecated.UsereadAsJAXB(Bridge). To be removed after JavaOne.- Throws:
javax.xml.bind.JAXBException
-
readAsJAXB
public <T> T readAsJAXB(com.sun.xml.bind.api.Bridge<T> bridge) throws javax.xml.bind.JAXBExceptionReads the header as a JAXB object by using the given unmarshaller.- Specified by:
readAsJAXBin interfacecom.sun.xml.ws.api.message.Header- Throws:
javax.xml.bind.JAXBException
-
writeTo
public void writeTo(XMLStreamWriter w) throws XMLStreamException
Writes out the header.- Specified by:
writeToin interfacecom.sun.xml.ws.api.message.Header- Throws:
XMLStreamException- if the operation fails for some reason. This leaves the writer to an undefined state.
-
writeTo
public void writeTo(javax.xml.soap.SOAPMessage saaj) throws javax.xml.soap.SOAPExceptionWrites 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:
writeToin interfacecom.sun.xml.ws.api.message.Header- Throws:
javax.xml.soap.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
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
startPrefixMappingandendPrefixMapping, 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 toErrorHandler. If the SAX event production cannot be continued and the processing needs to abort, the code may then throw the same SAXParseException reported toErrorHandler.- Specified by:
writeToin interfacecom.sun.xml.ws.api.message.Header- Parameters:
contentHandler- TheContentHandlerthat receives SAX events.errorHandler- TheErrorHandlerthat receives parsing errors.- Throws:
SAXException
-
getStringContent
public String getStringContent()
- Specified by:
getStringContentin interfacecom.sun.xml.ws.api.message.Header
-
readAsEPR
@NotNull public com.sun.xml.ws.api.addressing.WSEndpointReference readAsEPR(com.sun.xml.ws.api.addressing.AddressingVersion expected) throws XMLStreamException- Specified by:
readAsEPRin interfacecom.sun.xml.ws.api.message.Header- Throws:
XMLStreamException
-
readAsJAXB
public <T> T readAsJAXB(com.sun.xml.ws.spi.db.XMLBridge<T> arg0) throws javax.xml.bind.JAXBException- Specified by:
readAsJAXBin interfacecom.sun.xml.ws.api.message.Header- Throws:
javax.xml.bind.JAXBException
-
-