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

Public Member Functions

 __construct ($entityId, $maxCache=null, $maxDuration=null)
 Initialize the SAML builder. More...
 
 getEntityDescriptor ()
 Retrieve the EntityDescriptor element which is generated for this entity. More...
 
 getEntityDescriptorText ($formatted=true)
 Retrieve the EntityDescriptor as text. More...
 
 addSecurityTokenServiceType ($metadata)
 Add a SecurityTokenServiceType for ADFS metadata. More...
 
 addOrganization (array $orgName, array $orgDisplayName, array $orgURL)
 Add an Organization element based on data passed as parameters. More...
 
 addOrganizationInfo (array $metadata)
 Add an Organization element based on metadata array. More...
 
 addMetadata ($set, $metadata)
 Add a specific type of metadata to an entity. More...
 
 addMetadataSP20 ($metadata, $protocols=array(\SAML2\Constants::NS_SAMLP))
 Add SAML 2.0 SP metadata. More...
 
 addMetadataIdP20 ($metadata)
 Add metadata of a SAML 2.0 identity provider. More...
 
 addMetadataSP11 ($metadata)
 Add metadata of a SAML 1.1 service provider. More...
 
 addMetadataIdP11 ($metadata)
 Add metadata of a SAML 1.1 identity provider. More...
 
 addAttributeAuthority (array $metadata)
 Add metadata of a SAML attribute authority. More...
 
 addContact ($type, $details)
 Add contact information. More...
 

Private Member Functions

 setExpiration ($metadata)
 
 addExtensions (SimpleSAML_Configuration $metadata, \SAML2\XML\md\RoleDescriptor $e)
 Add extensions to the metadata. More...
 
 addAttributeConsumingService (\SAML2\XML\md\SPSSODescriptor $spDesc, SimpleSAML_Configuration $metadata)
 Add an AttributeConsumingService element to the metadata. More...
 
 addX509KeyDescriptor (\SAML2\XML\md\RoleDescriptor $rd, $use, $x509data)
 Add a KeyDescriptor with an X509 certificate. More...
 
 addCertificate (\SAML2\XML\md\RoleDescriptor $rd, SimpleSAML_Configuration $metadata)
 Add a certificate. More...
 

Static Private Member Functions

static createEndpoints (array $endpoints, $indexed)
 Add a list of endpoints to metadata. More...
 

Private Attributes

 $entityDescriptor
 
 $maxCache = null
 
 $maxDuration = null
 

Detailed Description

Definition at line 11 of file SAMLBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

SimpleSAML_Metadata_SAMLBuilder::__construct (   $entityId,
  $maxCache = null,
  $maxDuration = null 
)

Initialize the SAML builder.

Parameters
string$entityIdThe entity id of the entity.
double | null$maxCacheThe maximum time in seconds the metadata should be cached. Defaults to null
double | null$maxDurationThe maximum time in seconds this metadata should be considered valid. Defaults to null.

Definition at line 47 of file SAMLBuilder.php.

References $entityId, $maxCache, and $maxDuration.

48  {
49  assert(is_string($entityId));
50 
51  $this->maxCache = $maxCache;
52  $this->maxDuration = $maxDuration;
53 
54  $this->entityDescriptor = new \SAML2\XML\md\EntityDescriptor();
55  $this->entityDescriptor->entityID = $entityId;
56  }
if($source===null) if(!($source instanceof sspmod_saml_Auth_Source_SP)) $entityId
Definition: metadata.php:22

Member Function Documentation

◆ addAttributeAuthority()

SimpleSAML_Metadata_SAMLBuilder::addAttributeAuthority ( array  $metadata)

Add metadata of a SAML attribute authority.

Parameters
array$metadataThe AttributeAuthorityDescriptor, in the format returned by SimpleSAML_Metadata_SAMLParser.

Definition at line 643 of file SAMLBuilder.php.

Referenced by addMetadata().

644  {
645  assert(is_array($metadata));
646  assert(isset($metadata['entityid']));
647  assert(isset($metadata['metadata-set']));
648 
650 
651  $e = new \SAML2\XML\md\AttributeAuthorityDescriptor();
652  $e->protocolSupportEnumeration = $metadata->getArray('protocols', array(\SAML2\Constants::NS_SAMLP));
653 
654  $this->addExtensions($metadata, $e);
655  $this->addCertificate($e, $metadata);
656 
657  $e->AttributeService = self::createEndpoints($metadata->getEndpoints('AttributeService'), false);
658  $e->AssertionIDRequestService = self::createEndpoints(
659  $metadata->getEndpoints('AssertionIDRequestService'),
660  false
661  );
662 
663  $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array());
664 
665  $this->entityDescriptor->RoleDescriptor[] = $e;
666  }
addExtensions(SimpleSAML_Configuration $metadata, \SAML2\XML\md\RoleDescriptor $e)
Add extensions to the metadata.
$metadata['__DYNAMIC:1__']
addCertificate(\SAML2\XML\md\RoleDescriptor $rd, SimpleSAML_Configuration $metadata)
Add a certificate.
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
+ Here is the caller graph for this function:

◆ addAttributeConsumingService()

SimpleSAML_Metadata_SAMLBuilder::addAttributeConsumingService ( \SAML2\XML\md\SPSSODescriptor  $spDesc,
SimpleSAML_Configuration  $metadata 
)
private

Add an AttributeConsumingService element to the metadata.

Parameters
\SAML2\XML\md\SPSSODescriptor$spDescThe SPSSODescriptor element.
SimpleSAML_Configuration$metadataThe metadata.

Definition at line 385 of file SAMLBuilder.php.

References $attributes, $name, $t, SimpleSAML_Configuration\getArray(), SimpleSAML_Configuration\getBoolean(), SimpleSAML_Configuration\getInteger(), SimpleSAML_Configuration\getLocalizedString(), SimpleSAML_Configuration\getString(), and SimpleSAML_Configuration\hasValue().

388  {
389  $attributes = $metadata->getArray('attributes', array());
390  $name = $metadata->getLocalizedString('name', null);
391 
392  if ($name === null || count($attributes) == 0) {
393  // we cannot add an AttributeConsumingService without name and attributes
394  return;
395  }
396 
397  $attributesrequired = $metadata->getArray('attributes.required', array());
398 
399  /*
400  * Add an AttributeConsumingService element with information as name and description and list
401  * of requested attributes
402  */
403  $attributeconsumer = new \SAML2\XML\md\AttributeConsumingService();
404 
405  $attributeconsumer->index = $metadata->getInteger('attributes.index', 0);
406 
407  if ($metadata->hasValue('attributes.isDefault')) {
408  $attributeconsumer->isDefault = $metadata->getBoolean('attributes.isDefault', false);
409  }
410 
411  $attributeconsumer->ServiceName = $name;
412  $attributeconsumer->ServiceDescription = $metadata->getLocalizedString('description', array());
413 
414  $nameFormat = $metadata->getString('attributes.NameFormat', \SAML2\Constants::NAMEFORMAT_UNSPECIFIED);
415  foreach ($attributes as $friendlyName => $attribute) {
416  $t = new \SAML2\XML\md\RequestedAttribute();
417  $t->Name = $attribute;
418  if (!is_int($friendlyName)) {
419  $t->FriendlyName = $friendlyName;
420  }
421  if ($nameFormat !== \SAML2\Constants::NAMEFORMAT_UNSPECIFIED) {
422  $t->NameFormat = $nameFormat;
423  }
424  if (in_array($attribute, $attributesrequired, true)) {
425  $t->isRequired = true;
426  }
427  $attributeconsumer->RequestedAttribute[] = $t;
428  }
429 
430  $spDesc->AttributeConsumingService[] = $attributeconsumer;
431  }
getArray($name, $default=self::REQUIRED_OPTION)
This function retrieves an array configuration option.
hasValue($name)
Check whether a key in the configuration exists or not.
getLocalizedString($name, $default=self::REQUIRED_OPTION)
Retrieve a string which may be localized into many languages.
getBoolean($name, $default=self::REQUIRED_OPTION)
This function retrieves a boolean configuration option.
if(array_key_exists('yes', $_REQUEST)) $attributes
Definition: getconsent.php:85
getInteger($name, $default=self::REQUIRED_OPTION)
This function retrieves an integer configuration option.
getString($name, $default=self::REQUIRED_OPTION)
This function retrieves a string configuration option.
+ Here is the call graph for this function:

◆ addCertificate()

SimpleSAML_Metadata_SAMLBuilder::addCertificate ( \SAML2\XML\md\RoleDescriptor  $rd,
SimpleSAML_Configuration  $metadata 
)
private

Add a certificate.

Helper function for adding a certificate to the metadata.

Parameters
\SAML2\XML\md\RoleDescriptor$rdThe RoleDescriptor the certificate should be added to.
SimpleSAML_Configuration$metadataThe metadata of the entity.

Definition at line 758 of file SAMLBuilder.php.

Referenced by addSecurityTokenServiceType().

