Java Code Examples for org.apache.ws.security.WSConstants#BST_DIRECT_REFERENCE
The following examples show how to use
org.apache.ws.security.WSConstants#BST_DIRECT_REFERENCE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractBindingBuilder.java From steady with Apache License 2.0 | 5 votes |
protected WSSecEncryptedKey getEncryptedKeyBuilder(TokenWrapper wrapper, Token token) throws WSSecurityException { WSSecEncryptedKey encrKey = new WSSecEncryptedKey(wssConfig); Crypto crypto = getEncryptionCrypto(wrapper); message.getExchange().put(SecurityConstants.ENCRYPT_CRYPTO, crypto); setKeyIdentifierType(encrKey, wrapper, token); boolean alsoIncludeToken = false; // Find out do we also need to include the token as per the Inclusion requirement if (token instanceof X509Token && token.getInclusion() != SPConstants.IncludeTokenType.INCLUDE_TOKEN_NEVER && encrKey.getKeyIdentifierType() != WSConstants.BST_DIRECT_REFERENCE) { alsoIncludeToken = true; } String encrUser = setEncryptionUser(encrKey, wrapper, false, crypto); encrKey.setSymmetricEncAlgorithm(binding.getAlgorithmSuite().getEncryption()); encrKey.setKeyEncAlgo(binding.getAlgorithmSuite().getAsymmetricKeyWrap()); encrKey.prepare(saaj.getSOAPPart(), crypto); if (alsoIncludeToken) { CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS); cryptoType.setAlias(encrUser); X509Certificate[] certs = crypto.getX509Certificates(cryptoType); BinarySecurity bstToken = new X509Security(saaj.getSOAPPart()); ((X509Security) bstToken).setX509Certificate(certs[0]); bstToken.addWSUNamespace(); bstToken.setID(wssConfig.getIdAllocator().createSecureId("X509-", certs[0])); WSSecurityUtil.prependChildElement( secHeader.getSecurityHeader(), bstToken.getElement() ); bstElement = bstToken.getElement(); } return encrKey; }
Example 2
Source File: AbstractBindingBuilder.java From steady with Apache License 2.0 | 5 votes |
protected WSSecEncryptedKey getEncryptedKeyBuilder(TokenWrapper wrapper, Token token) throws WSSecurityException { WSSecEncryptedKey encrKey = new WSSecEncryptedKey(wssConfig); Crypto crypto = getEncryptionCrypto(wrapper); message.getExchange().put(SecurityConstants.ENCRYPT_CRYPTO, crypto); setKeyIdentifierType(encrKey, wrapper, token); boolean alsoIncludeToken = false; // Find out do we also need to include the token as per the Inclusion requirement if (token instanceof X509Token && token.getInclusion() != SPConstants.IncludeTokenType.INCLUDE_TOKEN_NEVER && encrKey.getKeyIdentifierType() != WSConstants.BST_DIRECT_REFERENCE) { alsoIncludeToken = true; } String encrUser = setEncryptionUser(encrKey, wrapper, false, crypto); encrKey.setSymmetricEncAlgorithm(binding.getAlgorithmSuite().getEncryption()); encrKey.setKeyEncAlgo(binding.getAlgorithmSuite().getAsymmetricKeyWrap()); encrKey.prepare(saaj.getSOAPPart(), crypto); if (alsoIncludeToken) { CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS); cryptoType.setAlias(encrUser); X509Certificate[] certs = crypto.getX509Certificates(cryptoType); BinarySecurity bstToken = new X509Security(saaj.getSOAPPart()); ((X509Security) bstToken).setX509Certificate(certs[0]); bstToken.addWSUNamespace(); bstToken.setID(wssConfig.getIdAllocator().createSecureId("X509-", certs[0])); WSSecurityUtil.prependChildElement( secHeader.getSecurityHeader(), bstToken.getElement() ); bstElement = bstToken.getElement(); } return encrKey; }
Example 3
Source File: AbstractBindingBuilder.java From steady with Apache License 2.0 | 5 votes |
protected WSSecEncryptedKey getEncryptedKeyBuilder(TokenWrapper wrapper, Token token) throws WSSecurityException { WSSecEncryptedKey encrKey = new WSSecEncryptedKey(wssConfig); Crypto crypto = getEncryptionCrypto(wrapper); message.getExchange().put(SecurityConstants.ENCRYPT_CRYPTO, crypto); setKeyIdentifierType(encrKey, wrapper, token); boolean alsoIncludeToken = false; // Find out do we also need to include the token as per the Inclusion requirement if (token instanceof X509Token && token.getInclusion() != SPConstants.IncludeTokenType.INCLUDE_TOKEN_NEVER && encrKey.getKeyIdentifierType() != WSConstants.BST_DIRECT_REFERENCE) { alsoIncludeToken = true; } String encrUser = setEncryptionUser(encrKey, wrapper, false, crypto); encrKey.setSymmetricEncAlgorithm(binding.getAlgorithmSuite().getEncryption()); encrKey.setKeyEncAlgo(binding.getAlgorithmSuite().getAsymmetricKeyWrap()); encrKey.prepare(saaj.getSOAPPart(), crypto); if (alsoIncludeToken) { CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS); cryptoType.setAlias(encrUser); X509Certificate[] certs = crypto.getX509Certificates(cryptoType); BinarySecurity bstToken = new X509Security(saaj.getSOAPPart()); ((X509Security) bstToken).setX509Certificate(certs[0]); bstToken.addWSUNamespace(); bstToken.setID(wssConfig.getIdAllocator().createSecureId("X509-", certs[0])); WSSecurityUtil.prependChildElement( secHeader.getSecurityHeader(), bstToken.getElement() ); bstElement = bstToken.getElement(); } return encrKey; }
Example 4
Source File: AbstractBindingBuilder.java From steady with Apache License 2.0 | 5 votes |
protected WSSecEncryptedKey getEncryptedKeyBuilder(TokenWrapper wrapper, Token token) throws WSSecurityException { WSSecEncryptedKey encrKey = new WSSecEncryptedKey(wssConfig); Crypto crypto = getEncryptionCrypto(wrapper); message.getExchange().put(SecurityConstants.ENCRYPT_CRYPTO, crypto); setKeyIdentifierType(encrKey, wrapper, token); boolean alsoIncludeToken = false; // Find out do we also need to include the token as per the Inclusion requirement if (token instanceof X509Token && token.getInclusion() != SPConstants.IncludeTokenType.INCLUDE_TOKEN_NEVER && encrKey.getKeyIdentifierType() != WSConstants.BST_DIRECT_REFERENCE) { alsoIncludeToken = true; } String encrUser = setEncryptionUser(encrKey, wrapper, false, crypto); encrKey.setSymmetricEncAlgorithm(binding.getAlgorithmSuite().getEncryption()); encrKey.setKeyEncAlgo(binding.getAlgorithmSuite().getAsymmetricKeyWrap()); encrKey.prepare(saaj.getSOAPPart(), crypto); if (alsoIncludeToken) { CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS); cryptoType.setAlias(encrUser); X509Certificate[] certs = crypto.getX509Certificates(cryptoType); BinarySecurity bstToken = new X509Security(saaj.getSOAPPart()); ((X509Security) bstToken).setX509Certificate(certs[0]); bstToken.addWSUNamespace(); bstToken.setID(wssConfig.getIdAllocator().createSecureId("X509-", certs[0])); WSSecurityUtil.prependChildElement( secHeader.getSecurityHeader(), bstToken.getElement() ); bstElement = bstToken.getElement(); } return encrKey; }