ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
SAML2\AttributeQuery Class Reference
+ Inheritance diagram for SAML2\AttributeQuery:
+ Collaboration diagram for SAML2\AttributeQuery:

Public Member Functions

 __construct (\DOMElement $xml=null)
 Constructor for SAML 2 attribute query messages. More...
 
 getAttributes ()
 Retrieve all requested attributes. More...
 
 setAttributes (array $attributes)
 Set all requested attributes. More...
 
 getAttributeNameFormat ()
 Retrieve the NameFormat used on all attributes. More...
 
 setAttributeNameFormat ($nameFormat)
 Set the NameFormat used on all attributes. More...
 
 toUnsignedXML ()
 Convert the attribute query message to an XML element. More...
 
- Public Member Functions inherited from SAML2\SubjectQuery
 getNameId ()
 Retrieve the NameId of the subject in the query. More...
 
 setNameId ($nameId)
 Set the NameId of the subject in the query. More...
 
 toUnsignedXML ()
 Convert subject query 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 ()
 

Private Attributes

 $attributes
 
 $nameFormat
 

Additional Inherited Members

- Static Public Member Functions inherited from SAML2\Message
static fromXML (\DOMElement $xml)
 Convert an XML element into a message. More...
 
- Protected Member Functions inherited from SAML2\SubjectQuery
 __construct ($tagName, \DOMElement $xml=null)
 Constructor for SAML 2 subject query messages. More...
 
- Protected Member Functions inherited from SAML2\Message
 __construct ($tagName, \DOMElement $xml=null)
 Initialize a message. More...
 
- Protected Attributes inherited from SAML2\Message
 $extensions
 
 $document
 
 $messageContainedSignatureUponConstruction = false
 

Detailed Description

Definition at line 20 of file AttributeQuery.php.

Constructor & Destructor Documentation

◆ __construct()

SAML2\AttributeQuery::__construct ( \DOMElement  $xml = null)

Constructor for SAML 2 attribute query messages.

Parameters
\DOMElement | null$xmlThe input message.
Exceptions

Definition at line 45 of file AttributeQuery.php.

References $attributes, $name, $xml, and array.

46  {
47  parent::__construct('AttributeQuery', $xml);
48 
49  $this->attributes = array();
50  $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
51 
52  if ($xml === null) {
53  return;
54  }
55 
56  $firstAttribute = true;
57  $attributes = Utils::xpQuery($xml, './saml_assertion:Attribute');
58  foreach ($attributes as $attribute) {
59  if (!$attribute->hasAttribute('Name')) {
60  throw new \Exception('Missing name on <saml:Attribute> element.');
61  }
62  $name = $attribute->getAttribute('Name');
63 
64  if ($attribute->hasAttribute('NameFormat')) {
65  $nameFormat = $attribute->getAttribute('NameFormat');
66  } else {
68  }
69 
70  if ($firstAttribute) {
71  $this->nameFormat = $nameFormat;
72  $firstAttribute = false;
73  } else {
74  if ($this->nameFormat !== $nameFormat) {
75  $this->nameFormat = Constants::NAMEFORMAT_UNSPECIFIED;
76  }
77  }
78 
79  if (!array_key_exists($name, $this->attributes)) {
80  $this->attributes[$name] = array();
81  }
82 
83  $values = Utils::xpQuery($attribute, './saml_assertion:AttributeValue');
84  foreach ($values as $value) {
85  $this->attributes[$name][] = trim($value->textContent);
86  }
87  }
88  }
$xml
Definition: metadata.php:240
if($format !==null) $name
Definition: metadata.php:146
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
Definition: Utils.php:191
const NAMEFORMAT_UNSPECIFIED
The interpretation of the attribute name is left to individual implementations.
Definition: Constants.php:141
Create styles array
The data for the language used.

Member Function Documentation

◆ getAttributeNameFormat()

SAML2\AttributeQuery::getAttributeNameFormat ( )

Retrieve the NameFormat used on all attributes.

If more than one NameFormat is used in the received attributes, this returns the unspecified NameFormat.

Returns
string The NameFormat used on all attributes.

Definition at line 118 of file AttributeQuery.php.

119  {
120  return $this->nameFormat;
121  }

◆ getAttributes()

SAML2\AttributeQuery::getAttributes ( )

Retrieve all requested attributes.

Returns
array All requested attributes, as an associative array.

Definition at line 95 of file AttributeQuery.php.

References $attributes.

96  {
97  return $this->attributes;
98  }

◆ setAttributeNameFormat()

SAML2\AttributeQuery::setAttributeNameFormat (   $nameFormat)

Set the NameFormat used on all attributes.

Parameters
string$nameFormatThe NameFormat used on all attributes.

Definition at line 128 of file AttributeQuery.php.

129  {
130  assert(is_string($nameFormat));
131 
132  $this->nameFormat = $nameFormat;
133  }

◆ setAttributes()

SAML2\AttributeQuery::setAttributes ( array  $attributes)

Set all requested attributes.

Parameters
array$attributesAll requested attributes, as an associative array.

Definition at line 105 of file AttributeQuery.php.

References $attributes.

106  {
107  $this->attributes = $attributes;
108  }

◆ toUnsignedXML()

SAML2\AttributeQuery::toUnsignedXML ( )

Convert the attribute query message to an XML element.

Returns
This attribute query.

Definition at line 140 of file AttributeQuery.php.

References $name, and $type.

141  {
142  $root = parent::toUnsignedXML();
143 
144  foreach ($this->attributes as $name => $values) {
145  $attribute = $root->ownerDocument->createElementNS(Constants::NS_SAML, 'saml:Attribute');
146  $root->appendChild($attribute);
147  $attribute->setAttribute('Name', $name);
148 
149  if ($this->nameFormat !== Constants::NAMEFORMAT_UNSPECIFIED) {
150  $attribute->setAttribute('NameFormat', $this->nameFormat);
151  }
152 
153  foreach ($values as $value) {
154  if (is_string($value)) {
155  $type = 'xs:string';
156  } elseif (is_int($value)) {
157  $type = 'xs:integer';
158  } else {
159  $type = null;
160  }
161 
162  $attributeValue = Utils::addString($attribute, Constants::NS_SAML, 'saml:AttributeValue', $value);
163  if ($type !== null) {
164  $attributeValue->setAttributeNS(Constants::NS_XSI, 'xsi:type', $type);
165  }
166  }
167  }
168 
169  return $root;
170  }
$type
if($format !==null) $name
Definition: metadata.php:146
static addString(\DOMElement $parent, $namespace, $name, $value)
Append string element.
Definition: Utils.php:635
const NS_XSI
The namespace for XML schema instance.
Definition: Constants.php:235
const NAMEFORMAT_UNSPECIFIED
The interpretation of the attribute name is left to individual implementations.
Definition: Constants.php:141
const NS_SAML
The namespace for the SAML 2 assertions.
Definition: Constants.php:220

Field Documentation

◆ $attributes

SAML2\AttributeQuery::$attributes
private

Definition at line 27 of file AttributeQuery.php.

◆ $nameFormat

SAML2\AttributeQuery::$nameFormat
private

Definition at line 37 of file AttributeQuery.php.


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