Class Saml2ErrorStatusException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.security.core.AuthenticationException
se.swedenconnect.spring.saml.idp.error.Saml2ErrorStatusException
All Implemented Interfaces:
Serializable

public class Saml2ErrorStatusException extends org.springframework.security.core.AuthenticationException
Exception class that when thrown will lead to a SAML error status message being sent.

A message source code, and optionally parameters, may be supplied. This message code is resolved into a text that is used as the Status status message.

Author:
Martin Lindström
See Also:
  • Constructor Details

    • Saml2ErrorStatusException

      public Saml2ErrorStatusException(Saml2ErrorStatus status)
      Constructor.
      Parameters:
      status - the Saml2ErrorStatus
    • Saml2ErrorStatusException

      public Saml2ErrorStatusException(Saml2ErrorStatus status, String msg)
      Constructor.
      Parameters:
      status - the Saml2ErrorStatus
      msg - the error message (will not be included in the resulting Status message)
    • Saml2ErrorStatusException

      public Saml2ErrorStatusException(Saml2ErrorStatus status, Throwable cause)
      Constructor.
      Parameters:
      status - the Saml2ErrorStatus
      cause - the cause of the error
    • Saml2ErrorStatusException

      public Saml2ErrorStatusException(Saml2ErrorStatus status, String msg, Throwable cause)
      Constructor.
      Parameters:
      status - the Saml2ErrorStatus
      msg - the error message (will not be included in the resulting Status message)
      cause - the cause of the error
    • Saml2ErrorStatusException

      public Saml2ErrorStatusException(String statusCode, String subStatusCode, String statusMessageCode, String defaultStatusMessage)
      Constructor.
      Parameters:
      statusCode - the main status code
      subStatusCode - the subordinate status code
      statusMessageCode - the status message code (will be resolved against a MessageSource)
      defaultStatusMessage - the status message to use if the statusMessageCode can not be resolved against a MessageSource
    • Saml2ErrorStatusException

      public Saml2ErrorStatusException(String statusCode, String subStatusCode, String statusMessageCode, String defaultStatusMessage, String msg)
      Constructor.
      Parameters:
      statusCode - the main status code
      subStatusCode - the subordinate status code
      statusMessageCode - the status message code (will be resolved against a MessageSource
      defaultStatusMessage - the status message to use if the statusMessageCode can not be resolved against a MessageSource
      msg - the error message (will not be included in the resulting Status message)
    • Saml2ErrorStatusException

      public Saml2ErrorStatusException(String statusCode, String subStatusCode, String statusMessageCode, String defaultStatusMessage, Throwable cause)
      Constructor.
      Parameters:
      statusCode - the main status code
      subStatusCode - the subordinate status code
      statusMessageCode - the status message code (will be resolved against a MessageSource
      defaultStatusMessage - the status message to use if the statusMessageCode can not be resolved against a MessageSource
      cause - the cause of the error
    • Saml2ErrorStatusException

      public Saml2ErrorStatusException(String statusCode, String subStatusCode, String statusMessageCode, String defaultStatusMessage, String msg, Throwable cause)
      Constructor.
      Parameters:
      statusCode - the main status code
      subStatusCode - the subordinate status code
      statusMessageCode - the status message code (will be resolved against a MessageSource
      defaultStatusMessage - the status message to use if the statusMessageCode can not be resolved against a MessageSource
      msg - the error message (will not be included in the resulting Status message)
      cause - the cause of the error
  • Method Details

    • setCustomStatusMessage

      public void setCustomStatusMessage(String statusMessageCode, String defaultStatusMessage)
      Assigns a custom status message. May be used if the exception object is initialized using a Saml2ErrorStatus object.
      Parameters:
      statusMessageCode - the status message code (for resolving against a MessageSource
      defaultStatusMessage - the default status message (if resolving fails)
    • setCustomStatusMessage

      public void setCustomStatusMessage(String statusMessage)
      Assigns a custom status message. If a MessageSource is being used when obtaining the Status use setCustomStatusMessage(String, String) instead.
      Parameters:
      statusMessage - the status message
    • getStatus

      public org.opensaml.saml.saml2.core.Status getStatus()
      Gets a SAML v2 Status element given this exception.
      Returns:
      a Status element
    • getStatus

      public org.opensaml.saml.saml2.core.Status getStatus(MessageSource messageSource, Locale locale)
      Gets a SAML v2 Status element given this exception.
      Parameters:
      messageSource - the message source to use when resolving the status message (if null, the defaultStatusMessage will be used)
      locale - the locale to use when resolving the status message
      Returns:
      a Status element
    • toString

      public String toString()
      Overrides:
      toString in class Throwable