/** * Test retrieval of a localized string for a given node. */ public function testExtractLocalizedString() { $document = SAML2_DOMDocumentFactory::fromString('<root xmlns="' . SAML2_Const::NS_MD . '">' . '<somenode xml:lang="en">value (en)</somenode>' . '<somenode xml:lang="no">value (no)</somenode>' . '</root>'); $localizedStringValues = SAML2_Utils::extractLocalizedStrings($document->firstChild, SAML2_Const::NS_MD, 'somenode'); $this->assertTrue(count($localizedStringValues) === 2); $this->assertEquals('value (en)', $localizedStringValues["en"]); $this->assertEquals('value (no)', $localizedStringValues["no"]); }
/** * Create/parse a mdrpi:RegistrationInfo element. * * @param DOMElement|NULL $xml The XML element we should load. */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if (!$xml->hasAttribute('registrationAuthority')) { throw new Exception('Missing required attribute "registrationAuthority" in mdrpi:RegistrationInfo element.'); } $this->registrationAuthority = $xml->getAttribute('registrationAuthority'); if ($xml->hasAttribute('registrationInstant')) { $this->registrationInstant = SimpleSAML_Utilities::parseSAML2Time($xml->getAttribute('registrationInstant')); } $this->RegistrationPolicy = SAML2_Utils::extractLocalizedStrings($xml, SAML2_XML_mdrpi_Common::NS_MDRPI, 'RegistrationPolicy'); }
/** * Create/parse a mdrpi:PublicationInfo element. * * @param DOMElement|NULL $xml The XML element we should load. * @throws Exception */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if (!$xml->hasAttribute('publisher')) { throw new Exception('Missing required attribute "publisher" in mdrpi:PublicationInfo element.'); } $this->publisher = $xml->getAttribute('publisher'); if ($xml->hasAttribute('creationInstant')) { $this->creationInstant = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('creationInstant')); } if ($xml->hasAttribute('publicationId')) { $this->publicationId = $xml->getAttribute('publicationId'); } $this->UsagePolicy = SAML2_Utils::extractLocalizedStrings($xml, SAML2_XML_mdrpi_Common::NS_MDRPI, 'UsagePolicy'); }
/** * Initialize / parse an AttributeConsumingService. * * @param DOMElement|NULL $xml The XML element we should load. * @throws Exception */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } if (!$xml->hasAttribute('index')) { throw new Exception('Missing index on AttributeConsumingService.'); } $this->index = (int) $xml->getAttribute('index'); $this->isDefault = SAML2_Utils::parseBoolean($xml, 'isDefault', NULL); $this->ServiceName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'ServiceName'); if (empty($this->ServiceName)) { throw new Exception('Missing ServiceName in AttributeConsumingService.'); } $this->ServiceDescription = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'ServiceDescription'); foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:RequestedAttribute') as $ra) { $this->RequestedAttribute[] = new SAML2_XML_md_RequestedAttribute($ra); } }
/** * Initialize an Organization element. * * @param DOMElement|NULL $xml The XML element we should load. */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } $this->Extensions = SAML2_XML_md_Extensions::getList($xml); $this->OrganizationName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'OrganizationName'); if (empty($this->OrganizationName)) { $this->OrganizationName = array('invalid' => ''); } $this->OrganizationDisplayName = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'OrganizationDisplayName'); if (empty($this->OrganizationDisplayName)) { $this->OrganizationDisplayName = array('invalid' => ''); } $this->OrganizationURL = SAML2_Utils::extractLocalizedStrings($xml, SAML2_Const::NS_MD, 'OrganizationURL'); if (empty($this->OrganizationURL)) { $this->OrganizationURL = array('invalid' => ''); } }
/** * Create a UIInfo element. * * @param DOMElement|NULL $xml The XML element we should load. */ public function __construct(DOMElement $xml = NULL) { if ($xml === NULL) { return; } $this->DisplayName = SAML2_Utils::extractLocalizedStrings($xml, self::NS, 'DisplayName'); $this->Description = SAML2_Utils::extractLocalizedStrings($xml, self::NS, 'Description'); $this->InformationURL = SAML2_Utils::extractLocalizedStrings($xml, self::NS, 'InformationURL'); $this->PrivacyStatementURL = SAML2_Utils::extractLocalizedStrings($xml, self::NS, 'PrivacyStatementURL'); foreach (SAML2_Utils::xpQuery($xml, './*') as $node) { if ($node->namespaceURI === self::NS) { switch ($node->localName) { case 'Keywords': $this->Keywords[] = new SAML2_XML_mdui_Keywords($node); break; case 'Logo': $this->Logo[] = new SAML2_XML_mdui_Logo($node); break; } } else { $this->children[] = new SAML2_XML_Chunk($node); } } }