Class SOAPMessageSecurityProvider


  • public final class SOAPMessageSecurityProvider
    extends java.lang.Object

    Class that allows to secure and encrypt the SOAP requests.

    Project:

    Library for the integration with the services of @Firma, eVisor and TS@.

    Version:
    1.0, 14/01/2014.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String AUTHENTICATION_CERTIFICATE
      Constant attribute that identifies the Web Services Security X.509 Certificate Token Profile, used to secure the SOAP messages.
      static java.lang.String AUTHENTICATION_SAML
      Constant attribute that identifies the Web Services Security SAML Token Profile, used to secure the SOAP messages.
      static java.lang.String AUTHENTICATION_USER_PASSWORD
      Constant attribute that identifies the Web Services Security UsernameToken Profile, used to secure the SOAP messages.
      static java.lang.String INCLUSION_METHOD_DIRECT
      Constant attribute that identifies the direct inclusion mode (BinarySecurityToken) of the X.509 certificate for the Web Services Security X.509 Certificate Token Profile.
      static java.lang.String INCLUSION_METHOD_IDENTIFIER
      Constant attribute that identifies the subject key identifier inclusion mode (KeyIdentifier) of the X.509 certificate for the Web Services Security X.509 Certificate Token Profile.
      static java.lang.String INCLUSION_METHOD_ISSUERSERIALNUMBER
      Constant attribute that identifies the issuer and serial number inclusion mode (X509IssuerSerial) of the X.509 certificate for the Web Services Security X.509 Certificate Token Profile.
      static java.lang.String SAML_HOLDER_OF_KEY
      Constant attribute that identifies the holder-of-key mandatory subject confirmation method for the Web Services Security SAML Token Profile.
      static java.lang.String SAML_SENDER_VOUCHEZ
      Constant attribute that identifies the sender-vouchez mandatory subject confirmation method for the Web Services Security SAML Token Profile.
      static java.lang.String TAG_ALIAS
      Constant attribute that identifies the tag to replace with the alias of the symmetric key to encrypt the SOAP requests.
      static java.lang.String TAG_ENCRYPT
      Constant attribute that identifies the tag to replace with the value of the symmetric key to encrypt the SOAP requests.
      static java.lang.String TAG_PASSWORD
      Constant attribute that identifies the tag to replace with the value of the password to secure the SOAP requests with UsernameToken.
      static java.lang.String TAG_REFERENCE_TYPE
      Constant attribute that identifies the tag to replace with the inclusion mode of the certificate used to secure the SOAP requests with X.509 Certificate Token.
      static java.lang.String TAG_USER
      Constant attribute that identifies the tag to replace with the value of the user to secure the SOAP requests with UsernameToken.
      static java.lang.String XML_SAMLTOKEN_HOK
      Constant attribute that represents the security header to secure the SOAP requests with SAML Token (holder-of-key).
      static java.lang.String XML_SAMLTOKEN_SV
      Constant attribute that represents the security header to secure the SOAP requests with SAML Token (sender-vouchez).
      static java.lang.String XML_SYMMETRIC_KEY
      Constant attribute that represents the tag to encrypt the SOAP requests with symmetric key.
      static java.lang.String XML_USERNAMETOKEN
      Constant attribute that represents the security header to secure the SOAP requests with UsernameToken.
      static java.lang.String XML_X509CERTIFICATETOKEN
      Constant attribute that represents the security header to secure the SOAP requests with X.509 Certificate Token.
      static java.lang.String XML_XWSS
      Constant attribute that represents the security header to secure the SOAP messages.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.InputStream generateInputStream​(java.lang.String xmlInput)
      Method that obtains an InputStream from a String.
      static java.io.InputStream generateXMLSAMLToken​(java.lang.String mandatorySubjectConfirmationMethod, boolean useSymmetricKey, java.lang.String symmetricKeyAlias)
      Method that obtains an InputStream as the security header to secure a SOAP message with SAML Token.
      static java.io.InputStream generateXMLUserNameToken​(java.lang.String userName, java.lang.String userPassword, boolean useSymmetricKey, java.lang.String symmetricKeyAlias)
      Method that obtains an InputStream as the security header to secure a SOAP message with UsernameToken.
      static java.io.InputStream generateXMLX509CertificateToken​(java.lang.String certificateInclussionMode, boolean useSymmetricKey, java.lang.String symmetricKeyAlias)
      Method that obtains an InputStream as the security header to secure a SOAP message with X.509 Certificate Token.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • AUTHENTICATION_USER_PASSWORD

        public static final java.lang.String AUTHENTICATION_USER_PASSWORD
        Constant attribute that identifies the Web Services Security UsernameToken Profile, used to secure the SOAP messages.
        See Also:
        Constant Field Values
      • AUTHENTICATION_CERTIFICATE

        public static final java.lang.String AUTHENTICATION_CERTIFICATE
        Constant attribute that identifies the Web Services Security X.509 Certificate Token Profile, used to secure the SOAP messages.
        See Also:
        Constant Field Values
      • AUTHENTICATION_SAML

        public static final java.lang.String AUTHENTICATION_SAML
        Constant attribute that identifies the Web Services Security SAML Token Profile, used to secure the SOAP messages.
        See Also:
        Constant Field Values
      • INCLUSION_METHOD_DIRECT

        public static final java.lang.String INCLUSION_METHOD_DIRECT
        Constant attribute that identifies the direct inclusion mode (BinarySecurityToken) of the X.509 certificate for the Web Services Security X.509 Certificate Token Profile.
        See Also:
        Constant Field Values
      • INCLUSION_METHOD_IDENTIFIER

        public static final java.lang.String INCLUSION_METHOD_IDENTIFIER
        Constant attribute that identifies the subject key identifier inclusion mode (KeyIdentifier) of the X.509 certificate for the Web Services Security X.509 Certificate Token Profile.
        See Also:
        Constant Field Values
      • INCLUSION_METHOD_ISSUERSERIALNUMBER

        public static final java.lang.String INCLUSION_METHOD_ISSUERSERIALNUMBER
        Constant attribute that identifies the issuer and serial number inclusion mode (X509IssuerSerial) of the X.509 certificate for the Web Services Security X.509 Certificate Token Profile.
        See Also:
        Constant Field Values
      • SAML_HOLDER_OF_KEY

        public static final java.lang.String SAML_HOLDER_OF_KEY
        Constant attribute that identifies the holder-of-key mandatory subject confirmation method for the Web Services Security SAML Token Profile.
        See Also:
        Constant Field Values
      • SAML_SENDER_VOUCHEZ

        public static final java.lang.String SAML_SENDER_VOUCHEZ
        Constant attribute that identifies the sender-vouchez mandatory subject confirmation method for the Web Services Security SAML Token Profile.
        See Also:
        Constant Field Values
      • TAG_ENCRYPT

        public static final java.lang.String TAG_ENCRYPT
        Constant attribute that identifies the tag to replace with the value of the symmetric key to encrypt the SOAP requests.
        See Also:
        Constant Field Values
      • TAG_USER

        public static final java.lang.String TAG_USER
        Constant attribute that identifies the tag to replace with the value of the user to secure the SOAP requests with UsernameToken.
        See Also:
        Constant Field Values
      • TAG_PASSWORD

        public static final java.lang.String TAG_PASSWORD
        Constant attribute that identifies the tag to replace with the value of the password to secure the SOAP requests with UsernameToken.
        See Also:
        Constant Field Values
      • TAG_ALIAS

        public static final java.lang.String TAG_ALIAS
        Constant attribute that identifies the tag to replace with the alias of the symmetric key to encrypt the SOAP requests.
        See Also:
        Constant Field Values
      • TAG_REFERENCE_TYPE

        public static final java.lang.String TAG_REFERENCE_TYPE
        Constant attribute that identifies the tag to replace with the inclusion mode of the certificate used to secure the SOAP requests with X.509 Certificate Token.
        See Also:
        Constant Field Values
      • XML_USERNAMETOKEN

        public static final java.lang.String XML_USERNAMETOKEN
        Constant attribute that represents the security header to secure the SOAP requests with UsernameToken.
        See Also:
        Constant Field Values
      • XML_SYMMETRIC_KEY

        public static final java.lang.String XML_SYMMETRIC_KEY
        Constant attribute that represents the tag to encrypt the SOAP requests with symmetric key.
        See Also:
        Constant Field Values
      • XML_X509CERTIFICATETOKEN

        public static final java.lang.String XML_X509CERTIFICATETOKEN
        Constant attribute that represents the security header to secure the SOAP requests with X.509 Certificate Token.
        See Also:
        Constant Field Values
      • XML_SAMLTOKEN_HOK

        public static final java.lang.String XML_SAMLTOKEN_HOK
        Constant attribute that represents the security header to secure the SOAP requests with SAML Token (holder-of-key).
        See Also:
        Constant Field Values
      • XML_SAMLTOKEN_SV

        public static final java.lang.String XML_SAMLTOKEN_SV
        Constant attribute that represents the security header to secure the SOAP requests with SAML Token (sender-vouchez).
        See Also:
        Constant Field Values
      • XML_XWSS

        public static final java.lang.String XML_XWSS
        Constant attribute that represents the security header to secure the SOAP messages.
        See Also:
        Constant Field Values
    • Method Detail

      • generateXMLUserNameToken

        public static java.io.InputStream generateXMLUserNameToken​(java.lang.String userName,
                                                                   java.lang.String userPassword,
                                                                   boolean useSymmetricKey,
                                                                   java.lang.String symmetricKeyAlias)
        Method that obtains an InputStream as the security header to secure a SOAP message with UsernameToken.
        Parameters:
        userName - Parameter that represents the user name.
        userPassword - Parameter that represents the user password.
        useSymmetricKey - Parameter that indicates if to use symmetric key to encrypt the SOAP message (true), or not (false).
        symmetricKeyAlias - Parameter that represents the alias of the symmetric key used to encrypt the SOAP message.
        Returns:
        the InputStream as the security header to secure a SOAP message with UsernameToken.
      • generateXMLX509CertificateToken

        public static java.io.InputStream generateXMLX509CertificateToken​(java.lang.String certificateInclussionMode,
                                                                          boolean useSymmetricKey,
                                                                          java.lang.String symmetricKeyAlias)
        Method that obtains an InputStream as the security header to secure a SOAP message with X.509 Certificate Token.
        Parameters:
        certificateInclussionMode - Parameter that represents the certificate inclusion mode.
        useSymmetricKey - Parameter that indicates if to use symmetric key to encrypt the SOAP message (true), or not (false).
        symmetricKeyAlias - Parameter that represents the alias of the symmetric key used to encrypt the SOAP message.
        Returns:
        the InputStream as the security header to secure a SOAP message with X.509 Certificate Token.
      • generateXMLSAMLToken

        public static java.io.InputStream generateXMLSAMLToken​(java.lang.String mandatorySubjectConfirmationMethod,
                                                               boolean useSymmetricKey,
                                                               java.lang.String symmetricKeyAlias)
        Method that obtains an InputStream as the security header to secure a SOAP message with SAML Token.
        Parameters:
        mandatorySubjectConfirmationMethod - Parameter that represents the mandatory subject confirmation method.
        useSymmetricKey - Parameter that indicates if to use symmetric key to encrypt the SOAP message (true), or not (false).
        symmetricKeyAlias - Parameter that represents the alias of the symmetric key used to encrypt the SOAP message.
        Returns:
        the InputStream as the security header to secure a SOAP message with SAML Token.
      • generateInputStream

        public static java.io.InputStream generateInputStream​(java.lang.String xmlInput)
        Method that obtains an InputStream from a String.
        Parameters:
        xmlInput - Parameter that represents the source String.
        Returns:
        the generated InputStream.