759  {
760  $keys = $metadata->getPublicKeys();
761  foreach ($keys as $key) {
762  if ($key['type'] !== 'X509Certificate') {
763  continue;
764  }
765  if (!isset($key['signing']) || $key['signing'] === true) {
766  $this->addX509KeyDescriptor($rd, 'signing', $key['X509Certificate']);
767  }
768  if (!isset($key['encryption']) || $key['encryption'] === true) {
769  $this->addX509KeyDescriptor($rd, 'encryption', $key['X509Certificate']);
770  }
771  }
772 
773  if ($metadata->hasValue('https.certData')) {
774  $this->addX509KeyDescriptor($rd, 'signing', $metadata->getString('https.certData'));
775  }
776  }
hasValue($name)
Check whether a key in the configuration exists or not.
$keys
addX509KeyDescriptor(\SAML2\XML\md\RoleDescriptor $rd, $use, $x509data)
Add a KeyDescriptor with an X509 certificate.
getPublicKeys($use=null, $required=false, $prefix='')
Get public key from metadata.
getString($name, $default=self::REQUIRED_OPTION)
This function retrieves a string configuration option.
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ addContact()

SimpleSAML_Metadata_SAMLBuilder::addContact (   $type,
  $details 
)

Add contact information.

Accepts a contact type, and a contact array that must be previously sanitized.

WARNING: This function will change its signature and no longer parse a 'name' element.

Parameters
string$typeThe type of contact. Deprecated.
array$detailsThe details about the contact.
Todo:

Change the signature to remove $type.

Remove the capability to pass a name and parse it inside the method.

Definition at line 682 of file SAMLBuilder.php.

683  {
684  assert(is_string($type));
685  assert(is_array($details));
686  assert(in_array($type, array('technical', 'support', 'administrative', 'billing', 'other'), true));
687 
688  // TODO: remove this check as soon as getContact() is called always before calling this function
689  $details = \SimpleSAML\Utils\Config\Metadata::getContact($details);
690 
691  $e = new \SAML2\XML\md\ContactPerson();
692  $e->contactType = $type;
693 
694  if (!empty($details['attributes'])) {
695  $e->ContactPersonAttributes = $details['attributes'];
696  }
697 
698  if (isset($details['company'])) {
699  $e->Company = $details['company'];
700  }
701  if (isset($details['givenName'])) {
702  $e->GivenName = $details['givenName'];
703  }
704  if (isset($details['surName'])) {
705  $e->SurName = $details['surName'];
706  }
707 
708  if (isset($details['emailAddress'])) {
709  $eas = $details['emailAddress'];
710  if (!is_array($eas)) {
711  $eas = array($eas);
712  }
713  foreach ($eas as $ea) {
714  $e->EmailAddress[] = $ea;
715  }
716  }
717 
718  if (isset($details['telephoneNumber'])) {
719  $tlfNrs = $details['telephoneNumber'];
720  if (!is_array($tlfNrs)) {
721  $tlfNrs = array($tlfNrs);
722  }
723  foreach ($tlfNrs as $tlfNr) {
724  $e->TelephoneNumber[] = $tlfNr;
725  }
726  }
727 
728  $this->entityDescriptor->ContactPerson[] = $e;
729  }
$type

◆ addExtensions()

SimpleSAML_Metadata_SAMLBuilder::addExtensions ( SimpleSAML_Configuration  $metadata,
\SAML2\XML\md\RoleDescriptor  $e 
)
private

Add extensions to the metadata.

Parameters
SimpleSAML_Configuration$metadataThe metadata to get extensions from.
\SAML2\XML\md\RoleDescriptor$eReference to the element where the Extensions element should be included.

Definition at line 140 of file SAMLBuilder.php.

References $lang, $s, $tag, SimpleSAML_Configuration\getArray(), SimpleSAML_Configuration\hasValue(), and SAML2\Utils\xsDateTimeToTimestamp().

