/**
  * @return array|EntityDescriptor[]
  */
 public function all()
 {
     if (null == $this->object) {
         $this->load();
     }
     if ($this->object instanceof EntityDescriptor) {
         return [$this->object];
     } else {
         return $this->object->getAllEntityDescriptors();
     }
 }
 public function test__deserialize_test_shib()
 {
     $context = new DeserializationContext();
     $context->getDocument()->load(__DIR__ . '/../../../../../../resources/sample/EntitiesDescriptor/testshib-providers.xml');
     $entitiesDescriptor = new EntitiesDescriptor();
     $entitiesDescriptor->deserialize($context->getDocument()->firstChild, $context);
     $this->assertEquals('urn:mace:shibboleth:testshib:two', $entitiesDescriptor->getName());
     $this->assertCount(2, $entitiesDescriptor->getAllEntityDescriptors());
     //region IDP
     $ed = $entitiesDescriptor->getByEntityId('https://idp.testshib.org/idp/shibboleth');
     $this->assertNotNull($ed);
     $this->assertEquals('https://idp.testshib.org/idp/shibboleth', $ed->getEntityID());
     $this->assertCount(1, $ed->getAllIdpSsoDescriptors());
     $idp = $ed->getFirstIdpSsoDescriptor();
     $this->assertNotNull($idp);
     $this->assertEquals('urn:oasis:names:tc:SAML:1.1:protocol urn:mace:shibboleth:1.0 urn:oasis:names:tc:SAML:2.0:protocol', $idp->getProtocolSupportEnumeration());
     $this->assertCount(1, $idp->getAllKeyDescriptors());
     KeyDescriptorChecker::checkCertificateCN($this, null, 'idp.testshib.org', $idp->getFirstKeyDescriptor());
     NameIdFormatChecker::check($this, $idp, array(SamlConstants::NAME_ID_FORMAT_TRANSIENT, SamlConstants::NAME_ID_FORMAT_SHIB_NAME_ID));
     $this->assertCount(4, $idp->getAllSingleSignOnServices());
     EndpointChecker::check($this, SamlConstants::BINDING_SHIB1_AUTHN_REQUEST, 'https://idp.testshib.org/idp/profile/Shibboleth/SSO', $idp->getFirstSingleSignOnService(SamlConstants::BINDING_SHIB1_AUTHN_REQUEST));
     EndpointChecker::check($this, SamlConstants::BINDING_SAML2_HTTP_POST, 'https://idp.testshib.org/idp/profile/SAML2/POST/SSO', $idp->getFirstSingleSignOnService(SamlConstants::BINDING_SAML2_HTTP_POST));
     EndpointChecker::check($this, SamlConstants::BINDING_SAML2_HTTP_REDIRECT, 'https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO', $idp->getFirstSingleSignOnService(SamlConstants::BINDING_SAML2_HTTP_REDIRECT));
     EndpointChecker::check($this, SamlConstants::BINDING_SAML2_SOAP, 'https://idp.testshib.org/idp/profile/SAML2/SOAP/ECP', $idp->getFirstSingleSignOnService(SamlConstants::BINDING_SAML2_SOAP));
     $this->assertEmpty($idp->getAllSingleLogoutServices());
     $this->assertEmpty($idp->getAllAttributes());
     $this->assertEmpty($idp->getAllOrganizations());
     $this->assertEmpty($idp->getAllContactPersons());
     $this->assertCount(1, $ed->getAllOrganizations());
     OrganizationChecker::check($this, 'TestShib Two Identity Provider', 'TestShib Two', 'http://www.testshib.org/testshib-two/', $ed->getFirstOrganization());
     $this->assertCount(1, $ed->getAllContactPersons());
     ContactPersonChecker::check($this, ContactPerson::TYPE_TECHNICAL, null, 'Nate', 'Klingenstein', '*****@*****.**', null, $ed->getFirstContactPerson());
     unset($idp);
     //endregion
     //region SP
     $ed = $entitiesDescriptor->getByEntityId('https://sp.testshib.org/shibboleth-sp');
     $this->assertNotNull($ed);
     $this->assertEquals('https://sp.testshib.org/shibboleth-sp', $ed->getEntityID());
     $this->assertCount(1, $ed->getAllSpSsoDescriptors());
     $sp = $ed->getFirstSpSsoDescriptor();
     $this->assertNotNull($sp);
     $this->assertEquals('urn:oasis:names:tc:SAML:2.0:protocol urn:oasis:names:tc:SAML:1.1:protocol http://schemas.xmlsoap.org/ws/2003/07/secext', $sp->getProtocolSupportEnumeration());
     $this->assertCount(1, $sp->getAllKeyDescriptors());
     KeyDescriptorChecker::checkCertificateCN($this, null, 'sp.testshib.org', $sp->getFirstKeyDescriptor());
     $this->assertCount(4, $sp->getAllSingleLogoutServices());
     EndpointChecker::check($this, SamlConstants::BINDING_SAML2_SOAP, 'https://sp.testshib.org/Shibboleth.sso/SLO/SOAP', $sp->getFirstSingleLogoutService(SamlConstants::BINDING_SAML2_SOAP));
     EndpointChecker::check($this, SamlConstants::BINDING_SAML2_HTTP_REDIRECT, 'https://sp.testshib.org/Shibboleth.sso/SLO/Redirect', $sp->getFirstSingleLogoutService(SamlConstants::BINDING_SAML2_HTTP_REDIRECT));
     EndpointChecker::check($this, SamlConstants::BINDING_SAML2_HTTP_POST, 'https://sp.testshib.org/Shibboleth.sso/SLO/POST', $sp->getFirstSingleLogoutService(SamlConstants::BINDING_SAML2_HTTP_POST));
     EndpointChecker::check($this, SamlConstants::BINDING_SAML2_HTTP_ARTIFACT, 'https://sp.testshib.org/Shibboleth.sso/SLO/Artifact', $sp->getFirstSingleLogoutService(SamlConstants::BINDING_SAML2_HTTP_ARTIFACT));
     NameIdFormatChecker::check($this, $sp, array(SamlConstants::NAME_ID_FORMAT_TRANSIENT, SamlConstants::NAME_ID_FORMAT_SHIB_NAME_ID));
     $this->assertCount(8, $sp->getAllAssertionConsumerServices());
     IndexedEndpointChecker::check($this, SamlConstants::BINDING_SAML2_HTTP_POST, 'https://sp.testshib.org/Shibboleth.sso/SAML2/POST', 1, true, $sp->getFirstAssertionConsumerService(SamlConstants::BINDING_SAML2_HTTP_POST));
     IndexedEndpointChecker::check($this, SamlConstants::BINDING_SAML2_HTTP_POST_SIMPLE_SIGN, 'https://sp.testshib.org/Shibboleth.sso/SAML2/POST-SimpleSign', 2, false, $sp->getFirstAssertionConsumerService(SamlConstants::BINDING_SAML2_HTTP_POST_SIMPLE_SIGN));
     IndexedEndpointChecker::check($this, SamlConstants::BINDING_SAML2_HTTP_ARTIFACT, 'https://sp.testshib.org/Shibboleth.sso/SAML2/Artifact', 3, false, $sp->getFirstAssertionConsumerService(SamlConstants::BINDING_SAML2_HTTP_ARTIFACT));
     IndexedEndpointChecker::check($this, SamlConstants::BINDING_SAML1_BROWSER_POST, 'https://sp.testshib.org/Shibboleth.sso/SAML/POST', 4, false, $sp->getFirstAssertionConsumerService(SamlConstants::BINDING_SAML1_BROWSER_POST));
     IndexedEndpointChecker::check($this, SamlConstants::BINDING_SAML1_ARTIFACT1, 'https://sp.testshib.org/Shibboleth.sso/SAML/Artifact', 5, false, $sp->getFirstAssertionConsumerService(SamlConstants::BINDING_SAML1_ARTIFACT1));
     IndexedEndpointChecker::check($this, SamlConstants::BINDING_WS_FED_WEB_SVC, 'https://sp.testshib.org/Shibboleth.sso/ADFS', 6, false, $sp->getFirstAssertionConsumerService(SamlConstants::BINDING_WS_FED_WEB_SVC));
     $this->assertCount(1, $ed->getAllOrganizations());
     OrganizationChecker::check($this, 'TestShib Two Service Provider', 'TestShib Two', 'http://www.testshib.org/testshib-two/', $ed->getFirstOrganization());
     $this->assertCount(1, $ed->getAllContactPersons());
     ContactPersonChecker::check($this, ContactPerson::TYPE_TECHNICAL, null, 'Nate', 'Klingenstein', '*****@*****.**', null, $ed->getFirstContactPerson());
     unset($sp);
     //endregion
 }
