Class SecureSOAPMessage


  • public class SecureSOAPMessage
    extends Object
    This class SecureSOAPMessage constructs the secured SOAPMessage for the given security mechanism token.
    • Constructor Detail

      • SecureSOAPMessage

        public SecureSOAPMessage​(jakarta.xml.soap.SOAPMessage soapMessage,
                                 boolean create)
                          throws SecurityException
        Constructor to create secure SOAP message.
        Parameters:
        soapMessage - the SOAP message to be secured.
        create - if true, creates a new secured SOAP message by adding security headers. if false, parses the secured SOAP message.
        Throws:
        SecurityException - if failed in creating or parsing the new secured SOAP message.
      • SecureSOAPMessage

        public SecureSOAPMessage​(jakarta.xml.soap.SOAPMessage soapMessage,
                                 boolean create,
                                 List signedElements)
                          throws SecurityException
        Constructor to create secure SOAP message.
        Parameters:
        soapMessage - the SOAP message to be secured.
        create - if true, creates a new secured SOAP message by adding security headers. if false, parses the secured SOAP message.
        signedElements - list of signed elements
        Throws:
        SecurityException - if failed in creating or parsing the new secured SOAP message.
    • Method Detail

      • getSecurityHeaderElement

        public Element getSecurityHeaderElement()
        Returns the Security Header Element.
        Returns:
        the Security Header Element.
      • getSOAPMessage

        public jakarta.xml.soap.SOAPMessage getSOAPMessage()
        Returns the secured SOAP message.
        Returns:
        the secured SOAP message.
      • setSOAPMessage

        public void setSOAPMessage​(jakarta.xml.soap.SOAPMessage inSoapMessage)
        Sets the secured SOAP message.
        Parameters:
        inSoapMessage - the input secured SOAP message.
      • parseSecurityHeader

        public void parseSecurityHeader​(Node node)
                                 throws SecurityException
        Parses for the security header.
        Parameters:
        node - security header node.
        Throws:
        SecurityException - if there is any error occured.
      • getSecurityMechanism

        public SecurityMechanism getSecurityMechanism()
        Returns the security mechanism of the secure soap message.
        Returns:
        SecurityMechanism the security mechanism of the secure SOAPMessage.
      • setSecurityMechanism

        public void setSecurityMechanism​(SecurityMechanism securityMechanism)
        Sets the security mechanism for securing the soap message.
        Parameters:
        securityMechanism - the security mechanism that will be used to secure the soap message.
      • setSecurityToken

        public void setSecurityToken​(SecurityToken token)
                              throws SecurityException
        Sets the security token for securing the soap message.
        Parameters:
        token - the security token that is used to secure the soap message.
        Throws:
        SecurityException - if the security token can not be added to the security header.
      • getSecurityToken

        public SecurityToken getSecurityToken()
        Returns the security token associated with this secure soap message.
        Returns:
        SecurityToken the security token for this secure soap message.
      • setSecurityContext

        public void setSecurityContext​(SecurityContext securityContext)
      • sign

        public void sign()
                  throws SecurityException
        Signs the SOAPMessage for the given security profile.
        Throws:
        SecurityException - if there is any failure in signing.
      • getMessageID

        public String getMessageID()
        Returns the messageID from the header.
        Returns:
        the messageID from the header.
      • getMessageTimestamp

        public long getMessageTimestamp()
        Retruns the message timestamp.
        Returns:
        the message timestamp.
      • verifySignature

        public boolean verifySignature()
                                throws SecurityException
        Verifies the signature of the SOAP message.
        Returns:
        true if the signature verification is successful.
        Throws:
        SecurityException - if there is any failure in validation.
      • verifyKerberosTokenSignature

        public boolean verifyKerberosTokenSignature​(Key secretKey)
                                             throws SecurityException
        Verifies the signature of the SOAP message that has kerberos key.
        Parameters:
        secretKey - the secret key that is used for signature verification.
        Returns:
        true if the signature verification is successful.
        Throws:
        SecurityException - if there is any failure in validation.
      • getMessageCertificate

        public X509Certificate getMessageCertificate()
        Returns the X509Certificate that is used to secure the SOAPMessage.
        Returns:
        the X509 certificate.
      • encrypt

        public void encrypt​(String certAlias,
                            String encryptionAlgorithm,
                            int encryptionKeyStrength,
                            boolean encryptBody,
                            boolean encryptHeader)
                     throws SecurityException
        Encrypts the SOAPMessage for the given security profile.
        Parameters:
        certAlias - the certificate alias
        encryptBody - boolean flag to encrypt Body
        encryptHeader - boolean flag to encrypt Security header
        Throws:
        SecurityException - if there is any failure in encryption.
      • decrypt

        public void decrypt​(String keyAlias,
                            boolean decryptBody,
                            boolean decryptHeader)
                     throws SecurityException
        Decrypts the SOAPMessage for the given security profile.
        Parameters:
        keyAlias - private key alias that is used to decrypt.
        decryptBody - boolean flag to decrypt Body
        decryptHeader - boolean flag to decrypt Security header
        Throws:
        SecurityException - if there is any failure in decryption.
      • setSenderIdentity

        public void setSenderIdentity​(String dnsName)
      • getClientDnsClaim

        public String getClientDnsClaim()
      • setSignedElements

        public void setSignedElements​(List elements)