org.apache.ws.security.message
Class WSEncryptBody

java.lang.Object
  extended byorg.apache.ws.security.message.WSBaseMessage
      extended byorg.apache.ws.security.message.WSEncryptBody

public class WSEncryptBody
extends WSBaseMessage

Encrypts a SOAP body inside a SOAP envelope according to WS Specification, X509 profile, and adds the encryption data.

Author:
Davanum Srinivas (dims@yahoo.com)., Werner Dittmann (Werner.Dittmann@siemens.com).

Field Summary
protected  byte[] embeddedKey
           
protected  java.lang.String embeddedKeyName
           
protected  java.lang.String encCanonAlgo
           
protected  javax.crypto.SecretKey encryptionKey
          Symmetric key that's actually used.
protected  java.lang.String keyEncAlgo
           
protected  org.w3c.dom.Element parentNode
          Parent node to which the EncryptedKeyElement should be added.
protected  SecurityTokenReference securityTokenReference
          SecurityTokenReference to be inserted into EncryptedData/keyInfo element.
protected  java.lang.String symEncAlgo
           
protected  javax.crypto.SecretKey symmetricKey
          Symmetric key used in the EncrytpedKey.
protected  java.security.cert.X509Certificate useThisCert
           
 
Fields inherited from class org.apache.ws.security.message.WSBaseMessage
actor, doDebug, keyIdentifierType, mustunderstand, parts, password, timeToLive, user, wssConfig
 
Constructor Summary
WSEncryptBody()
          Deprecated. replaced by WSSecEncrypt.WSSecEncrypt()
WSEncryptBody(java.lang.String actor)
          Deprecated. replaced by WSSecEncrypt.WSSecEncrypt() and WSSecHeader for actor specification.
WSEncryptBody(java.lang.String actor, boolean mu)
          Deprecated. replaced by WSSecEncrypt.WSSecEncrypt() and WSSecHeader for actor and mustunderstand specification.
 
Method Summary
 org.w3c.dom.Document build(org.w3c.dom.Document doc, Crypto crypto)
          Deprecated. replaced by WSSecEncrypt.build(Document, Crypto, WSSecHeader)
static org.w3c.dom.Element createCipherValue(org.w3c.dom.Document doc, org.w3c.dom.Element encryptedKey)
           
static org.w3c.dom.Element createDataRefList(org.w3c.dom.Document doc, org.w3c.dom.Element encryptedKey, java.util.Vector encDataRefs)
           
static org.w3c.dom.Element createEncryptedKey(org.w3c.dom.Document doc, java.lang.String keyTransportAlgo)
          Create DOM subtree for xenc:EncryptedKey
static org.w3c.dom.Element createEnrcyptedKey(org.w3c.dom.Document doc, java.lang.String keyTransportAlgo)
          Deprecated. use createEncryptedKey(Document doc, String keyTransportAlgo) instead
 javax.crypto.SecretKey getEncryptionKey()
          Deprecated. replaced by WSSecEncryptedKey.getEncryptedEphemeralKey()
 SecurityTokenReference getSecurityTokenReference()
          Deprecated. replaced by WSSecEncrypt.getSecurityTokenReference()
 java.lang.String getSymmetricEncAlgorithm()
          Deprecated. replaced by WSSecEncrypt.getSymmetricEncAlgorithm()
 javax.crypto.SecretKey getSymmetricKey()
          Deprecated. replaced by WSSecEncrypt.getSymmetricKey()
 void setEmbeddedKeyName(java.lang.String embeddedKeyName)
          Deprecated. replaced by WSSecEncrypt.setEmbeddedKeyName(String)
 void setEncCanonicalization(java.lang.String algo)
          Deprecated. replaced by WSSecEncrypt.setEncCanonicalization(String)
 void setKey(byte[] key)
          Deprecated. replaced by WSSecEncrypt.setKey(byte[])
 void setKeyEnc(java.lang.String keyEnc)
          Deprecated. replaced by WSSecEncrypt.setKeyEnc(String)
 void setParentNode(org.w3c.dom.Element element)
          Deprecated.  
 void setSecurityTokenReference(SecurityTokenReference reference)
          Deprecated. replaced by WSSecEncrypt.setSecurityTokenReference(SecurityTokenReference)
 void setSymmetricEncAlgorithm(java.lang.String algo)
          Deprecated. replaced by WSSecEncrypt.setSymmetricEncAlgorithm(String)
 void setSymmetricKey(javax.crypto.SecretKey key)
          Deprecated. replaced by WSSecEncrypt.setSymmetricKey(SecretKey)
 void setUserInfo(java.lang.String user)
          Deprecated. replaced by WSSecEncryptedKey.setUserInfo(String)
 void setUseThisCert(java.security.cert.X509Certificate cert)
          Deprecated. replaced by WSSecEncryptedKey.setUseThisCert(X509Certificate)
 
