XML Security, 1.6

com.ibm.xml.enc.dom
Class DOMEncryptedKey

java.lang.Object
  extended by com.ibm.xml.enc.dom.DOMStructure
      extended by com.ibm.xml.enc.dom.DOMEncryptedKey
All Implemented Interfaces:
EncryptedType, EncryptedKey, XMLStructure

public final class DOMEncryptedKey
extends DOMStructure
implements EncryptedKey


Field Summary
 
Fields inherited from interface javax.xml.crypto.enc.keyinfo.EncryptedKey
TYPE
 
Fields inherited from interface javax.xml.crypto.enc.EncryptedType
CONTENT, ELEMENT, XMLNS
 
Constructor Summary
DOMEncryptedKey(org.w3c.dom.Element encDataElem, XMLCryptoContext context)
          Creates a DOMEncryptedKey from XML.
DOMEncryptedKey(java.lang.String id, java.lang.String type, java.lang.String mimeType, java.lang.String encoding, java.lang.String recipient, DOMEncryptionMethod em, DOMKeyInfo ki, DOMCipherData cdata, DOMEncryptionProperties eps, DOMReferenceList rl, java.lang.String carriedKeyName, org.w3c.dom.Element localEncDataElem)
           
DOMEncryptedKey(ToBeEncryptedKey toBeEncrypted, DOMEncryptionMethod em, DOMKeyInfo ki, DOMEncryptionProperties eps, java.util.List references, java.lang.String id, java.lang.String carriedKeyName, java.lang.String recipient)
          Creates a DOMEncryptedKey from the specified components.
DOMEncryptedKey(ToBeEncryptedKey toBeEncrypted, DOMEncryptionMethod em, DOMKeyInfo ki, DOMEncryptionProperties eps, java.util.List references, java.lang.String id, java.lang.String carriedKeyName, java.lang.String recipient, DOMCipherReference cipherReference)
          Creates a DOMEncryptedKey from the specified components.
 
Method Summary
 java.io.InputStream decrypt(XMLDecryptContext decryptContext)
          Decrypts the CipherData in this EncryptedKey.
 java.security.Key decryptKey(XMLDecryptContext decryptContext, AlgorithmMethod algo)
          Decrypts the CipherData in this EncryptedKey and returns the decrypted key as a Key object.
 void encrypt(XMLEncryptContext encryptContext)
          Encrypts the ToBeEncrypted passed to the construction of this EncryptedType and inserts it in the CipherValue or CipherReference of the CipherData of this EncryptedData.
 boolean equals(java.lang.Object o)
           
 java.lang.String getCarriedKeyName()
          Returns the carried key name of this EncryptedKey.
 CipherData getCipherData()
          Returns the cipher data containing the encrypted data.
 java.io.InputStream getCipherText()
          Returns the encrypted data if the EncryptedType stores the encrypted data as CipherReference.
 java.lang.String getEncoding()
          Returns a URI identifying the transfer encoding of the data that has been encrypted.
 EncryptionMethod getEncryptionMethod()
          Returns the encryption method applied to the cipher data.
 EncryptionProperties getEncryptionProperties()
          Returns the encryption properties associated with this encrypted type.
 java.lang.String getId()
          Returns the optional ID.
 KeyInfo getKeyInfo()
          Returns the key info that carries information about the key used to encrypt the data.
 java.lang.String getMimeType()
          Returns the mime type of the data that has been encrypted.
 java.lang.String getRecipient()
          Returns a hint as to which recipient this EncryptedKey is intended for.
 java.util.List getReferenceList()
          Returns an unmodifiable list of ReferenceTypes containing pointers to data and keys encrypted using this key.
 ToBeEncrypted getToBeEncrypted()
          Returns the data to be encrypted if there is any
 java.lang.String getType()
          Returns a URI identifying the type of the plaintext form of the encrypted content.
 void marshal(org.w3c.dom.Node parent, org.w3c.dom.Node nextSibling, java.lang.String encPrefix, DOMCryptoContext context)
           
 void marshal(org.w3c.dom.Node parent, java.lang.String encPrefix, DOMCryptoContext context)
           
 
