From bb5ad9cf298b184d74580329364cac4d609047e0 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Wed, 30 May 2018 14:37:17 +0200 Subject: [PATCH] Replace SimpleSAML_Metadata_SAMLBuilder with namespaced version --- lib/SimpleSAML/Metadata/SAMLBuilder.php | 20 ++++++++-------- modules/adfs/www/idp/metadata.php | 2 +- modules/saml/www/sp/metadata.php | 2 +- .../SimpleSAML/Metadata/SAMLBuilderTest.php | 23 ++++++++++--------- www/saml2/idp/metadata.php | 2 +- www/shib13/idp/metadata.php | 2 +- 6 files changed, 26 insertions(+), 25 deletions(-) diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index 60bd0d157..0935e4004 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -1,5 +1,6 @@ <?php +namespace SimpleSAML\Metadata; /** * Class for generating SAML 2.0 metadata from SimpleSAMLphp metadata arrays. @@ -8,10 +9,9 @@ * * @package SimpleSAMLphp */ -class SimpleSAML_Metadata_SAMLBuilder -{ - +class SAMLBuilder +{ /** * The EntityDescriptor we are building. * @@ -76,7 +76,7 @@ class SimpleSAML_Metadata_SAMLBuilder /** * Retrieve the EntityDescriptor element which is generated for this entity. * - * @return DOMElement The EntityDescriptor element of this entity. + * @return \DOMElement The EntityDescriptor element of this entity. */ public function getEntityDescriptor() { @@ -102,7 +102,7 @@ class SimpleSAML_Metadata_SAMLBuilder $xml = $this->getEntityDescriptor(); if ($formatted) { - SimpleSAML\Utils\XML::formatDOMElement($xml); + \SimpleSAML\Utils\XML::formatDOMElement($xml); } return $xml->ownerDocument->saveXML(); @@ -122,7 +122,7 @@ class SimpleSAML_Metadata_SAMLBuilder $metadata = \SimpleSAML\Configuration::loadFromArray($metadata, $metadata['entityid']); $defaultEndpoint = $metadata->getDefaultEndpoint('SingleSignOnService'); - $e = new sspmod_adfs_SAML2_XML_fed_SecurityTokenServiceType(); + $e = new \sspmod_adfs_SAML2_XML_fed_SecurityTokenServiceType(); $e->Location = $defaultEndpoint['Location']; $this->addCertificate($e, $metadata); @@ -307,9 +307,9 @@ class SimpleSAML_Metadata_SAMLBuilder return; } - $orgName = SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationName'], 'en'); - $orgDisplayName = SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationDisplayName'], 'en'); - $orgURL = SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationURL'], 'en'); + $orgName = \SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationName'], 'en'); + $orgDisplayName = \SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationDisplayName'], 'en'); + $orgURL = \SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationURL'], 'en'); $this->addOrganization($orgName, $orgDisplayName, $orgURL); } @@ -461,7 +461,7 @@ class SimpleSAML_Metadata_SAMLBuilder $this->addAttributeAuthority($metadata); break; default: - SimpleSAML\Logger::warning('Unable to generate metadata for unknown type \''.$set.'\'.'); + \SimpleSAML\Logger::warning('Unable to generate metadata for unknown type \''.$set.'\'.'); } } diff --git a/modules/adfs/www/idp/metadata.php b/modules/adfs/www/idp/metadata.php index f12fd78bb..20a745aee 100644 --- a/modules/adfs/www/idp/metadata.php +++ b/modules/adfs/www/idp/metadata.php @@ -121,7 +121,7 @@ try { $metaflat = '$metadata['.var_export($idpentityid, true).'] = '.var_export($metaArray, true).';'; - $metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($idpentityid); + $metaBuilder = new \SimpleSAML\Metadata\SAMLBuilder($idpentityid); $metaBuilder->addSecurityTokenServiceType($metaArray); $metaBuilder->addOrganizationInfo($metaArray); $technicalContactEmail = $config->getString('technicalcontact_email', null); diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php index 9547235cc..d8d3f7ea1 100644 --- a/modules/saml/www/sp/metadata.php +++ b/modules/saml/www/sp/metadata.php @@ -241,7 +241,7 @@ if ($spconfig->hasValue('redirect.sign')) { $metaArray20['metadata-set'] = 'saml20-sp-remote'; $metaArray20['entityid'] = $entityId; -$metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); +$metaBuilder = new \SimpleSAML\Metadata\SAMLBuilder($entityId); $metaBuilder->addMetadataSP20($metaArray20, $supported_protocols); $metaBuilder->addOrganizationInfo($metaArray20); diff --git a/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php b/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php index 01ab8be31..0871ee968 100644 --- a/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php +++ b/tests/lib/SimpleSAML/Metadata/SAMLBuilderTest.php @@ -1,6 +1,7 @@ <?php use PHPUnit\Framework\TestCase; +use SimpleSAML\Metadata\SAMLBuilder; /** * Class SimpleSAML_Metadata_SAMLBuilderTest @@ -29,7 +30,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase ), ); - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); @@ -58,7 +59,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase ), ); - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); @@ -89,7 +90,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase ), ); - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); @@ -118,7 +119,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase ), ); - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); @@ -154,7 +155,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase ), ); - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); @@ -164,7 +165,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase $metadata['attributes.isDefault'] = true; - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); $acs = $spDesc->getElementsByTagName("AttributeConsumingService"); @@ -174,7 +175,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase $metadata['attributes.isDefault'] = false; - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); $acs = $spDesc->getElementsByTagName("AttributeConsumingService"); @@ -201,7 +202,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase ), ); - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); @@ -212,7 +213,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase $metadata['attributes.index'] = 15; - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $spDesc = $samlBuilder->getEntityDescriptor(); @@ -245,7 +246,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase ), ); - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $entityDescriptorXml = $samlBuilder->getEntityDescriptorText(); @@ -260,7 +261,7 @@ class SimpleSAML_Metadata_SAMLBuilderTest extends TestCase 0 => 'urn:oasis:names:tc:SAML:1.1:protocol', 1 => 'urn:oasis:names:tc:SAML:2.0:protocol', ); - $samlBuilder = new SimpleSAML_Metadata_SAMLBuilder($entityId); + $samlBuilder = new SAMLBuilder($entityId); $samlBuilder->addMetadata($set, $metadata); $entityDescriptorXml = $samlBuilder->getEntityDescriptorText(); diff --git a/www/saml2/idp/metadata.php b/www/saml2/idp/metadata.php index f1dd5680b..d68e8473a 100644 --- a/www/saml2/idp/metadata.php +++ b/www/saml2/idp/metadata.php @@ -201,7 +201,7 @@ try { $metaArray['contacts'][] = Metadata::getContact($techcontact); } - $metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($idpentityid); + $metaBuilder = new \SimpleSAML\Metadata\SAMLBuilder($idpentityid); $metaBuilder->addMetadataIdP20($metaArray); $metaBuilder->addOrganizationInfo($metaArray); diff --git a/www/shib13/idp/metadata.php b/www/shib13/idp/metadata.php index b8579fa8f..d580e2d40 100644 --- a/www/shib13/idp/metadata.php +++ b/www/shib13/idp/metadata.php @@ -70,7 +70,7 @@ try { $metaflat = '$metadata['.var_export($idpentityid, true).'] = '.var_export($metaArray, true).';'; - $metaBuilder = new SimpleSAML_Metadata_SAMLBuilder($idpentityid); + $metaBuilder = new \SimpleSAML\Metadata\SAMLBuilder($idpentityid); $metaBuilder->addMetadataIdP11($metaArray); $metaBuilder->addOrganizationInfo($metaArray); $metaBuilder->addContact('technical', \SimpleSAML\Utils\Config\Metadata::getContact(array( -- GitLab