Methods inherited from class org.apache.ws.security.message.WSBaseMessage
getKeyIdentifierType, insertSecurityHeader, setActor, setBodyID, setKeyIdentifierType, setMustUnderstand, setParts, setTimeToLive, setUserInfo, setWsConfig, setWsuId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

symEncAlgo

protected java.lang.String symEncAlgo

keyEncAlgo

protected java.lang.String keyEncAlgo

encCanonAlgo

protected java.lang.String encCanonAlgo

embeddedKey

protected byte[] embeddedKey

embeddedKeyName

protected java.lang.String embeddedKeyName

useThisCert

protected java.security.cert.X509Certificate useThisCert

symmetricKey

protected javax.crypto.SecretKey symmetricKey
Symmetric key used in the EncrytpedKey.


encryptionKey

protected javax.crypto.SecretKey encryptionKey
Symmetric key that's actually used.


parentNode

protected org.w3c.dom.Element parentNode
Parent node to which the EncryptedKeyElement should be added.


securityTokenReference

protected SecurityTokenReference securityTokenReference
SecurityTokenReference to be inserted into EncryptedData/keyInfo element.

Constructor Detail

WSEncryptBody

public WSEncryptBody()
Deprecated. replaced by WSSecEncrypt.WSSecEncrypt()

Constructor.


WSEncryptBody

public WSEncryptBody(java.lang.String actor)
Deprecated. replaced by WSSecEncrypt.WSSecEncrypt() and WSSecHeader for actor specification.

Constructor.

Parameters:
actor - The actor name of the wsse:Security header

WSEncryptBody

public WSEncryptBody(java.lang.String actor,
                     boolean mu)
Deprecated. replaced by WSSecEncrypt.WSSecEncrypt() and WSSecHeader for actor and mustunderstand specification.

Constructor.

Parameters:
actor - The actor name of the wsse:Security header
mu - Set mustUnderstand to true or false
Method Detail

setKey

public void setKey(byte[] key)
Deprecated. replaced by WSSecEncrypt.setKey(byte[])

Sets the key to use during embedded encryption.

Parameters:
key - to use during encryption. The key must fit the selected symmetrical encryption algorithm

setKeyEnc

public void setKeyEnc(java.lang.String keyEnc)
Deprecated. replaced by WSSecEncrypt.setKeyEnc(String)

Sets the algorithm to encode the symmetric key.

Default is the WSConstants.KEYTRANSPORT_RSA15 algorithm.

Parameters:
keyEnc - specifies the key encoding algorithm.
See Also:
WSConstants.KEYTRANSPORT_RSA15, WSConstants.KEYTRANSPORT_RSAOEP

setUserInfo

public void setUserInfo(java.lang.String user)
Deprecated. replaced by WSSecEncryptedKey.setUserInfo(String)

Set the user name to get the encryption certificate. The public key of this certificate is used, thus no password necessary. The user name is a keystore alias usually.

Parameters:
user -

setEmbeddedKeyName

public void setEmbeddedKeyName(java.lang.String embeddedKeyName)
Deprecated. replaced by WSSecEncrypt.setEmbeddedKeyName(String)

Set the key name for EMBEDDED_KEYNAME

Parameters:
embeddedKeyName -

setUseThisCert

public void setUseThisCert(java.security.cert.X509Certificate cert)
Deprecated. replaced by WSSecEncryptedKey.setUseThisCert(X509Certificate)

Set the X509 Certificate to use for encryption. If this is set and the key identifier is set to DirectReference then use this certificate to get the public key for encryption.

Parameters:
cert - is the X509 certificate to use for encryption

setSymmetricEncAlgorithm

public void setSymmetricEncAlgorithm(java.lang.String algo)
Deprecated. replaced by WSSecEncrypt.setSymmetricEncAlgorithm(String)

Set the name of the symmetric encryption algorithm to use.

This encryption alogrithm is used to encrypt the data, i.e. the SOAP Body. If the algorithm is not set then Triple DES is used. Refer to WSConstants which algorithms are supported.

