|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ws.security.message.WSSecBase
org.apache.ws.security.message.WSSecEncryptedKey
Builder class to build an EncryptedKey.
This is especially useful in the case where the same
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 token
Field Summary | |
protected BinarySecurity |
bstToken
BinarySecurityToken to be included in the case where BST_DIRECT_REFERENCE is used to refer to the asymmetric encryption cert |
protected org.w3c.dom.Document |
document
|
protected java.lang.String |
encKeyId
The Token identifier of the token that the DerivedKeyToken
is (or to be) derived from. |
protected java.lang.String |
encrUser
Remote user's alias to obtain the cert to encrypt the ephemeral key |
protected byte[] |
encryptedEphemeralKey
Encrypted bytes of the ephemeral key |
protected org.w3c.dom.Element |
encryptedKeyElement
xenc:EncryptedKey element |
protected org.w3c.dom.Element |
envelope
soap:Envelope element |
protected byte[] |
ephemeralKey
Session key used as the secret in key derivation |
protected java.lang.String |
keyEncAlgo
Algorithm used to encrypt the ephemeral key |
protected int |
keySize
Key size in bits Defaults to 128 |
protected java.security.cert.X509Certificate |
useThisCert
|
Fields inherited from class org.apache.ws.security.message.WSSecBase |
doDebug, keyIdentifierType, parts, password, user, wssConfig |
Constructor Summary | |
WSSecEncryptedKey()
|
Method Summary | |
void |
appendBSTElementToHeader(WSSecHeader secHeader)
Append the BinarySecurityToken to the elements already in the Security header. |
void |
appendToHeader(WSSecHeader secHeader)
Append the EncryptedKey element to the elements already in the Security header. |
protected org.w3c.dom.Element |
createCipherValue(org.w3c.dom.Document doc,
org.w3c.dom.Element encryptedKey)
|
protected org.w3c.dom.Element |
createEncryptedKey(org.w3c.dom.Document doc,
java.lang.String keyTransportAlgo)
Create DOM subtree for xenc:EncryptedKey |
protected org.w3c.dom.Element |
createEnrcyptedKey(org.w3c.dom.Document doc,
java.lang.String keyTransportAlgo)
Deprecated. use createEncryptedKey(Document doc, String keyTransportAlgo) instead |
protected byte[] |
generateEphemeralKey()
Create an ephemeral key |
org.w3c.dom.Element |
getBinarySecurityTokenElement()
|
java.lang.String |
getBSTTokenId()
Get the id of the BSt generated during prepare() . |
byte[] |
getEncryptedEphemeralKey()
|
org.w3c.dom.Element |
getEncryptedKeyElement()
|
byte[] |
getEphemeralKey()
|
java.lang.String |
getId()
Get the id generated during prepare() . |
boolean |
isCertSet()
|
void |
prepare(org.w3c.dom.Document doc,
Crypto crypto)
Prepare the ephemeralKey and the tokens required to be added to the security header |
protected void |
prepareInternal(byte[] keyBytes,
java.security.cert.X509Certificate remoteCert,
Crypto crypto)
Encrypt the symmetric key data and prepare the EncryptedKey element This method does the most work for to prepare the EncryptedKey element. |
void |
prependBSTElementToHeader(WSSecHeader secHeader)
Prepend the BinarySecurityToken to the elements already in the Security header. |
void |
prependToHeader(WSSecHeader secHeader)
Prepend the EncryptedKey element to the elements already in the Security header. |
void |
setDocument(org.w3c.dom.Document document)
|
void |
setEncKeyId(java.lang.String encKeyId)
|
void |
setEncryptedKeyElement(org.w3c.dom.Element encryptedKeyElement)
Set the encrypted key element when a pre prepared encrypted key is used |
void |
setEphemeralKey(byte[] ephemeralKey)
|
void |
setKeyEncAlgo(java.lang.String keyEncAlgo)
|
void |
setKeySize(int keySize)
|
void |
setUserInfo(java.lang.String user)
Set the user name to get the encryption certificate. |
void |
setUseThisCert(java.security.cert.X509Certificate cert)
Set the X509 Certificate to use for encryption. |
Methods inherited from class org.apache.ws.security.message.WSSecBase |
getKeyIdentifierType, setBodyID, setKeyIdentifierType, setParts, setUserInfo, setWsConfig, setWsuId |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected org.w3c.dom.Document document
protected org.w3c.dom.Element envelope
protected byte[] ephemeralKey
protected byte[] encryptedEphemeralKey
protected java.lang.String encrUser
protected java.lang.String keyEncAlgo
protected org.w3c.dom.Element encryptedKeyElement
protected java.lang.String encKeyId
DerivedKeyToken
is (or to be) derived from.
protected BinarySecurity bstToken
protected java.security.cert.X509Certificate useThisCert
protected int keySize
Constructor Detail |
public WSSecEncryptedKey()
Method Detail |
public void setUserInfo(java.lang.String user)
user
- public java.lang.String getId()
prepare()
.
Returns the the value of wsu:Id attribute of the EncryptedKey element.
prepare()
was not called before.public void prepare(org.w3c.dom.Document doc, Crypto crypto) throws WSSecurityException
doc
- The SOAP envelope as Document
crypto
- An instance of the Crypto API to handle keystore and certificates
WSSecurityException
protected void prepareInternal(byte[] keyBytes, java.security.cert.X509Certificate remoteCert, Crypto crypto) throws WSSecurityException
keyBytes
- The bytes that represent the symmetric keyremoteCert
- The certificate that contains the public key to encrypt the
symmetric key datacrypto
- An instance of the Crypto API to handle keystore and certificates
WSSecurityException
protected byte[] generateEphemeralKey() throws WSSecurityException
WSSecurityException
protected org.w3c.dom.Element createEncryptedKey(org.w3c.dom.Document doc, java.lang.String keyTransportAlgo)
xenc:EncryptedKey
doc
- the SOAP envelope parent documentkeyTransportAlgo
- specifies which algorithm to use to encrypt the symmetric key
xenc:EncryptedKey
elementprotected org.w3c.dom.Element createEnrcyptedKey(org.w3c.dom.Document doc, java.lang.String keyTransportAlgo)
xenc:EncryptedKey
doc
- the SOAP envelope parent documentkeyTransportAlgo
- specifies which algorithm to use to encrypt the symmetric key
xenc:EncryptedKey
elementprotected org.w3c.dom.Element createCipherValue(org.w3c.dom.Document doc, org.w3c.dom.Element encryptedKey)
public void prependToHeader(WSSecHeader secHeader)
prepare()
. This
allows to insert the EncryptedKey element at any position in the Security
header.
secHeader
- The security header that holds the Signature element.public void appendToHeader(WSSecHeader secHeader)
prepare()
. This
allows to insert the EncryptedKey element at any position in the Security
header.
secHeader
- The security header that holds the Signature element.public void prependBSTElementToHeader(WSSecHeader secHeader)
prepare()
. This
allows to insert the BST element at any position in the Security header.
secHeader
- The security header that holds the BST element.public void appendBSTElementToHeader(WSSecHeader secHeader)
prepare()
. This
allows to insert the BST element at any position in the Security header.
secHeader
- The security header that holds the BST element.public byte[] getEphemeralKey()
public void setUseThisCert(java.security.cert.X509Certificate cert)
DirectReference
then use this certificate to get the
public key for encryption.
cert
- is the X509 certificate to use for encryptionpublic org.w3c.dom.Element getEncryptedKeyElement()
public void setEncryptedKeyElement(org.w3c.dom.Element encryptedKeyElement)
encryptedKeyElement
- EncryptedKey element of the encrypted key usedpublic org.w3c.dom.Element getBinarySecurityTokenElement()
public void setKeySize(int keySize) throws WSSecurityException
WSSecurityException
public void setKeyEncAlgo(java.lang.String keyEncAlgo)
public void setEphemeralKey(byte[] ephemeralKey)
ephemeralKey
- The ephemeralKey to set.public java.lang.String getBSTTokenId()
prepare()
.
public void setDocument(org.w3c.dom.Document document)
document
- The document to set.public void setEncKeyId(java.lang.String encKeyId)
encKeyId
- The encKeyId to set.public boolean isCertSet()
public byte[] getEncryptedEphemeralKey()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |