Application Programming Interface Guide > Built-in Procedures > Procedures Reference > EncryptElement
 
EncryptElement
Encrypt an element in the specified SOAP envelope using a symmetric key that is encrypted by a certificate or public key.
The elementName argument determines which element in the message to encrypt. Typically this procedure is used to encrypt either the header or body of the SOAP message.
This method adds WS-Security artifacts to a header in the SOAPenvelope.
Artifacts are added to the SOAP header that is identified by the actor and mustUnderstand arguments. If the SOAP message does not contain a SOAP header with the specified actor and mustUnderstandvalues, the header is created.
The encryptionAlgorithm determines the method of encryption. The default value (AES_128) is sufficient for most purposes. Stronger encryption algorithms, such as AES_192 or AES_256, require an unrestricted Java Cryptography Extension (JCE) policy file to be installed in the server’s JVM.
Location
/lib/services/
Inputs
envelope: A SOAP envelope. It may not be NULL.
actor: Determines which WS Security header to process. It may be NULL.
mustUnderstand: Indicates whether or not the receiver must understand this header. If NULL, mustUnderstand defaults to TRUE.
elementName: The name of the element in the envelope to encrypt. If NULL, elementName defaults to {http://schemas.xmlsoap.org/soap/envelope/}Body.
encryptionAlgorithm: The symmetric encryption algorithm used to encrypt the data. It may be NULL, TRIPLE_DES, AES_128, AES_192, AES_256. If NULL, encryptionAlgorithm defaults to AES_128.
certificateAlias: The alias of a certificate or public key in the key store to use to encrypt the symmetric key that is used to encrypt the element. It may not be NULL.
keyStore: A serialized Java key store. It may be NULL.
keyStoreType: The type of key store. It must be JKS or PKCS12. It may not be NULL.
keyStorePassword: The password of the key store and of all private keys within it. It may be NULL or empty if there is no password.
Output
envelope: The SOAP envelope containing the encrypted element and the generated WS Security artifacts in a SOAP header.
Exceptions
IllegalArgumentException: If any of the arguments are invalid.
SecurityException: If the element could not be encrypted.