ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 42 of file Error.php.

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

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

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 101 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().

101  {
102 
103  if ($exception instanceof sspmod_saml_Error) {
104  // Return the original exception unchanged
105  return $exception;
106 
107  // TODO: remove this branch in 2.0
108  } elseif ($exception instanceof SimpleSAML_Error_NoPassive) {
109  $e = new self(
112  $exception->getMessage(),
113  $exception
114  );
115  // TODO: remove this branch in 2.0
116  } elseif ($exception instanceof SimpleSAML_Error_ProxyCountExceeded) {
117  $e = new self(
120  $exception->getMessage(),
121  $exception
122  );
123  } else {
124  $e = new self(
126  NULL,
127  get_class($exception) . ': ' . $exception->getMessage(),
128  $exception
129  );
130  }
131 
132  return $e;
133  }
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:268
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:318
const STATUS_PROXY_COUNT_EXCEEDED
Indicates that a responding provider cannot authenticate the principal directly and is not permitted ...
Definition: Constants.php:342
+ 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 67 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 87 of file Error.php.

References $statusMessage.

87  {
88  return $this->statusMessage;
89  }

◆ 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.

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

◆ 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 184 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 147 of file Error.php.

References $statusMessage.

147  {
148 
149  if ($this->statusMessage !== NULL) {
150  $msg = $this->statusMessage;
151  } else {
152  $msg = '';
153  }
154 
155  $e = NULL;
156 
157  switch ($this->status) {
158  case \SAML2\Constants::STATUS_RESPONDER:
159  switch ($this->subStatus) {
160  case \SAML2\Constants::STATUS_NO_PASSIVE:
161  $e = new SimpleSAML_Error_NoPassive($this->statusMessage, 0, $this);
162  break;
163  }
164  break;
165  }
166 
167  if ($e === NULL) {
168  return $this;
169  }
170 
171  return $e;
172  }
Class SimpleSAML_Error_NoPassive.
Definition: NoPassive.php:12

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 31 of file Error.php.

Referenced by __construct(), getStatusMessage(), and toException().

◆ $subStatus

sspmod_saml_Error::$subStatus
private

Definition at line 23 of file Error.php.

Referenced by __construct(), and getSubStatus().


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