Class AuthnRequest


  • public class AuthnRequest
    extends java.lang.Object
    AuthNRequest class of OneLogin's Java Toolkit. A class that implements SAML 2 Authentication Request
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
        Private property to construct a logger for this class.
      • authnRequestString

        private final java.lang.String authnRequestString
        SAML AuthNRequest string
      • id

        private final java.lang.String id
        SAML AuthNRequest ID.
      • issueInstant

        private final java.util.Calendar issueInstant
        Time stamp that indicates when the AuthNRequest was created
    • Constructor Detail

      • AuthnRequest

        @Deprecated
        public AuthnRequest​(Saml2Settings settings,
                            boolean forceAuthn,
                            boolean isPassive,
                            boolean setNameIdPolicy,
                            java.lang.String nameIdValueReq)
        Constructs the AuthnRequest object.
        Parameters:
        settings - OneLogin_Saml2_Settings
        forceAuthn - When true the AuthNReuqest will set the ForceAuthn='true'
        isPassive - When true the AuthNReuqest will set the IsPassive='true'
        setNameIdPolicy - When true the AuthNReuqest will set a nameIdPolicy
        nameIdValueReq - Indicates to the IdP the subject that should be authenticated
      • AuthnRequest

        @Deprecated
        public AuthnRequest​(Saml2Settings settings,
                            boolean forceAuthn,
                            boolean isPassive,
                            boolean setNameIdPolicy)
        Constructs the AuthnRequest object.
        Parameters:
        settings - OneLogin_Saml2_Settings
        forceAuthn - When true the AuthNReuqest will set the ForceAuthn='true'
        isPassive - When true the AuthNReuqest will set the IsPassive='true'
        setNameIdPolicy - When true the AuthNReuqest will set a nameIdPolicy
      • AuthnRequest

        public AuthnRequest​(Saml2Settings settings,
                            AuthnRequestParams params)
        Constructs the AuthnRequest object.
        Parameters:
        settings - OneLogin_Saml2_Settings
        params - a set of authentication request input parameters that shape the request to create
    • Method Detail

      • postProcessXml

        protected java.lang.String postProcessXml​(java.lang.String authnRequestXml,
                                                  AuthnRequestParams params,
                                                  Saml2Settings settings)
        Allows for an extension class to post-process the AuthnRequest XML generated for this request, in order to customize the result.

        This method is invoked at construction time, after all the other fields of this class have already been initialised. Its default implementation simply returns the input XML as-is, with no change.

        Parameters:
        authnRequestXml - the XML produced for this AuthnRequest by the standard implementation provided by AuthnRequest
        params - the authentication request input parameters
        settings - the settings
        Returns:
        the post-processed XML for this AuthnRequest, which will then be returned by any call to getAuthnRequestXml()
      • getEncodedAuthnRequest

        public java.lang.String getEncodedAuthnRequest​(java.lang.Boolean deflated)
                                                throws java.io.IOException
        Parameters:
        deflated - If deflated or not the encoded AuthnRequest
        Returns:
        the base64 encoded unsigned AuthnRequest (deflated or not)
        Throws:
        java.io.IOException
      • getEncodedAuthnRequest

        public java.lang.String getEncodedAuthnRequest()
                                                throws java.io.IOException
        Returns:
        base64 encoded, unsigned AuthnRequest (deflated or not)
        Throws:
        java.io.IOException
      • getAuthnRequestXml

        public java.lang.String getAuthnRequestXml()
        Returns:
        unsigned plain-text AuthnRequest.
      • generateSubstitutor

        private org.apache.commons.lang3.text.StrSubstitutor generateSubstitutor​(AuthnRequestParams params,
                                                                                 Saml2Settings settings)
        Substitutes AuthnRequest variables within a string by values.
        Parameters:
        params - the authentication request input parameters
        settings - Saml2Settings object. Setting data
        Returns:
        the StrSubstitutor object of the AuthnRequest
      • getAuthnRequestTemplate

        private static java.lang.StringBuilder getAuthnRequestTemplate()
        Returns:
        the AuthnRequest's template
      • getId

        public java.lang.String getId()
        Returns:
        the generated id of the AuthnRequest message
      • getIssueInstant

        public java.util.Calendar getIssueInstant()
        Returns the issue instant of this message.
        Returns:
        a new Calendar instance carrying the issue instant of this message