ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
sspmod_saml_Error Class Reference
+ Inheritance diagram for sspmod_saml_Error:
+ Collaboration diagram for sspmod_saml_Error:

Public Member Functions

 __construct ($status, $subStatus=null, $statusMessage=null, Exception $cause=null)
 Create a SAML 2 error. More...
 
 getStatus ()
 Get the top-level status code. More...
 
 getSubStatus ()
 Get the second-level status code. More...
 
 getStatusMessage ()
 Get the status message. More...
 
 toException ()
 Create a normal exception from a SAML2 error. More...
 
- Public Member Functions inherited from SimpleSAML_Error_Exception
 __construct ($message, $code=0, Exception $cause=null)
 Constructor for this error. More...
 
 getBacktrace ()
 Retrieve the backtrace. More...
 
 getCause ()
 Retrieve the cause of this exception. More...
 
 getClass ()
 Retrieve the class of this exception. More...
 
 format ($anonymize=false)
 Format this exception for logging. More...
 
 formatBacktrace ($anonymize=false)
 Format the backtrace for logging. More...
 
 log ($default_level)
 Print the exception to the log, by default with log level error. More...
 
 logError ()
 Print the exception to the log with log level error. More...
 
 logWarning ()
 Print the exception to the log with log level warning. More...
 
 logInfo ()
 Print the exception to the log with log level info. More...
 
 logDebug ()
 Print the exception to the log with log level debug. More...
 
 __sleep ()
 Function for serialization. More...
 

Static Public Member Functions

static fromException (Exception $exception)
 Create a SAML2 error from an exception. More...
 
- Static Public Member Functions inherited from SimpleSAML_Error_Exception
static fromException (Exception $e)
 Convert any exception into a SimpleSAML_Error_Exception. More...
 

Static Private Member Functions

static shortStatus ($status)
 Create a short version of the status code. More...
 

Private Attributes

 $status
 
 $subStatus
 
 $statusMessage
 

Additional Inherited Members

- Protected Member Functions inherited from SimpleSAML_Error_Exception
 initBacktrace (Exception $exception)
 Load the backtrace from the given exception. More...
 
 logBacktrace ($level=\SimpleSAML\Logger::DEBUG)
 Print the backtrace to the log if the 'debug' option is enabled in the configuration. More...
 

Detailed Description

Definition at line 8 of file Error.php.

Constructor & Destructor Documentation

◆ __construct()

sspmod_saml_Error::__construct (   $status,
  $subStatus = null,
  $statusMessage = null,
Exception  $cause = null 
)

Create a SAML 2 error.

Parameters
string$statusThe top-level status code.
string | null$subStatusThe second-level status code. Can be NULL, in which case there is no second-level status code.
string | null$statusMessageThe status message. Can be NULL, in which case there is no status message.
Exception | null$causeThe cause of this exception. Can be NULL.

Definition at line 40 of file Error.php.

References SimpleSAML_Error_Exception\$cause, $status, $statusMessage, and $subStatus.

41  {
42  assert(is_string($status));
43  assert($subStatus === null || is_string($subStatus));
44  assert($statusMessage === null || is_string($statusMessage));
45 
46  $st = self::shortStatus($status);
47  if ($subStatus !== null) {
48  $st .= '/' . self::shortStatus($subStatus);
49  }
50  if ($statusMessage !== null) {
51  $st .= ': ' . $statusMessage;
52  }
53  parent::__construct($st, 0, $cause);
54 
55  $this->status = $status;
56  $this->subStatus = $subStatus;
57  $this->statusMessage = $statusMessage;
58  }

Member Function Documentation

◆ fromException()

static sspmod_saml_Error::fromException ( Exception  $exception)
static

Create a SAML2 error from an exception.

This function attempts to create a SAML2 error with the appropriate status codes from an arbitrary exception.

Parameters
Exception$exceptionThe original exception.
Returns
sspmod_saml_Error The new exception.

Definition at line 103 of file Error.php.

References SAML2\Constants\STATUS_NO_PASSIVE, SAML2\Constants\STATUS_PROXY_COUNT_EXCEEDED, and SAML2\Constants\STATUS_RESPONDER.

Referenced by sspmod_saml_IdP_SAML2\handleAuthError().