141  {
142  if ($metadata->hasValue('tags')) {
143  $a = new \SAML2\XML\saml\Attribute();
144  $a->Name = 'tags';
145  foreach ($metadata->getArray('tags') as $tag) {
146  $a->AttributeValue[] = new \SAML2\XML\saml\AttributeValue($tag);
147  }
148  $e->Extensions[] = $a;
149  }
150 
151  if ($metadata->hasValue('hint.cidr')) {
152  $a = new \SAML2\XML\saml\Attribute();
153  $a->Name = 'hint.cidr';
154  foreach ($metadata->getArray('hint.cidr') as $hint) {
155  $a->AttributeValue[] = new \SAML2\XML\saml\AttributeValue($hint);
156  }
157  $e->Extensions[] = $a;
158  }
159 
160  if ($metadata->hasValue('scope')) {
161  foreach ($metadata->getArray('scope') as $scopetext) {
162  $s = new \SAML2\XML\shibmd\Scope();
163  $s->scope = $scopetext;
164  // Check whether $ ^ ( ) * | \ are in a scope -> assume regex.
165  if (1 === preg_match('/[\$\^\)\(\*\|\\\\]/', $scopetext)) {
166  $s->regexp = true;
167  } else {
168  $s->regexp = false;
169  }
170  $e->Extensions[] = $s;
171  }
172  }
173 
174  if ($metadata->hasValue('EntityAttributes')) {
175  $ea = new \SAML2\XML\mdattr\EntityAttributes();
176  foreach ($metadata->getArray('EntityAttributes') as $attributeName => $attributeValues) {
177  $a = new \SAML2\XML\saml\Attribute();
178  $a->Name = $attributeName;
179  $a->NameFormat = 'urn:oasis:names:tc:SAML:2.0:attrname-format:uri';
180 
181  // Attribute names that is not URI is prefixed as this: '{nameformat}name'
182  if (preg_match('/^\{(.*?)\}(.*)$/', $attributeName, $matches)) {
183  $a->Name = $matches[2];
184  $nameFormat = $matches[1];
185  if ($nameFormat !== \SAML2\Constants::NAMEFORMAT_UNSPECIFIED) {
186  $a->NameFormat = $nameFormat;
187  }
188  }
189  foreach ($attributeValues as $attributeValue) {
190  $a->AttributeValue[] = new \SAML2\XML\saml\AttributeValue($attributeValue);
191  }
192  $ea->children[] = $a;
193  }
194  $this->entityDescriptor->Extensions[] = $ea;
195  }
196 
197  if ($metadata->hasValue('RegistrationInfo')) {
198  $ri = new \SAML2\XML\mdrpi\RegistrationInfo();
199  foreach ($metadata->getArray('RegistrationInfo') as $riName => $riValues) {
200  switch ($riName) {
201  case 'authority':
202  $ri->registrationAuthority = $riValues;
203  break;
204  case 'instant':
205  $ri->registrationInstant = \SAML2\Utils::xsDateTimeToTimestamp($riValues);
206  break;
207  case 'policies':
208  $ri->RegistrationPolicy = $riValues;
209  break;
210  }
211  }
212  $this->entityDescriptor->Extensions[] = $ri;
213  }
214 
215  if ($metadata->hasValue('UIInfo')) {
216  $ui = new \SAML2\XML\mdui\UIInfo();
217  foreach ($metadata->getArray('UIInfo') as $uiName => $uiValues) {
218  switch ($uiName) {
219  case 'DisplayName':
220  $ui->DisplayName = $uiValues;
221  break;
222  case 'Description':
223  $ui->Description = $uiValues;
224  break;
225  case 'InformationURL':
226  $ui->InformationURL = $uiValues;
227  break;
228  case 'PrivacyStatementURL':
229  $ui->PrivacyStatementURL = $uiValues;
230  break;
231  case 'Keywords':
232  foreach ($uiValues as $lang => $keywords) {
233  $uiItem = new \SAML2\XML\mdui\Keywords();
234  $uiItem->lang = $lang;
235  $uiItem->Keywords = $keywords;
236  $ui->Keywords[] = $uiItem;
237  }
238  break;
239  case 'Logo':
240  foreach ($uiValues as $logo) {
241  $uiItem = new \SAML2\XML\mdui\Logo();
242  $uiItem->url = $logo['url'];
243  $uiItem->width = $logo['width'];
244  $uiItem->height = $logo['height'];
245  if (isset($logo['lang'])) {
246  $uiItem->lang = $logo['lang'];
247  }
248  $ui->Logo[] = $uiItem;
249  }
250  break;
251  }
252  }
253  $e->Extensions[] = $ui;
254  }
255 
256  if ($metadata->hasValue('DiscoHints')) {
257  $dh = new \SAML2\XML\mdui\DiscoHints();
258  foreach ($metadata->getArray('DiscoHints') as $dhName => $dhValues) {
259  switch ($dhName) {
260  case 'IPHint':
261  $dh->IPHint = $dhValues;
262  break;
263  case 'DomainHint':
264  $dh->DomainHint = $dhValues;
265  break;
266  case 'GeolocationHint':
267  $dh->GeolocationHint = $dhValues;
268  break;
269  }
270  }
271  $e->Extensions[] = $dh;
272  }
273  }
getArray($name, $default=self::REQUIRED_OPTION)
This function retrieves an array configuration option.
hasValue($name)
Check whether a key in the configuration exists or not.
$s
Definition: pwgen.php:45
static xsDateTimeToTimestamp($time)
This function converts a SAML2 timestamp on the form yyyy-mm-ddThh:mm:ss(.s+)?Z to a UNIX timestamp...
Definition: Utils.php:721
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
+ Here is the call graph for this function:

◆ addMetadata()

SimpleSAML_Metadata_SAMLBuilder::addMetadata (   $set,
  $metadata 
)

Add a specific type of metadata to an entity.

Parameters
string$setThe metadata set this metadata comes from.
array$metadataThe metadata.

Definition at line 440 of file SAMLBuilder.php.

References $metadata, addAttributeAuthority(), addMetadataIdP11(), addMetadataIdP20(), addMetadataSP11(), addMetadataSP20(), setExpiration(), and SimpleSAML\Logger\warning().

