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

Public Member Functions

 isSuccess ()
 Determine whether this is a successful response. More...
 
 getInResponseTo ()
 Retrieve the ID of the request this is a response to. More...
 
 setInResponseTo ($inResponseTo)
 Set the ID of the request this is a response to. More...
 
 getStatus ()
 Retrieve the status code. More...
 
 setStatus (array $status)
 Set the status code. More...
 
 toUnsignedXML ()
 Convert status response message to an XML element. More...
 
- Public Member Functions inherited from SAML2\Message
 addValidator ($function, $data)
 Add a method for validating this message. More...
 
 validate (XMLSecurityKey $key)
 Validate this message against a public key. More...
 
 getId ()
 Retrieve the identifier of this message. More...
 
 setId ($id)
 Set the identifier of this message. More...
 
 getIssueInstant ()
 Retrieve the issue timestamp of this message. More...
 
 setIssueInstant ($issueInstant)
 Set the issue timestamp of this message. More...
 
 getDestination ()
 Retrieve the destination of this message. More...
 
 setDestination ($destination)
 Set the destination of this message. More...
 
 setConsent ($consent)
 Set the given consent for this message. More...
 
 getConsent ()
 Set the given consent for this message. More...
 
 getIssuer ()
 Retrieve the issuer if this message. More...
 
 setIssuer ($issuer)
 Set the issuer of this message. More...
 
 isMessageConstructedWithSignature ()
 Query whether or not the message contained a signature at the root level when the object was constructed. More...
 
 getRelayState ()
 Retrieve the RelayState associated with this message. More...
 
 setRelayState ($relayState)
 Set the RelayState associated with this message. More...
 
 toUnsignedXML ()
 Convert this message to an unsigned XML document. More...
 
 toSignedXML ()
 Convert this message to a signed XML document. More...
 
 getSignatureKey ()
 Retrieve the private key we should use to sign the message. More...
 
 setSignatureKey (XMLSecurityKey $signatureKey=null)
 Set the private key we should use to sign the message. More...
 
 setCertificates (array $certificates)
 Set the certificates that should be included in the message. More...
 
 getCertificates ()
 Retrieve the certificates that are included in the message. More...
 
 getExtensions ()
 Retrieve the Extensions. More...
 
 setExtensions ($extensions)
 Set the Extensions. More...
 
 getSignatureMethod ()
 
 validate (XMLSecurityKey $key)
 Validate this element against a public key. More...
 
 setCertificates (array $certificates)
 Set the certificates that should be included in the element. More...
 
 getCertificates ()
 Retrieve the certificates that are included in the element (if any). More...
 
 getSignatureKey ()
 Retrieve the private key we should use to sign the element. More...
 
 setSignatureKey (XMLSecurityKey $signatureKey=null)
 Set the private key we should use to sign the element. More...
 

Protected Member Functions

 __construct ($tagName, \DOMElement $xml=null)
 Constructor for SAML 2 response messages. More...
 
 __construct ($tagName, \DOMElement $xml=null)
 Initialize a message. More...
 

Private Attributes

 $inResponseTo
 
 $status
 

Additional Inherited Members

- Static Public Member Functions inherited from SAML2\Message
static fromXML (\DOMElement $xml)
 Convert an XML element into a message. More...
 
- Protected Attributes inherited from SAML2\Message
 $extensions
 
 $document
 
 $messageContainedSignatureUponConstruction = false
 

Detailed Description

Definition at line 25 of file StatusResponse.php.

Constructor & Destructor Documentation

◆ __construct()

SAML2\StatusResponse::__construct (   $tagName,
\DOMElement  $xml = null 
)
protected

Constructor for SAML 2 response messages.

Parameters
string$tagNameThe tag name of the root element.
\DOMElement | null$xmlThe input message.
Exceptions

Exception

Reimplemented from SAML2\Message.

Definition at line 50 of file StatusResponse.php.

