Class WSSecDKEncrypt


  • public class WSSecDKEncrypt
    extends WSSecDerivedKeyBase
    Encrypts and signs parts of a message with derived keys derived from a symmetric key. This symmetric key will be included as an EncryptedKey
    • Constructor Detail

      • WSSecDKEncrypt

        public WSSecDKEncrypt​(WSSecHeader securityHeader)
      • WSSecDKEncrypt

        public WSSecDKEncrypt​(Document doc)
    • Method Detail

      • prepare

        public void prepare​(byte[] ephemeralKey)
                     throws WSSecurityException
        Description copied from class: WSSecDerivedKeyBase
        Initialize a WSSec Derived key. The method prepares and initializes a WSSec derived key structure after the relevant information was set. This method also creates and initializes the derived token using the ephemeral key. After preparation references can be added, encrypted and signed as required. This method does not add any element to the security header. This must be done explicitly.
        Overrides:
        prepare in class WSSecDerivedKeyBase
        Parameters:
        ephemeralKey - The ephemeral key to use for derivation
        Throws:
        WSSecurityException
      • addAttachmentEncryptedDataElements

        public void addAttachmentEncryptedDataElements()
      • encryptForExternalRef

        public Element encryptForExternalRef​(Element dataRef,
                                             List<WSEncryptionPart> references)
                                      throws WSSecurityException
        Encrypt one or more parts or elements of the message (external). This method takes a vector of WSEncryptionPart object that contain information about the elements to encrypt. The method call the encryption method, takes the reference information generated during encryption and add this to the xenc:Reference element. This method can be called after prepare() and can be called multiple times to encrypt a number of parts or elements. The method generates a xenc:Reference element that must be added to the SecurityHeader. See addExternalRefElement(). If the dataRef parameter is null the method creates and initializes a new Reference element.
        Parameters:
        dataRef - A xenc:Reference element or null
        references - A list containing WSEncryptionPart objects
        Returns:
        Returns the updated xenc:Reference element
        Throws:
        WSSecurityException
      • addExternalRefElement

        public void addExternalRefElement​(Element referenceList)
        Adds (prepends) the external Reference element to the Security header. The reference element must be created by the encryptForExternalRef() method. The method adds the reference element in the SecurityHeader.
        Parameters:
        referenceList - The external enc:Reference element
      • setSymmetricEncAlgorithm

        public void setSymmetricEncAlgorithm​(String algo)
        Set the symmetric encryption algorithm URI to use
        Parameters:
        algo - the symmetric encryption algorithm URI to use
      • setDerivedKeyLength

        public void setDerivedKeyLength​(int keyLength)
      • getAttachmentEncryptedDataElements

        public List<Element> getAttachmentEncryptedDataElements()
      • getEncryptionSerializer

        public org.apache.xml.security.encryption.Serializer getEncryptionSerializer()
      • setEncryptionSerializer

        public void setEncryptionSerializer​(org.apache.xml.security.encryption.Serializer encryptionSerializer)