Ejemplo n.º 3
0
 public function test__return_recursively_all_entity_descriptors()
 {
     $esd1 = new EntitiesDescriptor();
     $esd1->addItem(new EntityDescriptor('ed1'));
     $esd1->addItem(new EntityDescriptor('ed2'));
     $esd2 = new EntitiesDescriptor();
     $esd2->addItem(new EntityDescriptor('ed3'));
     $esd1->addItem($esd2);
     $esd3 = new EntitiesDescriptor();
     $esd3->addItem(new EntityDescriptor('ed4'));
     $esd2->addItem($esd3);
     $all = $esd1->getAllEntityDescriptors();
     $this->assertCount(4, $all);
     $this->assertContainsOnlyInstancesOf('LightSaml\\Model\\Metadata\\EntityDescriptor', $all);
     $this->assertEquals('ed1', $all[0]->getEntityID());
     $this->assertEquals('ed2', $all[1]->getEntityID());
     $this->assertEquals('ed3', $all[2]->getEntityID());
     $this->assertEquals('ed4', $all[3]->getEntityID());
 }
 public function test_deserialize_ukfederation_metadata()
 {
     $context = new DeserializationContext();
     $context->getDocument()->load(__DIR__ . '/../../../../../../resources/sample/EntitiesDescriptor/ukfederation-metadata.xml');
     $entitiesDescriptor = new EntitiesDescriptor();
     $entitiesDescriptor->deserialize($context->getDocument(), $context);
     $this->assertCount(2935, $entitiesDescriptor->getAllEntityDescriptors());
 }