|
20 | 20 | use SimpleSAML\Module\adfs\IdP\ADFS as ADFS_IdP; |
21 | 21 | use SimpleSAML\Module\admin\Event\FederationPageEvent; |
22 | 22 | use SimpleSAML\Module\saml\IdP\SAML2 as SAML2_IdP; |
| 23 | +use SimpleSAML\Module\saml\MetadataBuilder; |
23 | 24 | use SimpleSAML\Utils; |
24 | 25 | use SimpleSAML\XHTML\Template; |
25 | 26 | use Symfony\Component\HttpFoundation\Request; |
@@ -248,15 +249,15 @@ private function getHostedIdP(): array |
248 | 249 | sprintf('The entityID cannot be longer than %d characters.', C::SAML2INT_ENTITYID_MAX_LENGTH), |
249 | 250 | ); |
250 | 251 |
|
251 | | - $builder = new SAMLBuilder($entity['entityid']); |
252 | | - $builder->addMetadataIdP20($entity['metadata_array']); |
253 | | - $builder->addOrganizationInfo($entity['metadata_array']); |
254 | | - |
255 | | - $entity['metadata'] = Signer::sign( |
256 | | - $builder->getEntityDescriptorText(), |
257 | | - $entity['metadata_array'], |
258 | | - 'SAML 2 IdP', |
| 252 | + $builder = new MetadataBuilder( |
| 253 | + $this->config, |
| 254 | + Configuration::loadFromArray($entity['metadata_array']), |
259 | 255 | ); |
| 256 | + $document = $builder->buildDocument()->toXML(); |
| 257 | + $document->ownerDocument->formatOutput = true; |
| 258 | + $document->ownerDocument->encoding = 'UTF-8'; |
| 259 | + |
| 260 | + $entity['metadata'] = $document->ownerDocument?->saveXML(); |
260 | 261 | $entities[$index] = $entity; |
261 | 262 | } |
262 | 263 | } catch (Exception $e) { |
@@ -294,20 +295,15 @@ private function getHostedIdP(): array |
294 | 295 | sprintf('The entityID cannot be longer than %d characters.', C::SAML2INT_ENTITYID_MAX_LENGTH), |
295 | 296 | ); |
296 | 297 |
|
297 | | - $builder = new SAMLBuilder($entity['entityid']); |
298 | | - $builder->addSecurityTokenServiceType($entity['metadata_array']); |
299 | | - $builder->addOrganizationInfo($entity['metadata_array']); |
300 | | - if (isset($entity['metadata_array']['contacts'])) { |
301 | | - foreach ($entity['metadata_array']['contacts'] as $contact) { |
302 | | - $builder->addContact(Utils\Config\Metadata::getContact($contact)); |
303 | | - } |
304 | | - } |
305 | | - |
306 | | - $entity['metadata'] = Signer::sign( |
307 | | - $builder->getEntityDescriptorText(), |
308 | | - $entity['metadata_array'], |
309 | | - 'ADFS IdP', |
| 298 | + $builder = new MetadataBuilder( |
| 299 | + $this->config, |
| 300 | + Configuration::loadFromArray($entity['metadata_array']), |
310 | 301 | ); |
| 302 | + $document = $builder->buildDocument()->toXML(); |
| 303 | + $document->ownerDocument->formatOutput = true; |
| 304 | + $document->ownerDocument->encoding = 'UTF-8'; |
| 305 | + |
| 306 | + $entity['metadata'] = $document->ownerDocument->saveXML(); |
311 | 307 | $entities[$index] = $entity; |
312 | 308 | } |
313 | 309 | } catch (Exception $e) { |
@@ -379,23 +375,18 @@ private function getHostedSP(): array |
379 | 375 | ), |
380 | 376 | ); |
381 | 377 |
|
382 | | - $builder = new SAMLBuilder($source->getEntityId()); |
383 | | - $builder->addMetadataSP20($metadata, $source->getSupportedProtocols()); |
384 | | - $builder->addOrganizationInfo($metadata); |
385 | | - $xml = $builder->getEntityDescriptorText(true); |
386 | | - |
387 | | - // sanitize the resulting array |
388 | | - unset($metadata['metadata-set']); |
389 | | - unset($metadata['entityid']); |
| 378 | + $builder = new MetadataBuilder(Configuration::getInstance(), Configuration::loadFromArray($metadata)); |
| 379 | + $entityDescriptor = $builder->buildDocument(); |
| 380 | + $document = $entityDescriptor->toXML(); |
| 381 | + $document->ownerDocument->formatOutput = true; |
| 382 | + $document->ownerDocument->encoding = 'UTF-8'; |
| 383 | + $xml = $document->ownerDocument->saveXML(); |
390 | 384 |
|
391 | 385 | // sanitize the attributes array to remove friendly names |
392 | 386 | if (isset($metadata['attributes']) && is_array($metadata['attributes'])) { |
393 | 387 | $metadata['attributes'] = array_values($metadata['attributes']); |
394 | 388 | } |
395 | 389 |
|
396 | | - // sign the metadata if enabled |
397 | | - $xml = Signer::sign($xml, $source->getMetadata()->toArray(), 'SAML 2 SP'); |
398 | | - |
399 | 390 | $entities[] = [ |
400 | 391 | 'authid' => $source->getAuthId(), |
401 | 392 | 'entityid' => $source->getEntityId(), |
|
0 commit comments