51 {
52 parent::__construct($tagName, $xml);
53
54 $this->status = array(
56 'SubCode' => null,
57 'Message' => null,
58 );
59
60 if ($xml === null) {
61 return;
62 }
63
64 if ($xml->hasAttribute('InResponseTo')) {
65 $this->inResponseTo = $xml->getAttribute('InResponseTo');
66 }
67
68 $status = Utils::xpQuery($xml, './saml_protocol:Status');
69 if (empty($status)) {
70 throw new \Exception('Missing status code on response.');
71 }
72 $status = $status[0];
73
74 $statusCode = Utils::xpQuery($status, './saml_protocol:StatusCode');
75 if (empty($statusCode)) {
76 throw new \Exception('Missing status code in status element.');
77 }
78 $statusCode = $statusCode[0];
79
80 $this->status['Code'] = $statusCode->getAttribute('Value');
81
82 $subCode = Utils::xpQuery($statusCode, './saml_protocol:StatusCode');
83 if (!empty($subCode)) {
84 $this->status['SubCode'] = $subCode[0]->getAttribute('Value');
85 }
86
87 $message = Utils::xpQuery($status, './saml_protocol:StatusMessage');
88 if (!empty($message)) {
89 $this->status['Message'] = trim($message[0]->textContent);
90 }
91 }
const STATUS_SUCCESS
Top-level status code indicating successful processing of the request.
Definition: Constants.php:259
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
Definition: Utils.php:191
catch(Exception $e) $message

References $message, and $xml.

Member Function Documentation

◆ getInResponseTo()

SAML2\StatusResponse::getInResponseTo ( )

Retrieve the ID of the request this is a response to.

Returns
string|null The ID of the request.

Definition at line 116 of file StatusResponse.php.

117 {
118 return $this->inResponseTo;
119 }

◆ getStatus()

SAML2\StatusResponse::getStatus ( )

Retrieve the status code.

Returns
array The status code.

Definition at line 140 of file StatusResponse.php.

141 {
142 return $this->status;
143 }

Referenced by SAML2\Response\Validation\ConstraintValidator\IsSuccessful\validate().

+ Here is the caller graph for this function:

◆ isSuccess()

SAML2\StatusResponse::isSuccess ( )

Determine whether this is a successful response.

Returns
boolean true if the status code is success, false if not.

Definition at line 99 of file StatusResponse.php.

100 {
101 assert(array_key_exists("Code", $this->status));
102
103 if ($this->status['Code'] === Constants::STATUS_SUCCESS) {
104 return true;
105 }
106
107 return false;
108 }

◆ setInResponseTo()

SAML2\StatusResponse::setInResponseTo (   $inResponseTo)

Set the ID of the request this is a response to.

Parameters
string | null$inResponseToThe ID of the request.

Definition at line 127 of file StatusResponse.php.

128 {
129 assert(is_string($inResponseTo) || is_null($inResponseTo));
130
131 $this->inResponseTo = $inResponseTo;
132 }

◆ setStatus()

SAML2\StatusResponse::setStatus ( array  $status)

Set the status code.

Parameters
array$statusThe status code.

Definition at line 151 of file StatusResponse.php.

152 {
153 assert(array_key_exists("Code", $status));
154
155 $this->status = $status;
156 if (!array_key_exists('SubCode', $status)) {
157 $this->status['SubCode'] = null;
158 }
159 if (!array_key_exists('Message', $status)) {
160 $this->status['Message'] = null;
161 }
162 }

◆ toUnsignedXML()

SAML2\StatusResponse::toUnsignedXML ( )

Convert status response message to an XML element.

Returns
\DOMElement This status response.

Reimplemented from SAML2\Message.

Reimplemented in SAML2\ArtifactResponse.

Definition at line 170 of file StatusResponse.php.

171 {
172 $root = parent::toUnsignedXML();
173
174 if ($this->inResponseTo !== null) {
175 $root->setAttribute('InResponseTo', $this->inResponseTo);
176 }
177
178 $status = $this->document->createElementNS(Constants::NS_SAMLP, 'Status');
179 $root->appendChild($status);
180
181 $statusCode = $this->document->createElementNS(Constants::NS_SAMLP, 'StatusCode');
182 $statusCode->setAttribute('Value', $this->status['Code']);
183 $status->appendChild($statusCode);
184
185 if (!is_null($this->status['SubCode'])) {
186 $subStatusCode = $this->document->createElementNS(Constants::NS_SAMLP, 'StatusCode');
187 $subStatusCode->setAttribute('Value', $this->status['SubCode']);
188 $statusCode->appendChild($subStatusCode);
189 }
190
191 if (!is_null($this->status['Message'])) {
192 Utils::addString($status, Constants::NS_SAMLP, 'StatusMessage', $this->status['Message']);
193 }
194
195 return $root;
196 }
const NS_SAMLP
The namespace for the SAML 2 protocol.
Definition: Constants.php:220
static addString(\DOMElement $parent, $namespace, $name, $value)
Append string element.
Definition: Utils.php:635
$root
Definition: sabredav.php:45

References $root.

Field Documentation

◆ $inResponseTo

SAML2\StatusResponse::$inResponseTo
private

Definition at line 32 of file StatusResponse.php.

◆ $status

SAML2\StatusResponse::$status
private

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