Methods inherited from class com.ibm.xml.enc.dom.DOMStructure
isFeatureSupported
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.xml.crypto.XMLStructure
isFeatureSupported
 

Constructor Detail

DOMEncryptedKey

public DOMEncryptedKey(ToBeEncryptedKey toBeEncrypted,
                       DOMEncryptionMethod em,
                       DOMKeyInfo ki,
                       DOMEncryptionProperties eps,
                       java.util.List references,
                       java.lang.String id,
                       java.lang.String carriedKeyName,
                       java.lang.String recipient)
Creates a DOMEncryptedKey from the specified components.

Parameters:
toBeEncrypted - the Key to be encrypted
em - the EncryptionMethod
ki - the KeyInfo, or null if not specified
eps - the EncryptionProperties or null if not specified.
references - List of ReferenceTypes point to data and keys encrypted using this key
carriedKeyName - an element for associating a user readable name with the key value (specify null to omit)
recipient - an attribute that contains a hint as to which recipient this encrypted key value is intended for (specify null to omit)

DOMEncryptedKey

public DOMEncryptedKey(ToBeEncryptedKey toBeEncrypted,
                       DOMEncryptionMethod em,
                       DOMKeyInfo ki,
                       DOMEncryptionProperties eps,
                       java.util.List references,
                       java.lang.String id,
                       java.lang.String carriedKeyName,
                       java.lang.String recipient,
                       DOMCipherReference cipherReference)
Creates a DOMEncryptedKey from the specified components.

Parameters:
toBeEncrypted - the Key to be encrypted
em - the EncryptionMethod
ki - the KeyInfo, or null if not specified
eps - the EncryptionProperties or null if not specified.
references - List of ReferenceTypes point to data and keys encrypted using this key
carriedKeyName - an element for associating a user readable name with the key value (specify null to omit)
recipient - an attribute that contains a hint as to which recipient this encrypted key value is intended for (specify null to omit)
cipherReference - a cipherReference

DOMEncryptedKey

public DOMEncryptedKey(org.w3c.dom.Element encDataElem,
                       XMLCryptoContext context)
                throws MarshalException
Creates a DOMEncryptedKey from XML.

Parameters:
encDataElem - EncryptedKey element
Throws:
MarshalException - if EncryptedKey cannot be unmarshalled

DOMEncryptedKey

DOMEncryptedKey(java.lang.String id,
                java.lang.String type,
                java.lang.String mimeType,
                java.lang.String encoding,
                java.lang.String recipient,
                DOMEncryptionMethod em,
                DOMKeyInfo ki,
                DOMCipherData cdata,
                DOMEncryptionProperties eps,
                DOMReferenceList rl,
                java.lang.String carriedKeyName,
                org.w3c.dom.Element localEncDataElem)
Method Detail

getReferenceList

public java.util.List getReferenceList()
Description copied from interface: EncryptedKey
Returns an unmodifiable list of ReferenceTypes containing pointers to data and keys encrypted using this key.

Specified by:
getReferenceList in interface EncryptedKey
Returns:
an unmodifiable list of ReferenceTypes (may be empty but never null)

getCarriedKeyName

public java.lang.String getCarriedKeyName()
Description copied from interface: EncryptedKey
Returns the carried key name of this EncryptedKey.

Specified by:
getCarriedKeyName in interface EncryptedKey
Returns:
the carried key name or null if not specified

getRecipient

public java.lang.String getRecipient()
Description copied from interface: EncryptedKey
Returns a hint as to which recipient this EncryptedKey is intended for.

Specified by:
getRecipient in interface EncryptedKey
Returns:
the recipient or null if not specified

getId

public java.lang.String getId()
Description copied from interface: EncryptedType
Returns the optional ID.

Specified by:
getId in interface EncryptedType
Returns:
the ID, or null if not specified

getType

public java.lang.String getType()
Description copied from interface: EncryptedType
Returns a URI identifying the type of the plaintext form of the encrypted content.

Specified by:
getType in interface EncryptedType
Returns:
the type, or null if not specified

getMimeType

public java.lang.String getMimeType()
Description copied from interface: EncryptedType
Returns the mime type of the data that has been encrypted.

Specified by:
getMimeType in interface EncryptedType
Returns:
the mime type, or null if not specified