104  {
105  if ($exception instanceof sspmod_saml_Error) {
106  // Return the original exception unchanged
107  return $exception;
108 
109  // TODO: remove this branch in 2.0
110  } elseif ($exception instanceof SimpleSAML_Error_NoPassive) {
111  $e = new self(
114  $exception->getMessage(),
115  $exception
116  );
117  // TODO: remove this branch in 2.0
118  } elseif ($exception instanceof SimpleSAML_Error_ProxyCountExceeded) {
119  $e = new self(
122  $exception->getMessage(),
123  $exception
124  );
125  } else {
126  $e = new self(
128  null,
129  get_class($exception) . ': ' . $exception->getMessage(),
130  $exception
131  );
132  }
133 
134  return $e;
135  }
const STATUS_RESPONDER
The request could not be performed due to an error on the part of the SAML responder or SAML authorit...
Definition: Constants.php:273
Class SimpleSAML_Error_ProxyCountExceeded.
Class SimpleSAML_Error_NoPassive.
Definition: NoPassive.php:12
const STATUS_NO_PASSIVE
Indicates the responding provider cannot authenticate the principal passively, as has been requested...
Definition: Constants.php:323
const STATUS_PROXY_COUNT_EXCEEDED
Indicates that a responding provider cannot authenticate the principal directly and is not permitted ...
Definition: Constants.php:347
+ Here is the caller graph for this function:

◆ getStatus()

sspmod_saml_Error::getStatus ( )

Get the top-level status code.

Returns
string The top-level status code.

Definition at line 66 of file Error.php.

References $status.

67  {
68  return $this->status;
69  }

◆ getStatusMessage()

sspmod_saml_Error::getStatusMessage ( )

Get the status message.

Returns
string|null The status message or NULL if no status message is present.

Definition at line 88 of file Error.php.

References $statusMessage.

89  {
90  return $this->statusMessage;
91  }

◆ getSubStatus()

sspmod_saml_Error::getSubStatus ( )

Get the second-level status code.

Returns
string|null The second-level status code or NULL if no second-level status code is present.

Definition at line 77 of file Error.php.

References $subStatus.

78  {
79  return $this->subStatus;
80  }

◆ shortStatus()

static sspmod_saml_Error::shortStatus (   $status)
staticprivate

Create a short version of the status code.

Remove the 'urn:oasis:names:tc:SAML:2.0:status:'-prefix of status codes if it is present.

Parameters
string$statusThe status code.
Returns
string A shorter version of the status code.

Definition at line 183 of file Error.php.

References $status, and $t.

184  {
185  assert(is_string($status));
186 
187  $t = 'urn:oasis:names:tc:SAML:2.0:status:';
188  if (substr($status, 0, strlen($t)) === $t) {
189  return substr($status, strlen($t));
190  }
191 
192  return $status;
193  }

◆ toException()

sspmod_saml_Error::toException ( )

Create a normal exception from a SAML2 error.

This function attempts to reverse the operation of the fromException() function. If it is unable to create a more specific exception, it will return the current object.

See also
sspmod_saml_Error::fromException()
Returns
SimpleSAML_Error_Exception An exception representing this error.

Definition at line 149 of file Error.php.

150  {
151  $e = null;
152 
153  switch ($this->status) {
154  case \SAML2\Constants::STATUS_RESPONDER:
155  switch ($this->subStatus) {
156  case \SAML2\Constants::STATUS_NO_PASSIVE:
158  \SAML2\Constants::STATUS_RESPONDER,
159  $this->statusMessage
160  );
161  break;
162  }
163  break;
164  }
165 
166  if ($e === null) {
167  return $this;
168  }
169 
170  return $e;
171  }

Field Documentation

◆ $status

sspmod_saml_Error::$status
private

Definition at line 15 of file Error.php.

Referenced by __construct(), getStatus(), and shortStatus().

◆ $statusMessage

sspmod_saml_Error::$statusMessage
private

Definition at line 29 of file Error.php.

Referenced by __construct(), and getStatusMessage().

◆ $subStatus

sspmod_saml_Error::$subStatus
private

Definition at line 22 of file Error.php.

Referenced by __construct(), and getSubStatus().


The documentation for this class was generated from the following file: