当前位置: 首页>>代码示例>>PHP>>正文


PHP SAML2_Utils::xpQuery方法代码示例

本文整理汇总了PHP中SAML2_Utils::xpQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP SAML2_Utils::xpQuery方法的具体用法?PHP SAML2_Utils::xpQuery怎么用?PHP SAML2_Utils::xpQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SAML2_Utils的用法示例。


在下文中一共展示了SAML2_Utils::xpQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor for SAML 2 logout request messages.
  *
  * @param DOMElement|NULL $xml The input message.
  * @throws Exception
  */
 public function __construct(DOMElement $xml = NULL)
 {
     parent::__construct('LogoutRequest', $xml);
     $this->sessionIndexes = array();
     if ($xml === NULL) {
         return;
     }
     if ($xml->hasAttribute('NotOnOrAfter')) {
         $this->notOnOrAfter = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('NotOnOrAfter'));
     }
     $nameId = SAML2_Utils::xpQuery($xml, './saml_assertion:NameID | ./saml_assertion:EncryptedID/xenc:EncryptedData');
     if (empty($nameId)) {
         throw new Exception('Missing <saml:NameID> or <saml:EncryptedID> in <samlp:LogoutRequest>.');
     } elseif (count($nameId) > 1) {
         throw new Exception('More than one <saml:NameID> or <saml:EncryptedD> in <samlp:LogoutRequest>.');
     }
     $nameId = $nameId[0];
     if ($nameId->localName === 'EncryptedData') {
         /* The NameID element is encrypted. */
         $this->encryptedNameId = $nameId;
     } else {
         $this->nameId = SAML2_Utils::parseNameId($nameId);
     }
     $sessionIndexes = SAML2_Utils::xpQuery($xml, './saml_protocol:SessionIndex');
     foreach ($sessionIndexes as $sessionIndex) {
         $this->sessionIndexes[] = trim($sessionIndex->textContent);
     }
 }
开发者ID:danielkjfrog,项目名称:docker,代码行数:34,代码来源:LogoutRequest.php

示例2: testMarshalling

 public function testMarshalling()
 {
     $attributeQuery = new SAML2_AttributeQuery();
     $attributeQuery->setNameID(array('Value' => 'NameIDValue'));
     $attributeQuery->setAttributes(array('test1' => array('test1_attrv1', 'test1_attrv2'), 'test2' => array('test2_attrv1', 'test2_attrv2', 'test2_attrv3'), 'test3' => array()));
     $attributeQueryElement = $attributeQuery->toUnsignedXML();
     // Test Attribute Names
     $attributes = SAML2_Utils::xpQuery($attributeQueryElement, './saml_assertion:Attribute');
     $this->assertCount(3, $attributes);
     $this->assertEquals('test1', $attributes[0]->getAttribute('Name'));
     $this->assertEquals('test2', $attributes[1]->getAttribute('Name'));
     $this->assertEquals('test3', $attributes[2]->getAttribute('Name'));
     // Test Attribute Values for Attribute 1
     $av1 = SAML2_Utils::xpQuery($attributes[0], './saml_assertion:AttributeValue');
     $this->assertCount(2, $av1);
     $this->assertEquals('test1_attrv1', $av1[0]->textContent);
     $this->assertEquals('test1_attrv2', $av1[1]->textContent);
     // Test Attribute Values for Attribute 2
     $av2 = SAML2_Utils::xpQuery($attributes[1], './saml_assertion:AttributeValue');
     $this->assertCount(3, $av2);
     $this->assertEquals('test2_attrv1', $av2[0]->textContent);
     $this->assertEquals('test2_attrv2', $av2[1]->textContent);
     $this->assertEquals('test2_attrv3', $av2[2]->textContent);
     // Test Attribute Values for Attribute 3
     $av3 = SAML2_Utils::xpQuery($attributes[2], './saml_assertion:AttributeValue');
     $this->assertCount(0, $av3);
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:27,代码来源:AttributeQueryTest.php

示例3: __construct

 /**
  * Constructor for SAML 2 response messages.
  *
  * @param string $tagName  The tag name of the root element.
  * @param DOMElement|NULL $xml  The input message.
  */
 protected function __construct($tagName, DOMElement $xml = NULL)
 {
     parent::__construct($tagName, $xml);
     $this->status = array('Code' => SAML2_Const::STATUS_SUCCESS, 'SubCode' => NULL, 'Message' => NULL);
     if ($xml === NULL) {
         return;
     }
     if ($xml->hasAttribute('InResponseTo')) {
         $this->inResponseTo = $xml->getAttribute('InResponseTo');
     }
     $status = SAML2_Utils::xpQuery($xml, './saml_protocol:Status');
     if (empty($status)) {
         throw new Exception('Missing status code on response.');
     }
     $status = $status[0];
     $statusCode = SAML2_Utils::xpQuery($status, './saml_protocol:StatusCode');
     if (empty($statusCode)) {
         throw new Exception('Missing status code in status element.');
     }
     $statusCode = $statusCode[0];
     $this->status['Code'] = $statusCode->getAttribute('Value');
     $subCode = SAML2_Utils::xpQuery($statusCode, './saml_protocol:StatusCode');
     if (!empty($subCode)) {
         $this->status['SubCode'] = $subCode[0]->getAttribute('Value');
     }
     $message = SAML2_Utils::xpQuery($status, './saml_protocol:StatusMessage');
     if (!empty($message)) {
         $this->status['Message'] = trim($message[0]->textContent);
     }
 }
开发者ID:filonuse,项目名称:fedlab,代码行数:36,代码来源:StatusResponse.php

示例4: __construct

 /**
  * Create a ECP Request element.
  *
  * @param DOMElement|NULL $xml  The XML element we should load.
  */
 public function __construct(DOMElement $xml = NULL)
 {
     if ($xml === NULL) {
         return;
     }
     if ($this->checkXML($xml) !== TRUE) {
         throw new Exception($this->checkXML($xml));
     }
     if ($xml->hasAttribute('ProviderName')) {
         $this->ProviderName = $xml->getAttribute('ProviderName');
     }
     $this->IsPassive = SAML2_Utils::parseBoolean($xml, 'IsPassive', NULL);
     $issuer = SAML2_Utils::xpQuery($xml, './saml_assertion:Issuer');
     if (empty($issuer)) {
         throw new Exception('Missing <saml:Issuer> in <ecp:Request>.');
     } elseif (count($issuer) > 1) {
         throw new Exception('More than one <saml:Issuer> in <ecp:Request>.');
     }
     $this->Issuer = trim($issuer[0]->textContent);
     $idpList = SAML2_Utils::xpQuery($xml, './saml_protocol:IDPList');
     if (count($idpList) === 1) {
         $this->IDPList = new SAML2_XML_samlp_IDPList($idpList[0]);
     } elseif (count($idpList) > 1) {
         throw new Exception('More than one <samlp:IDPList> in ECP Request.');
     }
 }
开发者ID:sitya,项目名称:saml2,代码行数:31,代码来源:Request.php

示例5: testUnmarshalling

    public function testUnmarshalling()
    {
        $mdNamespace = SAML2_Const::NS_MD;
        $document = SAML2_DOMDocumentFactory::fromString(<<<XML
<md:Test xmlns:md="{$mdNamespace}" Binding="urn:something" Location="https://whatever/" xmlns:test="urn:test" test:attr="value" />
XML
);
        $endpointType = new SAML2_XML_md_EndpointType($document->firstChild);
        $this->assertEquals(TRUE, $endpointType->hasAttributeNS('urn:test', 'attr'));
        $this->assertEquals('value', $endpointType->getAttributeNS('urn:test', 'attr'));
        $this->assertEquals(FALSE, $endpointType->hasAttributeNS('urn:test', 'invalid'));
        $this->assertEquals('', $endpointType->getAttributeNS('urn:test', 'invalid'));
        $endpointType->removeAttributeNS('urn:test', 'attr');
        $this->assertEquals(FALSE, $endpointType->hasAttributeNS('urn:test', 'attr'));
        $this->assertEquals('', $endpointType->getAttributeNS('urn:test', 'attr'));
        $endpointType->setAttributeNS('urn:test2', 'test2:attr2', 'value2');
        $this->assertEquals('value2', $endpointType->getAttributeNS('urn:test2', 'attr2'));
        $document->loadXML('<root />');
        $endpointTypeElement = $endpointType->toXML($document->firstChild, 'md:Test');
        $endpointTypeElements = SAML2_Utils::xpQuery($endpointTypeElement, '/root/saml_metadata:Test');
        $this->assertCount(1, $endpointTypeElements);
        $endpointTypeElement = $endpointTypeElements[0];
        $this->assertEquals('value2', $endpointTypeElement->getAttributeNS('urn:test2', 'attr2'));
        $this->assertEquals(FALSE, $endpointTypeElement->hasAttributeNS('urn:test', 'attr'));
    }
开发者ID:Shalmezad,项目名称:saml2,代码行数:25,代码来源:EndpointTypeTest.php

示例6: __construct

 /**
  * Initialize an EntitiesDescriptor.
  *
  * @param DOMElement|NULL $xml The XML element we should load.
  */
 public function __construct(DOMElement $xml = NULL)
 {
     parent::__construct($xml);
     if ($xml === NULL) {
         return;
     }
     if ($xml->hasAttribute('ID')) {
         $this->ID = $xml->getAttribute('ID');
     }
     if ($xml->hasAttribute('validUntil')) {
         $this->validUntil = SAML2_Utils::xsDateTimeToTimestamp($xml->getAttribute('validUntil'));
     }
     if ($xml->hasAttribute('cacheDuration')) {
         $this->cacheDuration = $xml->getAttribute('cacheDuration');
     }
     if ($xml->hasAttribute('Name')) {
         $this->Name = $xml->getAttribute('Name');
     }
     $this->Extensions = SAML2_XML_md_Extensions::getList($xml);
     foreach (SAML2_Utils::xpQuery($xml, './saml_metadata:EntityDescriptor|./saml_metadata:EntitiesDescriptor') as $node) {
         if ($node->localName === 'EntityDescriptor') {
             $this->children[] = new SAML2_XML_md_EntityDescriptor($node);
         } else {
             $this->children[] = new SAML2_XML_md_EntitiesDescriptor($node);
         }
     }
 }
开发者ID:shirlei,项目名称:simplesaml,代码行数:32,代码来源:EntitiesDescriptor.php

示例7: testMarshalling

 public function testMarshalling()
 {
     $indexedEndpointType = new SAML2_XML_md_IndexedEndpointType();
     $indexedEndpointType->Binding = 'TestBinding';
     $indexedEndpointType->Location = 'TestLocation';
     $indexedEndpointType->index = 42;
     $indexedEndpointType->isDefault = FALSE;
     $document = SAML2_DOMDocumentFactory::fromString('<root />');
     $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
     $indexedEndpointElements = SAML2_Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
     $this->assertCount(1, $indexedEndpointElements);
     $indexedEndpointElement = $indexedEndpointElements[0];
     $this->assertEquals('TestBinding', $indexedEndpointElement->getAttribute('Binding'));
     $this->assertEquals('TestLocation', $indexedEndpointElement->getAttribute('Location'));
     $this->assertEquals('42', $indexedEndpointElement->getAttribute('index'));
     $this->assertEquals('false', $indexedEndpointElement->getAttribute('isDefault'));
     $indexedEndpointType->isDefault = TRUE;
     $document->loadXML('<root />');
     $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
     $indexedEndpointTypeElement = SAML2_Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
     $this->assertCount(1, $indexedEndpointTypeElement);
     $this->assertEquals('true', $indexedEndpointTypeElement[0]->getAttribute('isDefault'));
     $indexedEndpointType->isDefault = NULL;
     $document->loadXML('<root />');
     $indexedEndpointTypeElement = $indexedEndpointType->toXML($document->firstChild, 'md:Test');
     $indexedEndpointTypeElement = SAML2_Utils::xpQuery($indexedEndpointTypeElement, '/root/saml_metadata:Test');
     $this->assertCount(1, $indexedEndpointTypeElement);
     $this->assertTrue(!$indexedEndpointTypeElement[0]->hasAttribute('isDefault'));
 }
开发者ID:Shalmezad,项目名称:saml2,代码行数:29,代码来源:IndexedEndpointTypeTest.php

示例8: getList

 /**
  * Get a list of Extensions in the given element.
  *
  * @param DOMElement $parent  The element that may contain the samlp:Extensions element.
  * @return array  Array of extensions.
  */
 public static function getList(DOMElement $parent)
 {
     $ret = array();
     foreach (SAML2_Utils::xpQuery($parent, './saml_protocol:Extensions/*') as $node) {
         $ret[] = new SAML2_XML_Chunk($node);
     }
     return $ret;
 }
开发者ID:emma5021,项目名称:toba,代码行数:14,代码来源:Extensions.php

示例9: __construct

 public function __construct(DOMElement $xml = NULL)
 {
     parent::__construct('ArtifactResolve', $xml);
     if (!is_null($xml)) {
         $results = SAML2_Utils::xpQuery($xml, './saml_protocol:Artifact');
         $this->artifact = $results[0]->textContent;
     }
 }
开发者ID:emma5021,项目名称:toba,代码行数:8,代码来源:ArtifactResolve.php

示例10: getStringElements

 /**
  * Retrieve the value of a child DOMElements as an array of strings.
  *
  * @param DOMElement $parent  The parent element.
  * @param string $name  The name of the child elements.
  * @return array  The value of the child elements.
  */
 private static function getStringElements(DOMElement $parent, $name)
 {
     assert('is_string($name)');
     $e = SAML2_Utils::xpQuery($parent, './saml_metadata:' . $name);
     $ret = array();
     foreach ($e as $i) {
         $ret[] = $i->textContent;
     }
     return $ret;
 }
开发者ID:emma5021,项目名称:toba,代码行数:17,代码来源:ContactPerson.php

示例11: receive

 /**
  * Receive a SAML 2 message sent using the HTTP-POST binding.
  *
  * Throws an exception if it is unable receive the message.
  *
  * @return SAML2_Message The received message.
  * @throws Exception
  */
 public function receive()
 {
     $postText = file_get_contents('php://input');
     if (empty($postText)) {
         throw new Exception('Invalid message received to AssertionConsumerService endpoint.');
     }
     $document = SAML2_DOMDocumentFactory::fromString($postText);
     $xml = $document->firstChild;
     SAML2_Utils::getContainer()->debugMessage($xml, 'in');
     $results = SAML2_Utils::xpQuery($xml, '/soap-env:Envelope/soap-env:Body/*[1]');
     return SAML2_Message::fromXML($results[0]);
 }
开发者ID:Shalmezad,项目名称:saml2,代码行数:20,代码来源:SOAP.php

示例12: __construct

 /**
  * Create a DiscoHints element.
  *
  * @param DOMElement|NULL $xml The XML element we should load.
  */
 public function __construct(DOMElement $xml = NULL)
 {
     if ($xml === NULL) {
         return;
     }
     $this->IPHint = SAML2_Utils::extractStrings($xml, self::NS, 'IPHint');
     $this->DomainHint = SAML2_Utils::extractStrings($xml, self::NS, 'DomainHint');
     $this->GeolocationHint = SAML2_Utils::extractStrings($xml, self::NS, 'GeolocationHint');
     foreach (SAML2_Utils::xpQuery($xml, "./*[namespace-uri()!='" . self::NS . "']") as $node) {
         $this->children[] = new SAML2_XML_Chunk($node);
     }
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:17,代码来源:DiscoHints.php

示例13: testXpQuery

 /**
  * Test querying a SAML XML document.
  */
 public function testXpQuery()
 {
     $aq = new SAML2_AttributeQuery();
     $aq->setNameID(array('Value' => 'NameIDValue', 'Format' => 'SomeNameIDFormat', 'NameQualifier' => 'OurNameQualifier', 'SPNameQualifier' => 'TheSPNameQualifier'));
     $xml = $aq->toUnsignedXML();
     $nameID = SAML2_Utils::xpQuery($xml, './saml_assertion:Subject/saml_assertion:NameID');
     $this->assertTrue(count($nameID) === 1);
     $this->assertEquals('SomeNameIDFormat', $nameID[0]->getAttribute("Format"));
     $this->assertEquals('OurNameQualifier', $nameID[0]->getAttribute("NameQualifier"));
     $this->assertEquals('TheSPNameQualifier', $nameID[0]->getAttribute("SPNameQualifier"));
     $this->assertEquals('NameIDValue', $nameID[0]->textContent);
 }
开发者ID:shirlei,项目名称:simplesaml,代码行数:15,代码来源:UtilsTest.php

示例14: testValidateWithValueTampering

 /**
  * Test that signatures no longer validate if the value has been tampered with.
  */
 public function testValidateWithValueTampering()
 {
     // Test modification of SignatureValue.
     $signedMockElementCopy = SAML2_Utils::copyElement($this->signedMockElement);
     $signedMockElementCopy->ownerDocument->appendChild($signedMockElementCopy);
     $digestValueElements = SAML2_Utils::xpQuery($signedMockElementCopy, '/root/ds:Signature/ds:SignatureValue');
     $this->assertCount(1, $digestValueElements);
     $digestValueElements[0]->firstChild->data = 'invalid';
     $tmp = new SAML2_SignedElementHelperMock($signedMockElementCopy);
     $this->setExpectedException('Exception', 'Unable to validate Signature');
     $tmp->validate(SAML2_CertificatesMock::getPublicKey());
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:15,代码来源:SignedElementHelperTest.php

示例15: receive

 /**
  * Receive a SAML 2 message sent using the HTTP-POST binding.
  *
  * Throws an exception if it is unable receive the message.
  *
  * @return SAML2_Message  The received message.
  */
 public function receive()
 {
     $postText = file_get_contents('php://input');
     if (empty($postText)) {
         throw new SimpleSAML_Error_BadRequest('Invalid message received to AssertionConsumerService endpoint.');
     }
     $document = new DOMDocument();
     $document->loadXML($postText);
     $xml = $document->firstChild;
     $results = SAML2_Utils::xpQuery($xml, '/soap-env:Envelope/soap-env:Body/*[1]');
     return SAML2_Message::fromXML($results[0]);
 }
开发者ID:filonuse,项目名称:fedlab,代码行数:19,代码来源:SOAP.php


注:本文中的SAML2_Utils::xpQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。