Class LogoutRequest

java.lang.Object
com.onelogin.saml2.logout.LogoutRequest

public class LogoutRequest extends Object
LogoutRequest class of OneLogin's Java Toolkit. A class that implements SAML 2 Logout Request builder/parser/validator
  • Field Details

    • LOGGER

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

      private final String logoutRequestString
      SAML LogoutRequest string
    • id

      public String id
      SAML LogoutRequest ID.
    • settings

      private final Saml2Settings settings
      Settings data.
    • request

      private final HttpRequest request
      HttpRequest object to be processed (Contains GET and POST parameters, request URL, ...).
    • currentUrl

      private String currentUrl
      URL of the current host + current view
    • issueInstant

      private Calendar issueInstant
      Time when the Logout Request was created
    • validationException

      private Exception validationException
      After validation, if it fails this property has the cause of the problem
  • Constructor Details

  • Method Details

    • postProcessXml

      protected String postProcessXml(String logoutRequestXml, LogoutRequestParams params, Saml2Settings settings)
      Allows for an extension class to post-process the LogoutRequest XML generated for this request, in order to customize the result.

      This method is invoked at construction time when no existing LogoutRequest message is found in the HTTP request (and hence in the logout request sending scenario only), 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:
      logoutRequestXml - the XML produced for this LogoutRequest by the standard implementation provided by LogoutRequest
      params - the logout request input parameters
      settings - the settings
      Returns:
      the post-processed XML for this LogoutRequest, which will then be returned by any call to getLogoutRequestXml()
    • getEncodedLogoutRequest

      public String getEncodedLogoutRequest(Boolean deflated) throws IOException
      Parameters:
      deflated - If deflated or not the encoded Logout Request
      Returns:
      the base64 encoded unsigned Logout Request (deflated or not)
      Throws:
      IOException
    • getEncodedLogoutRequest

      public String getEncodedLogoutRequest() throws IOException
      Returns:
      the base64 encoded unsigned Logout Request (deflated or not)
      Throws:
      IOException
    • getLogoutRequestXml

      public String getLogoutRequestXml()
      Returns:
      the plain XML Logout Request
    • generateSubstitutor

      private org.apache.commons.lang3.text.StrSubstitutor generateSubstitutor(LogoutRequestParams params, Saml2Settings settings)
      Substitutes LogoutRequest variables within a string by values.
      Parameters:
      params - the logout request input parameters
      settings - Saml2Settings object. Setting data
      Returns:
      the StrSubstitutor object of the LogoutRequest
    • getLogoutRequestTemplate

      private static StringBuilder getLogoutRequestTemplate()
      Returns:
      the LogoutRequest's template
    • isValid

      public Boolean isValid()
      Determines if the SAML LogoutRequest is valid or not
      Returns:
      true if the SAML LogoutRequest is valid
    • getId

      public static String getId(Document samlLogoutRequestDocument)
      Returns the ID of the Logout Request Document.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      Returns:
      the ID of the Logout Request.
    • getIssueInstant

      public static Calendar getIssueInstant(Document samlLogoutRequestDocument)
      Returns the issue instant of the Logout Request Document.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      Returns:
      the issue instant of the Logout Request.
    • getId

      public static String getId(String samlLogoutRequestString)
      Returns the ID of the Logout Request String.
      Parameters:
      samlLogoutRequestString - A Logout Request string.
      Returns:
      the ID of the Logout Request.
    • getIssueInstant

      public static Calendar getIssueInstant(String samlLogoutRequestString)
      Returns the issue instant of the Logout Request Document.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      Returns:
      the issue instant of the Logout Request.
    • getNameIdData

      public static Map<String,String> getNameIdData(Document samlLogoutRequestDocument, PrivateKey key) throws Exception
      Gets the NameID Data from the the Logout Request Document.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      key - The SP key to decrypt the NameID if encrypted
      Returns:
      the Name ID Data (Value, Format, NameQualifier, SPNameQualifier)
      Throws:
      Exception
    • getNameIdData

      public static Map<String,String> getNameIdData(Document samlLogoutRequestDocument, PrivateKey key, boolean trimValue) throws Exception
      Gets the NameID Data from the the Logout Request Document.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      key - The SP key to decrypt the NameID if encrypted
      trimValue - whether the extracted Name ID value should be trimmed
      Returns:
      the Name ID Data (Value, Format, NameQualifier, SPNameQualifier)
      Throws:
      Exception
    • getNameIdData

      public static Map<String,String> getNameIdData(String samlLogoutRequestString, PrivateKey key) throws Exception
      Gets the NameID Data from the the Logout Request String.
      Parameters:
      samlLogoutRequestString - A DOMDocument object loaded from the SAML Logout Request.
      key - The SP key to decrypt the NameID if encrypted
      Returns:
      the Name ID Data (Value, Format, NameQualifier, SPNameQualifier)
      Throws:
      Exception
    • getNameIdData

      public static Map<String,String> getNameIdData(String samlLogoutRequestString, PrivateKey key, boolean trimValue) throws Exception
      Gets the NameID Data from the the Logout Request String.
      Parameters:
      samlLogoutRequestString - A DOMDocument object loaded from the SAML Logout Request.
      key - The SP key to decrypt the NameID if encrypted
      trimValue - whether the extracted Name ID value should be trimmed
      Returns:
      the Name ID Data (Value, Format, NameQualifier, SPNameQualifier)
      Throws:
      Exception
    • getNameId

      public static String getNameId(Document samlLogoutRequestDocument, PrivateKey key) throws Exception
      Gets the NameID value provided from the SAML Logout Request Document.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      key - The SP key to decrypt the NameID if encrypted
      Returns:
      the Name ID value
      Throws:
      Exception
    • getNameId

      public static String getNameId(Document samlLogoutRequestDocument, PrivateKey key, boolean trimValue) throws Exception
      Gets the NameID value provided from the SAML Logout Request Document.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      key - The SP key to decrypt the NameID if encrypted
      trimValue - whether the extracted Name ID value should be trimmed
      Returns:
      the Name ID value
      Throws:
      Exception
    • getNameId

      public static String getNameId(Document samlLogoutRequestDocument) throws Exception
      Gets the NameID value provided from the SAML Logout Request Document.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      Returns:
      the Name ID value
      Throws:
      Exception
    • getNameId

      public static String getNameId(String samlLogoutRequestString, PrivateKey key) throws Exception
      Gets the NameID value provided from the SAML Logout Request String.
      Parameters:
      samlLogoutRequestString - A Logout Request string.
      key - The SP key to decrypt the NameID if encrypted
      Returns:
      the Name ID value
      Throws:
      Exception
    • getNameId

      public static String getNameId(String samlLogoutRequestString, PrivateKey key, boolean trimValue) throws Exception
      Gets the NameID value provided from the SAML Logout Request String.
      Parameters:
      samlLogoutRequestString - A Logout Request string.
      key - The SP key to decrypt the NameID if encrypted
      trimValue - whether the extracted Name ID value should be trimmed
      Returns:
      the Name ID value
      Throws:
      Exception
    • getNameId

      public static String getNameId(String samlLogoutRequestString) throws Exception
      Gets the NameID value provided from the SAML Logout Request String.
      Parameters:
      samlLogoutRequestString - A Logout Request string.
      Returns:
      the Name ID value
      Throws:
      Exception
    • getIssuer

      public static String getIssuer(Document samlLogoutRequestDocument) throws XPathExpressionException
      Gets the Issuer from Logout Request Document.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      Returns:
      the issuer of the logout request
      Throws:
      XPathExpressionException
    • getIssuer

      public static String getIssuer(Document samlLogoutRequestDocument, boolean trim) throws XPathExpressionException
      Gets the Issuer from Logout Request Document.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      trim - whether the extracted issuer value should be trimmed
      Returns:
      the issuer of the logout request
      Throws:
      XPathExpressionException
    • getIssuer

      public static String getIssuer(String samlLogoutRequestString) throws XPathExpressionException
      Gets the Issuer from Logout Request String.
      Parameters:
      samlLogoutRequestString - A Logout Request string.
      Returns:
      the issuer of the logout request
      Throws:
      XPathExpressionException
    • getIssuer

      public static String getIssuer(String samlLogoutRequestString, boolean trim) throws XPathExpressionException
      Gets the Issuer from Logout Request String.
      Parameters:
      samlLogoutRequestString - A Logout Request string.
      trim - whether the extracted issuer value should be trimmed
      Returns:
      the issuer of the logout request
      Throws:
      XPathExpressionException
    • getSessionIndexes

      public static List<String> getSessionIndexes(Document samlLogoutRequestDocument) throws XPathExpressionException
      Gets the SessionIndexes from the LogoutRequest.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      Returns:
      the SessionIndexes
      Throws:
      XPathExpressionException
    • getSessionIndexes

      public static List<String> getSessionIndexes(Document samlLogoutRequestDocument, boolean trim) throws XPathExpressionException
      Gets the SessionIndexes from the LogoutRequest.
      Parameters:
      samlLogoutRequestDocument - A DOMDocument object loaded from the SAML Logout Request.
      trim - whether the extracted session indexes should be trimmed
      Returns:
      the SessionIndexes
      Throws:
      XPathExpressionException
    • getSessionIndexes

      public static List<String> getSessionIndexes(String samlLogoutRequestString) throws XPathExpressionException
      Gets the SessionIndexes from the LogoutRequest.
      Parameters:
      samlLogoutRequestString - A Logout Request string.
      Returns:
      the SessionIndexes
      Throws:
      XPathExpressionException
    • getSessionIndexes

      public static List<String> getSessionIndexes(String samlLogoutRequestString, boolean trim) throws XPathExpressionException
      Gets the SessionIndexes from the LogoutRequest.
      Parameters:
      samlLogoutRequestString - A Logout Request string.
      trim - whether the extracted session indexes should be trimmed
      Returns:
      the SessionIndexes
      Throws:
      XPathExpressionException
    • getError

      public String getError()
      After execute a validation process, if fails this method returns the cause
      Returns:
      the cause of the validation error
    • getValidationException

      public Exception getValidationException()
      After execute a validation process, if fails this method returns the Exception object
      Returns:
      the cause of the validation error
    • setValidationException

      protected void setValidationException(Exception validationException)
      Sets the validation exception that this LogoutRequest should return when a validation error occurs.
      Parameters:
      validationException - the validation exception to set
    • getId

      public String getId()
      Returns:
      the ID of the Logout Request
    • getIssueInstant

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