public class WSSecEncryptedKey extends WSSecBase
EncryptedKey has to be used to sign and encrypt the message In
such a situation this builder will add the EncryptedKey to the
security header and we can use the information form the builder to provide to
other builders to reference to the tokenaddWSUNamespace, attachmentCallbackHandler, callbackLookup, expandXopInclude, keyIdentifierType, password, storeBytesInAttachment, user| Constructor and Description |
|---|
WSSecEncryptedKey(Document doc) |
WSSecEncryptedKey(Document doc,
Provider provider) |
WSSecEncryptedKey(WSSecHeader securityHeader) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addCipherValueElement(byte[] encryptedEphemeralKey)
Create and add the CipherValue Element to the EncryptedKey Element.
|
void |
appendBSTElementToHeader()
Append the BinarySecurityToken to the elements already in the Security
header.
|
void |
appendToHeader()
Append the EncryptedKey element to the elements already in the Security
header.
|
protected Element |
createCipherValue(Document doc,
Element encryptedKey) |
protected void |
createEncryptedKeyElement(Key key)
Now we need to setup the EncryptedKey header block:
1) create a EncryptedKey element and set a wsu:Id for it
2) Generate ds:KeyInfo element, this wraps the wsse:SecurityTokenReference
3) Create and set up the SecurityTokenReference according to the keyIdentifier parameter
4) Create the CipherValue element structure and insert the encrypted session key
|
protected void |
createEncryptedKeyElement(X509Certificate remoteCert,
Crypto crypto)
Now we need to setup the EncryptedKey header block:
1) create a EncryptedKey element and set a wsu:Id for it
2) Generate ds:KeyInfo element, this wraps the wsse:SecurityTokenReference
3) Create and set up the SecurityTokenReference according to the keyIdentifier parameter
4) Create the CipherValue element structure and insert the encrypted session key
|
protected byte[] |
encryptSymmetricKey(PublicKey encryptingKey,
SecretKey keyToBeEncrypted) |
Element |
getBinarySecurityTokenElement() |
String |
getBSTTokenId()
Get the id of the BSt generated during
prepare(). |
Element |
getCustomEKKeyInfoElement() |
String |
getDigestAlgorithm()
Get the digest algorithm to use with the RSA-OAEP key transport algorithm.
|
Element |
getEncryptedKeyElement() |
String |
getEncryptedKeySHA1() |
String |
getId()
Get the id generated during
prepare(). |
String |
getKeyEncAlgo() |
String |
getMGFAlgorithm()
Get the MGF algorithm to use with the RSA-OAEP key transport algorithm.
|
X509Certificate |
getUseThisCert() |
PublicKey |
getUseThisPublicKey() |
boolean |
isCertSet() |
boolean |
isIncludeEncryptionToken() |
void |
prepare(Crypto crypto,
SecretKey symmetricKey)
Create the EncryptedKey Element for inclusion in the security header, by encrypting the
symmetricKey parameter using either a public key or certificate that is set on the class,
and adding the encrypted bytes as the CipherValue of the EncryptedKey element.
|
void |
prependBSTElementToHeader()
Prepend the BinarySecurityToken to the elements already in the Security
header.
|
void |
prependToHeader()
Prepend the EncryptedKey element to the elements already in the Security
header.
|
void |
setCustomEKKeyInfoElement(Element customEKKeyInfoElement) |
void |
setCustomEKTokenId(String customEKTokenId) |
void |
setCustomEKTokenValueType(String customEKTokenValueType) |
void |
setDigestAlgorithm(String digestAlgorithm)
Set the digest algorithm to use with the RSA-OAEP key transport algorithm.
|
void |
setEncKeyId(String encKeyId) |
void |
setEncryptedKeyElement(Element encryptedKeyElement)
Set the encrypted key element when a pre prepared encrypted key is used
|
protected void |
setEncryptedKeySHA1(byte[] encryptedEphemeralKey) |
void |
setIncludeEncryptionToken(boolean includeEncryptionToken) |
void |
setKeyEncAlgo(String keyEncAlgo) |
void |
setMGFAlgorithm(String mgfAlgorithm)
Set the MGF algorithm to use with the RSA-OAEP key transport algorithm.
|
void |
setUserInfo(String user)
Set the user name to get the encryption certificate.
|
void |
setUseThisCert(X509Certificate cert)
Set the X509 Certificate to use for encryption.
|
void |
setUseThisPublicKey(PublicKey key)
Set the PublicKey to use for encryption.
|
clean, getDocument, getIdAllocator, getKeyIdentifierType, getParts, getSecurityHeader, getWsDocInfo, isExpandXopInclude, setAttachmentCallbackHandler, setBodyID, setCallbackLookup, setExpandXopInclude, setIdAllocator, setKeyIdentifierType, setStoreBytesInAttachment, setUserInfo, setWsDocInfo, setWsuIdpublic WSSecEncryptedKey(WSSecHeader securityHeader)
public WSSecEncryptedKey(Document doc)
public void setUserInfo(String user)
user - public String getId()
prepare().
Returns the the value of wsu:Id attribute of the EncryptedKey element.prepare()
was not called before.public void prepare(Crypto crypto, SecretKey symmetricKey) throws WSSecurityException
crypto - An instance of the Crypto API to handle keystore and certificatessymmetricKey - The symmetric key to encrypt and insert into the EncryptedKeyWSSecurityExceptionprotected void addCipherValueElement(byte[] encryptedEphemeralKey)
throws WSSecurityException
WSSecurityExceptionprotected void createEncryptedKeyElement(X509Certificate remoteCert, Crypto crypto) throws WSSecurityException
WSSecurityExceptionprotected void createEncryptedKeyElement(Key key) throws WSSecurityException
WSSecurityExceptionprotected byte[] encryptSymmetricKey(PublicKey encryptingKey, SecretKey keyToBeEncrypted) throws WSSecurityException
WSSecurityExceptionpublic void prependToHeader()
prepare(). This
allows to insert the EncryptedKey element at any position in the Security
header.public void appendToHeader()
prepare(). This
allows to insert the EncryptedKey element at any position in the Security
header.public void prependBSTElementToHeader()
prepare(). This
allows to insert the BST element at any position in the Security header.public void appendBSTElementToHeader()
prepare(). This
allows to insert the BST element at any position in the Security header.public void setUseThisCert(X509Certificate cert)
DirectReference then use this certificate to get the
public key for encryption.cert - is the X509 certificate to use for encryptionpublic X509Certificate getUseThisCert()
public void setUseThisPublicKey(PublicKey key)
key - the PublicKey instance to use for encryptionpublic PublicKey getUseThisPublicKey()
public Element getEncryptedKeyElement()
public void setEncryptedKeyElement(Element encryptedKeyElement)
encryptedKeyElement - EncryptedKey element of the encrypted key usedpublic Element getBinarySecurityTokenElement()
public void setKeyEncAlgo(String keyEncAlgo)
public String getKeyEncAlgo()
public String getBSTTokenId()
prepare().public void setEncKeyId(String encKeyId)
encKeyId - The encKeyId to set.public boolean isCertSet()
public void setCustomEKTokenValueType(String customEKTokenValueType)
public void setCustomEKTokenId(String customEKTokenId)
public void setDigestAlgorithm(String digestAlgorithm)
digestAlgorithm - the digest algorithm to use with the RSA-OAEP key transport algorithmpublic String getDigestAlgorithm()
public void setMGFAlgorithm(String mgfAlgorithm)
mgfAlgorithm - the MGF algorithm to use with the RSA-OAEP key transport algorithmpublic String getMGFAlgorithm()
public boolean isIncludeEncryptionToken()
public void setIncludeEncryptionToken(boolean includeEncryptionToken)
public Element getCustomEKKeyInfoElement()
public void setCustomEKKeyInfoElement(Element customEKKeyInfoElement)
protected void setEncryptedKeySHA1(byte[] encryptedEphemeralKey)
throws WSSecurityException
WSSecurityExceptionpublic String getEncryptedKeySHA1()
Copyright © 2004–2023 The Apache Software Foundation. All rights reserved.