Class SAML2SDKUtils

    • Constructor Detail

      • SAML2SDKUtils

        protected SAML2SDKUtils()
        Protected contstructor.
    • Method Detail

      • getObjectInstance

        public static Object getObjectInstance​(String iName)
        Returns default object instance for a given interface.
        Parameters:
        iName - name of the interface.
        Returns:
        object instance corresponding to the interface implementation. return null if the object instance could not be obtained.
      • getObjectInstance

        public static Object getObjectInstance​(String iName,
                                               String value)
        Returns new object instance taking String parameter in constructor.
        Parameters:
        iName - name of the interface.
        value - String value to be used as parameter in constructor.
        Returns:
        object instance corresponding to the interface implementation. return null if the object instance could not be obtained.
      • getObjectInstance

        public static Object getObjectInstance​(String iName,
                                               Element value)
        Returns new object instance taking Element parameter in constructor.
        Parameters:
        iName - name of the interface.
        value - Element value to be used as parameter in constructor.
        Returns:
        object instance corresponding to the interface implementation. return null if the object instance could not be obtained.
      • getObjectInstance

        public static Object getObjectInstance​(String iName,
                                               byte[] typecode,
                                               int endpointIndex,
                                               String sourceID,
                                               String messageHandle)
        Returns new object instance with given parameters.
        Parameters:
        iName - name of the interface.
        typecode - type code.
        endpointIndex - end point index.
        sourceID - source ID.
        messageHandle - message handler.
        Returns:
        object instance corresponding to the interface implementation. return null if the object instance could not be obtained.
      • checkStatement

        public static boolean checkStatement​(Element element,
                                             String statementname)
        Verifies if an element is a type of a specific statement. Currently, this method is used by class AuthnStatementImpl, AuthzDecisionStatement and AttributeStatementImpl.
        Parameters:
        element - a DOM Element which needs to be verified.
        statementname - A specific name of a statement, for example, AuthnStatement, AuthzStatement or AttributeStatement
        Returns:
        true if the element is of the specific type; false otherwise.
      • byteArrayToString

        public static String byteArrayToString​(byte[] bytes)
        Converts byte array to String.
        Parameters:
        bytes - Byte Array to be converted.
        Returns:
        result of the conversion.
      • intToTwoBytes

        public static byte[] intToTwoBytes​(int i)
                                    throws SAML2Exception
        Converts integer to byte array.
        Parameters:
        i - an integer value between 0 and 65535.
        Returns:
        a byte array whose length is 2.
        Throws:
        SAML2Exception - if the input is not between 0 and 65535.
      • twoBytesToInt

        public static int twoBytesToInt​(byte[] bytes)
                                 throws SAML2Exception
        Converts two bytes to an integer.
        Parameters:
        bytes - byte array whose length is 2.
        Returns:
        an integer value between 0 and 65535.
        Throws:
        SAML2Exception - if the input is null or the length is not 2.
      • generateMessageHandle

        public static String generateMessageHandle()
        Generates message handle used in an Artifact.
        Returns:
        String format of 20-byte sequence identifying a message.
      • stringToByteArray

        public static byte[] stringToByteArray​(String input)
        Converts String to Byte Array.
        Parameters:
        input - String to be converted.
        Returns:
        result of the conversion.
      • byteArrayToHexString

        @Deprecated(since="7.3.0")
        public static String byteArrayToHexString​(byte[] byteArray)
        Deprecated.
        This method is deprecated, use Hex.encode(byte[])} instead. Converts byte array to Hex String.
        Parameters:
        byteArray - Byte Array to be converted.
        Returns:
        result of the conversion.
      • hexStringToByteArray

        @Deprecated(since="7.3.0")
        public static byte[] hexStringToByteArray​(String hexString)
        Deprecated.
        This method is deprecated, use Hex.decode(String) instead. Converts Hex String to Byte Array.
        Parameters:
        hexString - Hex String to be converted.
        Returns:
        result of the conversion.
      • generateID

        public static String generateID()
        Generates ID.
        Returns:
        ID value.
      • createSOAPMessageString

        public static String createSOAPMessageString​(String xmlString)
                                              throws javax.xml.soap.SOAPException,
                                                     SAML2Exception
        Creates SOAPMessage with the input XML String as message body.
        Parameters:
        xmlString - XML string to be put into SOAPMessage body.
        Returns:
        newly created SOAPMessage.
        Throws:
        javax.xml.soap.SOAPException - if it cannot create the SOAPMessage.
        SAML2Exception
      • fillInBasicAuthInfo

        public static String fillInBasicAuthInfo​(javax.xml.bind.JAXBElement<com.sun.identity.saml2.jaxb.entityconfig.BaseConfigType> config,
                                                 String locationURL)
        Fills in basic auth user and password inside the location URL if configuration is done properly
        Parameters:
        config - Either an SPSSOConfigElement object , an IDPSSOConfigElement object or PEPConfigElement.
        locationURL - The original location URL which is to be inserted with user:password@ before the hostname part and after //
        Returns:
        The modified location URL with the basic auth user and password if configured properly
      • StringToBoolean

        public static Boolean StringToBoolean​(String str)
                                       throws SAML2Exception
        Converts a value of XML boolean type to Boolean object.
        Parameters:
        str - a value of XML boolean type
        Returns:
        a Boolean object.
        Throws:
        SAML2Exception - if there is a syntax error
      • removeDeployUri

        public static String removeDeployUri​(String uri)
        Removes deployment URI from the pass down string. i.e. from "/opensso/ArtifactResolver/metaAlias/idp" to "/ArtifactResolver/metaAlias/idp".
        Parameters:
        uri - the URI string which the deployment uri is to be removed return string without deployment uri
      • booleanValueOf

        public static Boolean booleanValueOf​(String value)
        Returns the boolean value as a Boolean object.
        Parameters:
        value - boolean value true or false.
      • decodeXMLToDebugLog

        public static void decodeXMLToDebugLog​(String callerName,
                                               Element xmlElement)
        If enabled, decodes the provided XML element and prints it out to the decryption debug log.
        Parameters:
        callerName - String representing the name of the calling method.
        xmlElement - String representing an XML document with decrypted data.
      • isSAMLDecryptionDebugEnabled

        public static boolean isSAMLDecryptionDebugEnabled()
        Tells whether SAML SP decryption debug mode is enabled.
        Returns:
        true if SAML decryption debug mode is enabled, or false otherwise or if the property is not found.