Parameters:
algo - Is the name of the encryption algorithm
See Also:
WSConstants.TRIPLE_DES, WSConstants.AES_128, WSConstants.AES_192, WSConstants.AES_256

setEncCanonicalization

public void setEncCanonicalization(java.lang.String algo)
Deprecated. replaced by WSSecEncrypt.setEncCanonicalization(String)

Set the name of an optional canonicalization algorithm to use before encryption.

This c14n alogrithm is used to serialize the data before encryption, i.e. the SOAP Body. If the algorithm is not set then a standard serialization is used (provided by XMLCipher, usually a XMLSerializer according to DOM 3 specification).

Parameters:
algo - Is the name of the canonicalization algorithm

getSymmetricEncAlgorithm

public java.lang.String getSymmetricEncAlgorithm()
Deprecated. replaced by WSSecEncrypt.getSymmetricEncAlgorithm()

Get the name of symmetric encryption algorithm to use.

The name of the encryption alogrithm to encrypt the data, i.e. the SOAP Body. Refer to WSConstants which algorithms are supported.

Returns:
the name of the currently selected symmetric encryption algorithm
See Also:
WSConstants.TRIPLE_DES, WSConstants.AES_128, WSConstants.AES_192, WSConstants.AES_256

build

public org.w3c.dom.Document build(org.w3c.dom.Document doc,
                                  Crypto crypto)
                           throws WSSecurityException
Deprecated. replaced by WSSecEncrypt.build(Document, Crypto, WSSecHeader)

Builds the SOAP envelope with encrypted Body and adds encrypted key.

This function performs several steps:

Parameters:
doc - the SOAP envelope as Document with plaintext Body
crypto - an instance of the Crypto API to handle keystore and Certificates
Returns:
the SOAP envelope with encrypted Body as Document
Throws:
WSSecurityException

createEncryptedKey

public static org.w3c.dom.Element createEncryptedKey(org.w3c.dom.Document doc,
                                                     java.lang.String keyTransportAlgo)
Create DOM subtree for xenc:EncryptedKey

Parameters:
doc - the SOAP envelope parent document
keyTransportAlgo - specifies which algorithm to use to encrypt the symmetric key
Returns:
an xenc:EncryptedKey element

createEnrcyptedKey

public static org.w3c.dom.Element createEnrcyptedKey(org.w3c.dom.Document doc,
                                                     java.lang.String keyTransportAlgo)
Deprecated. use createEncryptedKey(Document doc, String keyTransportAlgo) instead

Create DOM subtree for xenc:EncryptedKey

Parameters:
doc - the SOAP envelope parent document
keyTransportAlgo - specifies which algorithm to use to encrypt the symmetric key
Returns:
an xenc:EncryptedKey element

createCipherValue

public static org.w3c.dom.Element createCipherValue(org.w3c.dom.Document doc,
                                                    org.w3c.dom.Element encryptedKey)

createDataRefList

public static org.w3c.dom.Element createDataRefList(org.w3c.dom.Document doc,
                                                    org.w3c.dom.Element encryptedKey,
                                                    java.util.Vector encDataRefs)

setParentNode

public void setParentNode(org.w3c.dom.Element element)
Deprecated.  

Sets the parent node of the EncryptedKeyElement

Parameters:
element -

getSymmetricKey

public javax.crypto.SecretKey getSymmetricKey()
Deprecated. replaced by WSSecEncrypt.getSymmetricKey()

Returns:
TODO

setSymmetricKey

public void setSymmetricKey(javax.crypto.SecretKey key)
Deprecated. replaced by WSSecEncrypt.setSymmetricKey(SecretKey)

Set the symmetric key to be used for encryption

Parameters:
key -

getEncryptionKey

public javax.crypto.SecretKey getEncryptionKey()
Deprecated. replaced by WSSecEncryptedKey.getEncryptedEphemeralKey()

Get the symmetric key used for encryption. This may be the same as the symmetric key field.

Returns:
The symmetric key

getSecurityTokenReference

public SecurityTokenReference getSecurityTokenReference()
Deprecated. replaced by WSSecEncrypt.getSecurityTokenReference()

Returns:
TODO

setSecurityTokenReference

public void setSecurityTokenReference(SecurityTokenReference reference)
Deprecated. replaced by WSSecEncrypt.setSecurityTokenReference(SecurityTokenReference)

Parameters:
reference -


Copyright © 2004-2008 The Apache Software Foundation. All Rights Reserved.