441  {
442  assert(is_string($set));
443  assert(is_array($metadata));
444 
445  $this->setExpiration($metadata);
446 
447  switch ($set) {
448  case 'saml20-sp-remote':
449  $this->addMetadataSP20($metadata);
450  break;
451  case 'saml20-idp-remote':
452  $this->addMetadataIdP20($metadata);
453  break;
454  case 'shib13-sp-remote':
455  $this->addMetadataSP11($metadata);
456  break;
457  case 'shib13-idp-remote':
458  $this->addMetadataIdP11($metadata);
459  break;
460  case 'attributeauthority-remote':
462  break;
463  default:
464  SimpleSAML\Logger::warning('Unable to generate metadata for unknown type \''.$set.'\'.');
465  }
466  }
addMetadataSP11($metadata)
Add metadata of a SAML 1.1 service provider.
addMetadataIdP11($metadata)
Add metadata of a SAML 1.1 identity provider.
$metadata['__DYNAMIC:1__']
addAttributeAuthority(array $metadata)
Add metadata of a SAML attribute authority.
static warning($string)
Definition: Logger.php:177
addMetadataIdP20($metadata)
Add metadata of a SAML 2.0 identity provider.
addMetadataSP20($metadata, $protocols=array(\SAML2\Constants::NS_SAMLP))
Add SAML 2.0 SP metadata.
+ Here is the call graph for this function:

◆ addMetadataIdP11()

SimpleSAML_Metadata_SAMLBuilder::addMetadataIdP11 (   $metadata)

Add metadata of a SAML 1.1 identity provider.

Parameters
array$metadataThe metadata.

Definition at line 615 of file SAMLBuilder.php.

Referenced by addMetadata().

616  {
617  assert(is_array($metadata));
618  assert(isset($metadata['entityid']));
619  assert(isset($metadata['metadata-set']));
620 
622 
623  $e = new \SAML2\XML\md\IDPSSODescriptor();
624  $e->protocolSupportEnumeration[] = 'urn:oasis:names:tc:SAML:1.1:protocol';
625  $e->protocolSupportEnumeration[] = 'urn:mace:shibboleth:1.0';
626 
627  $this->addCertificate($e, $metadata);
628 
629  $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array());
630 
631  $e->SingleSignOnService = self::createEndpoints($metadata->getEndpoints('SingleSignOnService'), false);
632 
633  $this->entityDescriptor->RoleDescriptor[] = $e;
634  }
$metadata['__DYNAMIC:1__']
addCertificate(\SAML2\XML\md\RoleDescriptor $rd, SimpleSAML_Configuration $metadata)
Add a certificate.
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
+ Here is the caller graph for this function:

◆ addMetadataIdP20()

SimpleSAML_Metadata_SAMLBuilder::addMetadataIdP20 (   $metadata)

Add metadata of a SAML 2.0 identity provider.

Parameters
array$metadataThe metadata.

Definition at line 531 of file SAMLBuilder.php.

Referenced by addMetadata().

532  {
533  assert(is_array($metadata));
534  assert(isset($metadata['entityid']));
535  assert(isset($metadata['metadata-set']));
536 
538 
539  $e = new \SAML2\XML\md\IDPSSODescriptor();
540  $e->protocolSupportEnumeration[] = 'urn:oasis:names:tc:SAML:2.0:protocol';
541 
542  if ($metadata->hasValue('sign.authnrequest')) {
543  $e->WantAuthnRequestsSigned = $metadata->getBoolean('sign.authnrequest');
544  } elseif ($metadata->hasValue('redirect.sign')) {
545  $e->WantAuthnRequestsSigned = $metadata->getBoolean('redirect.sign');
546  }
547 
548  $this->addExtensions($metadata, $e);
549 
550  $this->addCertificate($e, $metadata);
551 
552  if ($metadata->hasValue('ArtifactResolutionService')) {
553  $e->ArtifactResolutionService = self::createEndpoints(
554  $metadata->getEndpoints('ArtifactResolutionService'),
555  true
556  );
557  }
558 
559  $e->SingleLogoutService = self::createEndpoints($metadata->getEndpoints('SingleLogoutService'), false);
560 
561  $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array());
562 
563  $e->SingleSignOnService = self::createEndpoints($metadata->getEndpoints('SingleSignOnService'), false);
564 
565  $this->entityDescriptor->RoleDescriptor[] = $e;
566 
567  foreach ($metadata->getArray('contacts', array()) as $contact) {
568  if (array_key_exists('contactType', $contact) && array_key_exists('emailAddress', $contact)) {
569  $this->addContact($contact['contactType'], \SimpleSAML\Utils\Config\Metadata::getContact($contact));
570  }
571  }
572  }
addContact($type, $details)
Add contact information.
addExtensions(SimpleSAML_Configuration $metadata, \SAML2\XML\md\RoleDescriptor $e)
Add extensions to the metadata.
$metadata['__DYNAMIC:1__']
Attribute-related utility methods.
addCertificate(\SAML2\XML\md\RoleDescriptor $rd, SimpleSAML_Configuration $metadata)
Add a certificate.
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
+ Here is the caller graph for this function:

◆ addMetadataSP11()

SimpleSAML_Metadata_SAMLBuilder::addMetadataSP11 (   $metadata)

Add metadata of a SAML 1.1 service provider.

Parameters
array$metadataThe metadata.

Definition at line 580 of file SAMLBuilder.php.

Referenced by addMetadata().

581  {
582  assert(is_array($metadata));
583  assert(isset($metadata['entityid']));
584  assert(isset($metadata['metadata-set']));
585 
587 
588  $e = new \SAML2\XML\md\SPSSODescriptor();
589  $e->protocolSupportEnumeration[] = 'urn:oasis:names:tc:SAML:1.1:protocol';
590 
591  $this->addCertificate($e, $metadata);
592 
593  $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array());
594 
595  $endpoints = $metadata->getEndpoints('AssertionConsumerService');
596  foreach ($metadata->getArrayizeString('AssertionConsumerService.artifact', array()) as $acs) {
597  $endpoints[] = array(
598  'Binding' => 'urn:oasis:names:tc:SAML:1.0:profiles:artifact-01',
599  'Location' => $acs,
600  );
601  }
602  $e->AssertionConsumerService = self::createEndpoints($endpoints, true);
603 
605 
606  $this->entityDescriptor->RoleDescriptor[] = $e;
607  }
$metadata['__DYNAMIC:1__']
addAttributeConsumingService(\SAML2\XML\md\SPSSODescriptor $spDesc, SimpleSAML_Configuration $metadata)
Add an AttributeConsumingService element to the metadata.
addCertificate(\SAML2\XML\md\RoleDescriptor $rd, SimpleSAML_Configuration $metadata)
Add a certificate.
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
+ Here is the caller graph for this function:

◆ addMetadataSP20()

SimpleSAML_Metadata_SAMLBuilder::addMetadataSP20 (   $metadata,
  $protocols = array(\SAML2\Constants::NS_SAMLP) 
)

Add SAML 2.0 SP metadata.

Parameters
array$metadataThe metadata.
array$protocolsThe protocols supported. Defaults to ::NS_SAMLP.

Definition at line 475 of file SAMLBuilder.php.

Referenced by addMetadata().

476  {
477  assert(is_array($metadata));
478  assert(is_array($protocols));
479  assert(isset($metadata['entityid']));
480  assert(isset($metadata['metadata-set']));
481 
483 
484  $e = new \SAML2\XML\md\SPSSODescriptor();
485  $e->protocolSupportEnumeration = $protocols;
486 
487  if ($metadata->hasValue('saml20.sign.assertion')) {
488  $e->WantAssertionsSigned = $metadata->getBoolean('saml20.sign.assertion');
489  }
490 
491  if ($metadata->hasValue('redirect.validate')) {
492  $e->AuthnRequestsSigned = $metadata->getBoolean('redirect.validate');
493  } elseif ($metadata->hasValue('validate.authnrequest')) {
494  $e->AuthnRequestsSigned = $metadata->getBoolean('validate.authnrequest');
495  }
496 
497  $this->addExtensions($metadata, $e);
498 
499  $this->addCertificate($e, $metadata);
500 
501  $e->SingleLogoutService = self::createEndpoints($metadata->getEndpoints('SingleLogoutService'), false);
502 
503  $e->NameIDFormat = $metadata->getArrayizeString('NameIDFormat', array());
504 
505  $endpoints = $metadata->getEndpoints('AssertionConsumerService');
506  foreach ($metadata->getArrayizeString('AssertionConsumerService.artifact', array()) as $acs) {
507  $endpoints[] = array(
508  'Binding' => 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',
509  'Location' => $acs,
510  );
511  }
512  $e->AssertionConsumerService = self::createEndpoints($endpoints, true);
513 
515 
516  $this->entityDescriptor->RoleDescriptor[] = $e;
517 
518  foreach ($metadata->getArray('contacts', array()) as $contact) {
519  if (array_key_exists('contactType', $contact) && array_key_exists('emailAddress', $contact)) {
520  $this->addContact($contact['contactType'], \SimpleSAML\Utils\Config\Metadata::getContact($contact));
521  }
522  }
523  }
addContact($type, $details)
Add contact information.
addExtensions(SimpleSAML_Configuration $metadata, \SAML2\XML\md\RoleDescriptor $e)
Add extensions to the metadata.
$metadata['__DYNAMIC:1__']
addAttributeConsumingService(\SAML2\XML\md\SPSSODescriptor $spDesc, SimpleSAML_Configuration $metadata)
Add an AttributeConsumingService element to the metadata.
Attribute-related utility methods.
addCertificate(\SAML2\XML\md\RoleDescriptor $rd, SimpleSAML_Configuration $metadata)
Add a certificate.
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
+ Here is the caller graph for this function:

◆ addOrganization()

SimpleSAML_Metadata_SAMLBuilder::addOrganization ( array  $orgName,
array  $orgDisplayName,
array  $orgURL 
)

Add an Organization element based on data passed as parameters.

Parameters
array$orgNameAn array with the localized OrganizationName.
array$orgDisplayNameAn array with the localized OrganizationDisplayName.
array$orgURLAn array with the localized OrganizationURL.

Definition at line 283 of file SAMLBuilder.php.

References $orgName.

Referenced by addOrganizationInfo().

284  {
285  $org = new \SAML2\XML\md\Organization();
286 
287  $org->OrganizationName = $orgName;
288  $org->OrganizationDisplayName = $orgDisplayName;
289  $org->OrganizationURL = $orgURL;
290 
291  $this->entityDescriptor->Organization = $org;
292  }
if($name !==null &&!empty($attributes)) $orgName
Definition: metadata.php:178
+ Here is the caller graph for this function:

◆ addOrganizationInfo()

SimpleSAML_Metadata_SAMLBuilder::addOrganizationInfo ( array  $metadata)

Add an Organization element based on metadata array.

Parameters
array$metadataThe metadata we should extract the organization information from.

Definition at line 300 of file SAMLBuilder.php.

References $orgName, addOrganization(), and SimpleSAML\Utils\Arrays\arrayize().

301  {
302  if (empty($metadata['OrganizationName']) ||
303  empty($metadata['OrganizationDisplayName']) ||
304  empty($metadata['OrganizationURL'])
305  ) {
306  // empty or incomplete organization information
307  return;
308  }
309 
310  $orgName = SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationName'], 'en');
311  $orgDisplayName = SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationDisplayName'], 'en');
312  $orgURL = SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationURL'], 'en');
313 
314  $this->addOrganization($orgName, $orgDisplayName, $orgURL);
315  }
addOrganization(array $orgName, array $orgDisplayName, array $orgURL)
Add an Organization element based on data passed as parameters.
static arrayize($data, $index=0)
Put a non-array variable into an array.
Definition: Arrays.php:24
$metadata['__DYNAMIC:1__']
if($name !==null &&!empty($attributes)) $orgName
Definition: metadata.php:178
+ Here is the call graph for this function:

◆ addSecurityTokenServiceType()

SimpleSAML_Metadata_SAMLBuilder::addSecurityTokenServiceType (   $metadata)

Add a SecurityTokenServiceType for ADFS metadata.

Parameters
array$metadataThe metadata with the information about the SecurityTokenServiceType.

Definition at line 117 of file SAMLBuilder.php.

References $metadata, addCertificate(), and SimpleSAML_Configuration\loadFromArray().

118  {
119  assert(is_array($metadata));
120  assert(isset($metadata['entityid']));
121  assert(isset($metadata['metadata-set']));
122 
124  $defaultEndpoint = $metadata->getDefaultEndpoint('SingleSignOnService');
126  $e->Location = $defaultEndpoint['Location'];
127 
128  $this->addCertificate($e, $metadata);
129 
130  $this->entityDescriptor->RoleDescriptor[] = $e;
131  }
$metadata['__DYNAMIC:1__']
addCertificate(\SAML2\XML\md\RoleDescriptor $rd, SimpleSAML_Configuration $metadata)
Add a certificate.
static loadFromArray($config, $location='[ARRAY]', $instance=null)
Loads a configuration from the given array.
+ Here is the call graph for this function:

◆ addX509KeyDescriptor()

SimpleSAML_Metadata_SAMLBuilder::addX509KeyDescriptor ( \SAML2\XML\md\RoleDescriptor  $rd,
  $use,
  $x509data 
)
private

Add a KeyDescriptor with an X509 certificate.

Parameters
\SAML2\XML\md\RoleDescriptor$rdThe RoleDescriptor the certificate should be added to.
string$useThe value of the 'use' attribute.
string$x509dataThe certificate data.

Definition at line 739 of file SAMLBuilder.php.

740  {
741  assert(in_array($use, array('encryption', 'signing'), true));
742  assert(is_string($x509data));
743 
744  $keyDescriptor = \SAML2\Utils::createKeyDescriptor($x509data);
745  $keyDescriptor->use = $use;
746  $rd->KeyDescriptor[] = $keyDescriptor;
747  }
static createKeyDescriptor($x509Data)
Create a KeyDescriptor with the given certificate.
Definition: Utils.php:683

