protected function load() { $doc = new \DOMDocument(); $doc->load($this->filename); if ($this->entityId) { $entitiesDescriptor = new EntitiesDescriptor(); $entitiesDescriptor->loadFromXml($doc->firstChild); $this->entityDescriptor = $entitiesDescriptor->getByEntityId($this->entityId); } else { $this->entityDescriptor = new EntityDescriptor(); $this->entityDescriptor->loadFromXml($doc->firstChild); } }
function testOne() { $doc = new \DOMDocument(); $doc->load(__DIR__ . '/../../../../../../../resources/sample/EntityDescriptor/ed01-formatted-certificate.xml'); $ed = new EntityDescriptor(); $ed->loadFromXml($doc->firstChild); $this->checkSP($ed); $this->checkIDP($ed); }
function testOne() { $url = "https://b1.bead.loc/adfs/ls/"; $doc = new \DOMDocument(); $doc->load(__DIR__ . '/../../../../../../../resources/sample/EntityDescriptor/idp2-ed.xml'); $ed = new EntityDescriptor(); $ed->loadFromXml($doc->firstChild); $this->checkSP($ed, $url); $this->checkIDP($ed, $url); }
/** * @param string $file * @return EntityDescriptor * @throws \InvalidArgumentException */ public static function getEntityDescriptorFromXmlFile($file) { if (!is_file($file)) { throw new \InvalidArgumentException("Specified EntityDescriptor path is not a file {$file}"); } $doc = new \DOMDocument(); $doc->load($file); $result = new EntityDescriptor(); $result->loadFromXml($doc->firstChild); return $result; }
/** * @return \AerialShip\LightSaml\Security\X509Certificate */ private function getCertificate() { $ed = new EntityDescriptor(); $doc = new \DOMDocument(); $doc->load(__DIR__ . '/../../../../../../../resources/sample/EntityDescriptor/idp2-ed.xml'); $ed->loadFromXml($doc->firstChild); $arrIdp = $ed->getAllIdpSsoDescriptors(); $idp = $arrIdp[0]; $arrKeys = $idp->findKeyDescriptors('signing'); $k = $arrKeys[0]; $cert = $k->getCertificate(); return $cert; }
private function checkDeserializaton(\DOMElement $root, $entityID, $locationLogout, $locationLogin, X509Certificate $certificate) { $ed = new EntityDescriptor(); $ed->loadFromXml($root); $this->assertEquals($entityID, $ed->getEntityID()); $items = $ed->getItems(); $this->assertEquals(2, count($items)); $this->assertTrue($items[0] instanceof SpSsoDescriptor); $arrSP = $ed->getItemsByType('SpSsoDescriptor'); $this->assertNotEmpty($arrSP); /** @var $sp SpSsoDescriptor */ $sp = $arrSP[0]; $this->assertNotNull($sp); $this->assertTrue($sp instanceof SpSsoDescriptor); $keys = $sp->getKeyDescriptors(); $this->assertEquals(2, count($keys)); $this->assertEquals(KeyDescriptor::USE_SIGNING, $keys[0]->getUse()); $this->assertEquals($certificate->getData(), $keys[0]->getCertificate()->getData()); $this->assertEquals(KeyDescriptor::USE_ENCRYPTION, $keys[1]->getUse()); $this->assertEquals($certificate->getData(), $keys[1]->getCertificate()->getData()); $this->assertEquals(Protocol::SAML2, $sp->getProtocolSupportEnumeration()); $items = $sp->getServices(); $this->assertEquals(3, count($items), print_r($items, true)); $arrLogout = $sp->findSingleLogoutServices(); $this->assertNotEmpty($arrLogout); $logout = $arrLogout[0]; $this->assertNotNull($logout); $this->assertEquals(Bindings::SAML2_HTTP_REDIRECT, $logout->getBinding()); $this->assertEquals($locationLogout, $logout->getLocation()); $arr = $sp->findAssertionConsumerServices(); $this->assertEquals(2, count($arr)); $arr = $sp->findAssertionConsumerServices(Bindings::SAML2_HTTP_POST); $this->assertNotEmpty($arr); $as1 = $arr[0]; $this->assertNotNull($as1); $this->assertEquals(Bindings::SAML2_HTTP_POST, $as1->getBinding()); $this->assertEquals($locationLogin, $as1->getLocation()); $this->assertEquals(0, $as1->getIndex()); $arr = $sp->findAssertionConsumerServices(Bindings::SAML2_HTTP_ARTIFACT); $this->assertNotEmpty($arr); $as2 = $arr[0]; $this->assertNotNull($as2); $this->assertEquals(Bindings::SAML2_HTTP_ARTIFACT, $as2->getBinding()); $this->assertEquals($locationLogin, $as2->getLocation()); $this->assertEquals(1, $as2->getIndex()); }