Class AbstractBindingBuilder
- java.lang.Object
-
- org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractCommonBindingHandler
-
- org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder
-
- Direct Known Subclasses:
AsymmetricBindingHandler,SymmetricBindingHandler,TransportBindingHandler
public abstract class AbstractBindingBuilder extends AbstractCommonBindingHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.cxf.ws.policy.AssertionInfoMapaimprotected AbstractBindingbindingprotected ElementbottomUpElementprotected ElementbstElementprotected CallbackLookupcallbackLookupstatic StringCRYPTO_CACHEprotected Set<WSEncryptionPart>encryptedTokensListprotected ElementlastEncryptedKeyElementprotected static LoggerLOGprotected StringmainSigIdprotected AbstractSymmetricAsymmetricBinding.ProtectionOrderprotectionOrderprotected SOAPMessagesaajprotected WSSecHeadersecHeaderprotected List<WSEncryptionPart>sigConfListprotected Set<Integer>signaturesprotected booleanstoreBytesInAttachmentprotected WSSecTimestamptimestampElprotected ElementtopDownElementprotected WSDocInfowsDocInfoprotected WSSConfigwssConfig-
Fields inherited from class org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractCommonBindingHandler
message
-
-
Constructor Summary
Constructors Constructor Description AbstractBindingBuilder(WSSConfig config, AbstractBinding binding, SOAPMessage saaj, WSSecHeader secHeader, org.apache.cxf.ws.policy.AssertionInfoMap aim, org.apache.cxf.binding.soap.SoapMessage message)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddDerivedKeyElement(Element el)protected WSSecUsernameTokenaddDKUsernameToken(UsernameToken token, byte[] salt)protected voidaddEncryptedKeyElement(Element el)protected SamlAssertionWrapperaddSamlToken(SamlToken token)protected voidaddSig(byte[] val)protected voidaddSignatureConfirmation(List<WSEncryptionPart> sigParts)protected voidaddSignatureParts(List<org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.SupportingToken> tokenList, List<WSEncryptionPart> sigParts)protected voidaddSupportingElement(Element el)protected voidaddSupportingTokens(List<WSEncryptionPart> sigs)protected voidaddTopDownElement(Element el)protected WSSecUsernameTokenaddUsernameToken(UsernameToken token)StringaddWsuIdToElement(Element element)Generates a wsu:Id attribute for the providedElementand returns the attribute value or finds and returns the value of the attribute if it already exists.protected ElementcloneElement(Element el)WSEncryptionPartconvertToEncryptionPart(Element element)Convert a DOM Element into a WSEncryptionPart, adding a (wsu:)Id if there is not one already.protected WSSecTimestampcreateTimestamp()protected voiddoEndorse()protected voiddoEndorsedSignatures(List<org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.SupportingToken> tokenList, boolean isTokenProtection, boolean isSigProtect)protected StringfindIDFromSamlToken(Element samlToken)protected CryptogetCrypto(String cryptoKey, String propKey)protected Map<Object,Crypto>getCryptoCache()protected List<WSEncryptionPart>getElements(String encryptionModifier, List<XPath> xpaths, List<Element> found, boolean forceId)Identifies the portions of the message to be signed/encrypted.protected WSSecEncryptedKeygetEncryptedKeyBuilder(AbstractToken token, SecretKey symmetricKey)protected WSSecurityEngineResultgetEncryptedKeyResult()List<WSEncryptionPart>getEncryptedParts()CryptogetEncryptionCrypto()protected List<WSEncryptionPart>getParts(boolean sign, boolean includeBody, List<WSEncryptionPart> parts, List<Element> found)Identifies the portions of the message to be signed/encrypted.List<WSEncryptionPart>getPartsAndElements(boolean sign, boolean includeBody, List<WSEncryptionPart> parts, List<XPath> xpaths, List<XPath> contentXpaths)Identifies the portions of the message to be signed/encrypted.protected StringgetPassword(String userName, org.apache.neethi.Assertion info, int usage)protected WSSecSignaturegetSignatureBuilder(AbstractToken token, boolean attached, boolean endorse)CryptogetSignatureCrypto()List<WSEncryptionPart>getSignedParts(SupportingTokens supportingToken)protected TokenStoregetTokenStore()static StringgetUsername(List<WSHandlerResult> results)Scan throughWSHandlerResultlist for a Username token and return the username if a Username Token foundvoidhandleEncryptedSignedHeaders(List<WSEncryptionPart> encryptedParts, List<WSEncryptionPart> signedParts)Processes the parts to be signed and reconfigures those parts that have already been encrypted.protected WSSecTimestamphandleLayout(WSSecTimestamp timestamp)protected List<org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.SupportingToken>handleSupportingTokens(SupportingTokens suppTokens, boolean endorse, List<org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.SupportingToken> ret)protected voidhandleUsernameTokenSupportingToken(UsernameToken token, boolean endorse, boolean encryptedToken, List<org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.SupportingToken> ret)protected voidinsertAfter(Element child, Element sib)protected voidinsertBeforeBottomUp(Element el)booleanisExpandXopInclude()protected voidreshuffleTimestamp()StringsetEncryptionUser(WSSecEncryptedKey encrKeyBuilder, AbstractToken token, boolean sign, Crypto crypto)voidsetKeyIdentifierType(WSSecBase secBase, AbstractToken token)protected voidstoreAssertionAsSecurityToken(SamlAssertionWrapper assertion)Store a SAML Assertion as a SecurityToken-
Methods inherited from class org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractCommonBindingHandler
assertAlgorithmSuite, assertPolicy, assertPolicy, assertToken, assertTokenWrapper, assertTrustProperties, assertWSSProperties, getAllAssertionsByLocalname, getMessage, getSecurityToken, getWss10, isRequestor, isTokenRequired, unassertPolicy, unassertPolicy
-
-
-
-
Field Detail
-
CRYPTO_CACHE
public static final String CRYPTO_CACHE
- See Also:
- Constant Field Values
-
LOG
protected static final Logger LOG
-
protectionOrder
protected AbstractSymmetricAsymmetricBinding.ProtectionOrder protectionOrder
-
wssConfig
protected final WSSConfig wssConfig
-
saaj
protected SOAPMessage saaj
-
secHeader
protected WSSecHeader secHeader
-
aim
protected org.apache.cxf.ws.policy.AssertionInfoMap aim
-
binding
protected AbstractBinding binding
-
timestampEl
protected WSSecTimestamp timestampEl
-
mainSigId
protected String mainSigId
-
sigConfList
protected List<WSEncryptionPart> sigConfList
-
encryptedTokensList
protected Set<WSEncryptionPart> encryptedTokensList
-
bottomUpElement
protected Element bottomUpElement
-
topDownElement
protected Element topDownElement
-
bstElement
protected Element bstElement
-
lastEncryptedKeyElement
protected Element lastEncryptedKeyElement
-
callbackLookup
protected final CallbackLookup callbackLookup
-
storeBytesInAttachment
protected boolean storeBytesInAttachment
-
wsDocInfo
protected WSDocInfo wsDocInfo
-
-
Constructor Detail
-
AbstractBindingBuilder
public AbstractBindingBuilder(WSSConfig config, AbstractBinding binding, SOAPMessage saaj, WSSecHeader secHeader, org.apache.cxf.ws.policy.AssertionInfoMap aim, org.apache.cxf.binding.soap.SoapMessage message) throws SOAPException
- Throws:
SOAPException
-
-
Method Detail
-
addDerivedKeyElement
protected void addDerivedKeyElement(Element el)
-
addEncryptedKeyElement
protected void addEncryptedKeyElement(Element el)
-
addSupportingElement
protected void addSupportingElement(Element el)
-
insertBeforeBottomUp
protected void insertBeforeBottomUp(Element el)
-
addTopDownElement
protected void addTopDownElement(Element el)
-
getTokenStore
protected final TokenStore getTokenStore() throws TokenStoreException
- Throws:
TokenStoreException
-
createTimestamp
protected WSSecTimestamp createTimestamp()
-
handleLayout
protected WSSecTimestamp handleLayout(WSSecTimestamp timestamp)
-
reshuffleTimestamp
protected void reshuffleTimestamp()
-
handleSupportingTokens
protected List<org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.SupportingToken> handleSupportingTokens(SupportingTokens suppTokens, boolean endorse, List<org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.SupportingToken> ret) throws WSSecurityException, SOAPException, TokenStoreException
-
handleUsernameTokenSupportingToken
protected void handleUsernameTokenSupportingToken(UsernameToken token, boolean endorse, boolean encryptedToken, List<org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.SupportingToken> ret) throws WSSecurityException
- Throws:
WSSecurityException
-
addSignatureParts
protected void addSignatureParts(List<org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.SupportingToken> tokenList, List<WSEncryptionPart> sigParts)
-
addUsernameToken
protected WSSecUsernameToken addUsernameToken(UsernameToken token)
-
addDKUsernameToken
protected WSSecUsernameToken addDKUsernameToken(UsernameToken token, byte[] salt)
-
addSamlToken
protected SamlAssertionWrapper addSamlToken(SamlToken token) throws WSSecurityException, TokenStoreException
-
storeAssertionAsSecurityToken
protected void storeAssertionAsSecurityToken(SamlAssertionWrapper assertion) throws TokenStoreException
Store a SAML Assertion as a SecurityToken- Throws:
TokenStoreException
-
getPassword
protected String getPassword(String userName, org.apache.neethi.Assertion info, int usage)
-
addWsuIdToElement
public String addWsuIdToElement(Element element)
Generates a wsu:Id attribute for the providedElementand returns the attribute value or finds and returns the value of the attribute if it already exists.- Parameters:
element- theElementto check/create the attribute on- Returns:
- the generated or discovered wsu:Id attribute value
-
getEncryptedParts
public List<WSEncryptionPart> getEncryptedParts() throws SOAPException
- Throws:
SOAPException
-
getSignedParts
public List<WSEncryptionPart> getSignedParts(SupportingTokens supportingToken) throws SOAPException
- Throws:
SOAPException
-
getPartsAndElements
public List<WSEncryptionPart> getPartsAndElements(boolean sign, boolean includeBody, List<WSEncryptionPart> parts, List<XPath> xpaths, List<XPath> contentXpaths) throws SOAPException
Identifies the portions of the message to be signed/encrypted.- Parameters:
sign- whether the matches are to be signed or encryptedincludeBody- if the body should be included in the signature/encryptionparts- anyWSEncryptionParts to match for signature or encryption as specified by WS-SP signed parts or encrypted parts. Parts without a name match all elements with the provided namespace.xpaths- any XPath expressions to sign/encrypt matchescontentXpaths- any XPath expressions to content encrypt- Returns:
- a configured list of
WSEncryptionParts suitable for processing by WSS4J - Throws:
SOAPException- if there is an error extracting SOAP content from the SAAJ model
-
getParts
protected List<WSEncryptionPart> getParts(boolean sign, boolean includeBody, List<WSEncryptionPart> parts, List<Element> found) throws SOAPException
Identifies the portions of the message to be signed/encrypted.- Parameters:
sign- whether the matches are to be signed or encryptedincludeBody- if the body should be included in the signature/encryptionparts- anyWSEncryptionParts to match for signature or encryption as specified by WS-SP signed parts or encrypted parts. Parts without a name match all elements with the provided namespace.found- a list of elements that have previously been tagged for signing/encryption. Populated with additional matches found by this method and used to prevent including the same element twice under the same operation.- Returns:
- a configured list of
WSEncryptionParts suitable for processing by WSS4J - Throws:
SOAPException- if there is an error extracting SOAP content from the SAAJ model
-
getElements
protected List<WSEncryptionPart> getElements(String encryptionModifier, List<XPath> xpaths, List<Element> found, boolean forceId) throws SOAPException
Identifies the portions of the message to be signed/encrypted.- Parameters:
encryptionModifier- indicates the scope of the crypto operation over matched elements. Either "Content" or "Element".xpaths- any XPath expressions to sign/encrypt matchesfound- a list of elements that have previously been tagged for signing/encryption. Populated with additional matches found by this method and used to prevent including the same element twice under the same operation.forceId- force adding a wsu:Id onto the elements. Recommended for signatures.- Returns:
- a configured list of
WSEncryptionParts suitable for processing by WSS4J - Throws:
SOAPException- if there is an error extracting SOAP content from the SAAJ model
-
getEncryptedKeyBuilder
protected WSSecEncryptedKey getEncryptedKeyBuilder(AbstractToken token, SecretKey symmetricKey) throws WSSecurityException
- Throws:
WSSecurityException
-
getSignatureCrypto
public Crypto getSignatureCrypto() throws WSSecurityException
- Throws:
WSSecurityException
-
getEncryptionCrypto
public Crypto getEncryptionCrypto() throws WSSecurityException
- Throws:
WSSecurityException
-
getCrypto
protected Crypto getCrypto(String cryptoKey, String propKey) throws WSSecurityException
- Throws:
WSSecurityException
-
setKeyIdentifierType
public void setKeyIdentifierType(WSSecBase secBase, AbstractToken token)
-
setEncryptionUser
public String setEncryptionUser(WSSecEncryptedKey encrKeyBuilder, AbstractToken token, boolean sign, Crypto crypto)
-
getUsername
public static String getUsername(List<WSHandlerResult> results)
Scan throughWSHandlerResultlist for a Username token and return the username if a Username Token found- Parameters:
results-- Returns:
-
getEncryptedKeyResult
protected WSSecurityEngineResult getEncryptedKeyResult()
-
getSignatureBuilder
protected WSSecSignature getSignatureBuilder(AbstractToken token, boolean attached, boolean endorse) throws WSSecurityException, TokenStoreException
-
doEndorsedSignatures
protected void doEndorsedSignatures(List<org.apache.cxf.ws.security.wss4j.policyhandlers.AbstractBindingBuilder.SupportingToken> tokenList, boolean isTokenProtection, boolean isSigProtect)
-
addSupportingTokens
protected void addSupportingTokens(List<WSEncryptionPart> sigs) throws WSSecurityException
- Throws:
WSSecurityException
-
doEndorse
protected void doEndorse()
-
addSignatureConfirmation
protected void addSignatureConfirmation(List<WSEncryptionPart> sigParts)
-
handleEncryptedSignedHeaders
public void handleEncryptedSignedHeaders(List<WSEncryptionPart> encryptedParts, List<WSEncryptionPart> signedParts)
Processes the parts to be signed and reconfigures those parts that have already been encrypted.- Parameters:
encryptedParts- the parts that have been encryptedsignedParts- the parts that are to be signed- Throws:
IllegalArgumentException- if an element insignedPartscontains aWSEncryptionPartwith anullidvalue and theWSEncryptionPartnamevalue is not "Token"
-
convertToEncryptionPart
public WSEncryptionPart convertToEncryptionPart(Element element)
Convert a DOM Element into a WSEncryptionPart, adding a (wsu:)Id if there is not one already.- Parameters:
element- The DOM Element to convert- Returns:
- The WSEncryptionPart representing the DOM Element argument
-
addSig
protected void addSig(byte[] val)
-
isExpandXopInclude
public boolean isExpandXopInclude()
-
-