getEncoding

public java.lang.String getEncoding()
Description copied from interface: EncryptedType
Returns a URI identifying the transfer encoding of the data that has been encrypted.

Specified by:
getEncoding in interface EncryptedType
Returns:
the encoding, or null if not specified

getEncryptionMethod

public EncryptionMethod getEncryptionMethod()
Description copied from interface: EncryptedType
Returns the encryption method applied to the cipher data.

Specified by:
getEncryptionMethod in interface EncryptedType
Returns:
the encryption method, or null if not specified

getKeyInfo

public KeyInfo getKeyInfo()
Description copied from interface: EncryptedType
Returns the key info that carries information about the key used to encrypt the data.

Specified by:
getKeyInfo in interface EncryptedType
Returns:
the key info, or null if not specified

getCipherData

public CipherData getCipherData()
Description copied from interface: EncryptedType
Returns the cipher data containing the encrypted data.

Specified by:
getCipherData in interface EncryptedType
Returns:
the cipher data, or null if the data is a CipherValue and the data has not been encrypted yet

getEncryptionProperties

public EncryptionProperties getEncryptionProperties()
Description copied from interface: EncryptedType
Returns the encryption properties associated with this encrypted type.

Specified by:
getEncryptionProperties in interface EncryptedType
Returns:
the encryption properties, or null if not specified

getCipherText

public java.io.InputStream getCipherText()
Description copied from interface: EncryptedType
Returns the encrypted data if the EncryptedType stores the encrypted data as CipherReference.

Specified by:
getCipherText in interface EncryptedType
Returns:
the encrypted data if EncryptedType has CipherReference as CipherData

getToBeEncrypted

public ToBeEncrypted getToBeEncrypted()
Description copied from interface: EncryptedType
Returns the data to be encrypted if there is any

Specified by:
getToBeEncrypted in interface EncryptedType
Returns:
the data to be encrypted if there is any

marshal

public void marshal(org.w3c.dom.Node parent,
                    java.lang.String encPrefix,
                    DOMCryptoContext context)
             throws MarshalException
Specified by:
marshal in class DOMStructure
Throws:
MarshalException

marshal

public void marshal(org.w3c.dom.Node parent,
                    org.w3c.dom.Node nextSibling,
                    java.lang.String encPrefix,
                    DOMCryptoContext context)
             throws MarshalException
Throws:
MarshalException

decrypt

public java.io.InputStream decrypt(XMLDecryptContext decryptContext)
                            throws XMLEncryptionException
Description copied from interface: EncryptedKey
Decrypts the CipherData in this EncryptedKey.

Specified by:
decrypt in interface EncryptedType
Specified by:
decrypt in interface EncryptedKey
Parameters:
decryptContext - the decryption context
Returns:
the decrypted CipherData as an InputStream.
Throws:
XMLEncryptionException - if an error occurs while decrypting

decryptKey

public java.security.Key decryptKey(XMLDecryptContext decryptContext,
                                    AlgorithmMethod algo)
                             throws XMLEncryptionException
Description copied from interface: EncryptedKey
Decrypts the CipherData in this EncryptedKey and returns the decrypted key as a Key object.

Specified by:
decryptKey in interface EncryptedKey
Parameters:
decryptContext - the decryption context
algo - the algorithm of the decrypted key
Returns:
the decrypted CipherData as a key
Throws:
XMLEncryptionException - if an error occurs while decrypting

encrypt

public void encrypt(XMLEncryptContext encryptContext)
             throws MarshalException,
                    XMLEncryptionException
Description copied from interface: EncryptedType
Encrypts the ToBeEncrypted passed to the construction of this EncryptedType and inserts it in the CipherValue or CipherReference of the CipherData of this EncryptedData.

The data is assumed to be serialized by the application before invoking this method.

Specified by:
encrypt in interface EncryptedType
Parameters:
encryptContext - the encryption context
Throws:
MarshalException - if an error occurs while marshalling
XMLEncryptionException - if an error occurs while encrypting

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

XML Security, 1.6

Portions Copyright 2003, 2012 IBM Corporation.
Portions Copyright 2003, 2012 Oracle and/or its affiliates.