◆ createEndpoints()

static SimpleSAML_Metadata_SAMLBuilder::createEndpoints ( array  $endpoints,
  $indexed 
)
staticprivate

Add a list of endpoints to metadata.

Parameters
array$endpointsThe endpoints.
bool$indexedWhether the endpoints should be indexed.
Returns
array An array of endpoint objects, either or .

Definition at line 326 of file SAMLBuilder.php.

References $ret, and $t.

327  {
328  assert(is_bool($indexed));
329 
330  $ret = array();
331 
332  foreach ($endpoints as &$ep) {
333  if ($indexed) {
334  $t = new \SAML2\XML\md\IndexedEndpointType();
335  } else {
336  $t = new \SAML2\XML\md\EndpointType();
337  }
338 
339  $t->Binding = $ep['Binding'];
340  $t->Location = $ep['Location'];
341  if (isset($ep['ResponseLocation'])) {
342  $t->ResponseLocation = $ep['ResponseLocation'];
343  }
344  if (isset($ep['hoksso:ProtocolBinding'])) {
345  $t->setAttributeNS(
346  \SAML2\Constants::NS_HOK,
347  'hoksso:ProtocolBinding',
348  \SAML2\Constants::BINDING_HTTP_REDIRECT
349  );
350  }
351 
352  if ($indexed) {
353  if (!isset($ep['index'])) {
354  // Find the maximum index
355  $maxIndex = -1;
356  foreach ($endpoints as $ep) {
357  if (!isset($ep['index'])) {
358  continue;
359  }
360 
361  if ($ep['index'] > $maxIndex) {
362  $maxIndex = $ep['index'];
363  }
364  }
365 
366  $ep['index'] = $maxIndex + 1;
367  }
368 
369  $t->index = $ep['index'];
370  }
371 
372  $ret[] = $t;
373  }
374 
375  return $ret;
376  }
$ret
Definition: parser.php:6

◆ getEntityDescriptor()

SimpleSAML_Metadata_SAMLBuilder::getEntityDescriptor ( )

Retrieve the EntityDescriptor element which is generated for this entity.

Returns
DOMElement The EntityDescriptor element of this entity.

Definition at line 81 of file SAMLBuilder.php.

References $xml.

Referenced by getEntityDescriptorText().

82  {
83  $xml = $this->entityDescriptor->toXML();
84  $xml->ownerDocument->appendChild($xml);
85 
86  return $xml;
87  }
+ Here is the caller graph for this function:

◆ getEntityDescriptorText()

SimpleSAML_Metadata_SAMLBuilder::getEntityDescriptorText (   $formatted = true)

Retrieve the EntityDescriptor as text.

This function serializes this EntityDescriptor, and returns it as text.

Parameters
bool$formattedWhether the returned EntityDescriptor should be formatted first.
Returns
string The serialized EntityDescriptor.

Definition at line 99 of file SAMLBuilder.php.

References $xml, and getEntityDescriptor().

100  {
101  assert(is_bool($formatted));
102 
103  $xml = $this->getEntityDescriptor();
104  if ($formatted) {
105  SimpleSAML\Utils\XML::formatDOMElement($xml);
106  }
107 
108  return $xml->ownerDocument->saveXML();
109  }
getEntityDescriptor()
Retrieve the EntityDescriptor element which is generated for this entity.
Definition: SAMLBuilder.php:81
+ Here is the call graph for this function:

◆ setExpiration()

SimpleSAML_Metadata_SAMLBuilder::setExpiration (   $metadata)
private

Definition at line 59 of file SAMLBuilder.php.

References $maxDuration, and $metadata.

Referenced by addMetadata().

60  {
61  if (array_key_exists('expire', $metadata)) {
62  if ($metadata['expire'] - time() < $this->maxDuration) {
63  $this->maxDuration = $metadata['expire'] - time();
64  }
65  }
66 
67  if ($this->maxCache !== null) {
68  $this->entityDescriptor->cacheDuration = 'PT'.$this->maxCache.'S';
69  }
70  if ($this->maxDuration !== null) {
71  $this->entityDescriptor->validUntil = time() + $this->maxDuration;
72  }
73  }
$metadata['__DYNAMIC:1__']
+ Here is the caller graph for this function:

Field Documentation

◆ $entityDescriptor

SimpleSAML_Metadata_SAMLBuilder::$entityDescriptor
private

Definition at line 20 of file SAMLBuilder.php.

◆ $maxCache

SimpleSAML_Metadata_SAMLBuilder::$maxCache = null
private

Definition at line 28 of file SAMLBuilder.php.

Referenced by __construct().

◆ $maxDuration

SimpleSAML_Metadata_SAMLBuilder::$maxDuration = null
private

Definition at line 36 of file SAMLBuilder.php.

Referenced by __construct(), and setExpiration().


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