Package org.apache.cxf.ws.security.wss4j
Class CryptoCoverageUtil
- java.lang.Object
-
- org.apache.cxf.ws.security.wss4j.CryptoCoverageUtil
-
public final class CryptoCoverageUtil extends Object
Utility to enable the checking of WS-Security signature / WS-Security encryption coverage based on the results of the WSS4J signature/encryption processor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCryptoCoverageUtil.CoverageScopeDifferentiates which part of an element to check for cryptographic coverage.static classCryptoCoverageUtil.CoverageTypeDifferentiates which type of cryptographic coverage to check for.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcheckAttachmentsCoverage(Collection<org.apache.cxf.message.Attachment> attachments, Collection<org.apache.wss4j.dom.WSDataRef> refs, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope)static voidcheckBodyCoverage(Element soapBody, Collection<org.apache.wss4j.dom.WSDataRef> refs, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope)Checks that the references provided refer to the signed/encrypted SOAP body element.static voidcheckCoverage(Element soapEnvelope, Collection<org.apache.wss4j.dom.WSDataRef> refs, Map<String,String> namespaces, String xPath, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope)Checks that the references provided refer to the required signed/encrypted elements as defined by the XPath expression inxPath.static voidcheckCoverage(Element soapEnvelope, Collection<org.apache.wss4j.dom.WSDataRef> refs, Map<String,String> namespaces, Collection<String> xPaths, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope)Checks that the references provided refer to the required signed/encrypted elements as defined by the XPath expressions inxPaths.static voidcheckCoverage(Element soapEnvelope, Collection<org.apache.wss4j.dom.WSDataRef> refs, XPath xpath, Collection<String> xPaths, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope)Checks that the references provided refer to the required signed/encrypted elements as defined by the XPath expressions inxPaths.static voidcheckHeaderCoverage(Element soapHeader, Collection<org.apache.wss4j.dom.WSDataRef> refs, String namespace, String name, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope)Checks that the references provided refer to the required signed/encrypted SOAP header element(s) matching the provided name and namespace.static voidreconcileEncryptedSignedRefs(Collection<org.apache.wss4j.dom.WSDataRef> signedRefs, Collection<org.apache.wss4j.dom.WSDataRef> encryptedRefs)Inspects the signed and encrypted content in the message and accurately resolves encrypted and then signed elements insignedRefs.
-
-
-
Method Detail
-
reconcileEncryptedSignedRefs
public static void reconcileEncryptedSignedRefs(Collection<org.apache.wss4j.dom.WSDataRef> signedRefs, Collection<org.apache.wss4j.dom.WSDataRef> encryptedRefs)
Inspects the signed and encrypted content in the message and accurately resolves encrypted and then signed elements insignedRefs. Entries insignedRefsthat correspond to an encrypted element are resolved to the decrypted element and added tosignedRefs. The original reference to the encrypted content remains unaltered in the list to allow for matching against a requirement that xenc:EncryptedData and xenc:EncryptedKey elements be signed.- Parameters:
signedRefs- references to the signed content in the messageencryptedRefs- references to the encrypted content in the message
-
checkBodyCoverage
public static void checkBodyCoverage(Element soapBody, Collection<org.apache.wss4j.dom.WSDataRef> refs, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope) throws org.apache.wss4j.common.ext.WSSecurityException
Checks that the references provided refer to the signed/encrypted SOAP body element.- Parameters:
soapBody- the SOAP body elementrefs- the refs to the data extracted from the signature/encryptiontype- the type of cryptographic coverage to check forscope- the scope of the cryptographic coverage to check for, defaults to element- Throws:
org.apache.wss4j.common.ext.WSSecurityException- if there is an error evaluating the coverage or the body is not covered by the signature/encryption.
-
checkAttachmentsCoverage
public static void checkAttachmentsCoverage(Collection<org.apache.cxf.message.Attachment> attachments, Collection<org.apache.wss4j.dom.WSDataRef> refs, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope) throws org.apache.wss4j.common.ext.WSSecurityException
- Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
checkHeaderCoverage
public static void checkHeaderCoverage(Element soapHeader, Collection<org.apache.wss4j.dom.WSDataRef> refs, String namespace, String name, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope) throws org.apache.wss4j.common.ext.WSSecurityException
Checks that the references provided refer to the required signed/encrypted SOAP header element(s) matching the provided name and namespace. Ifnameis null, all headers fromnamespaceare inspected for coverage.- Parameters:
soapHeader- the SOAP header elementrefs- the refs to the data extracted from the signature/encryptionnamespace- the namespace of the header(s) to check for coveragename- the local part of the header name to check for coverage, may be nulltype- the type of cryptographic coverage to check forscope- the scope of the cryptographic coverage to check for, defaults to element- Throws:
org.apache.wss4j.common.ext.WSSecurityException- if there is an error evaluating the coverage or a header is not covered by the signature/encryption.
-
checkCoverage
public static void checkCoverage(Element soapEnvelope, Collection<org.apache.wss4j.dom.WSDataRef> refs, Map<String,String> namespaces, String xPath, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope) throws org.apache.wss4j.common.ext.WSSecurityException
Checks that the references provided refer to the required signed/encrypted elements as defined by the XPath expression inxPath.- Parameters:
soapEnvelope- the SOAP Envelope elementrefs- the refs to the data extracted from the signature/encryptionnamespaces- the prefix to namespace mapping, may benullxPath- the XPath expressiontype- the type of cryptographic coverage to check forscope- the scope of the cryptographic coverage to check for, defaults to element- Throws:
org.apache.wss4j.common.ext.WSSecurityException- if there is an error evaluating an XPath or an element is not covered by the signature/encryption.
-
checkCoverage
public static void checkCoverage(Element soapEnvelope, Collection<org.apache.wss4j.dom.WSDataRef> refs, Map<String,String> namespaces, Collection<String> xPaths, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope) throws org.apache.wss4j.common.ext.WSSecurityException
Checks that the references provided refer to the required signed/encrypted elements as defined by the XPath expressions inxPaths.- Parameters:
soapEnvelope- the SOAP Envelope elementrefs- the refs to the data extracted from the signature/encryptionnamespaces- the prefix to namespace mapping, may benullxPaths- the collection of XPath expressionstype- the type of cryptographic coverage to check forscope- the scope of the cryptographic coverage to check for, defaults to element- Throws:
org.apache.wss4j.common.ext.WSSecurityException- if there is an error evaluating an XPath or an element is not covered by the signature/encryption.
-
checkCoverage
public static void checkCoverage(Element soapEnvelope, Collection<org.apache.wss4j.dom.WSDataRef> refs, XPath xpath, Collection<String> xPaths, CryptoCoverageUtil.CoverageType type, CryptoCoverageUtil.CoverageScope scope) throws org.apache.wss4j.common.ext.WSSecurityException
Checks that the references provided refer to the required signed/encrypted elements as defined by the XPath expressions inxPaths.- Throws:
org.apache.wss4j.common.ext.WSSecurityException
-
-