本文整理汇总了PHP中SimpleSAML_Utilities::isDOMElementOfType方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSAML_Utilities::isDOMElementOfType方法的具体用法?PHP SimpleSAML_Utilities::isDOMElementOfType怎么用?PHP SimpleSAML_Utilities::isDOMElementOfType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleSAML_Utilities
的用法示例。
在下文中一共展示了SimpleSAML_Utilities::isDOMElementOfType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extractResponse
/**
* Extract the response element from the SOAP response.
*
* @param string $soapResponse The SOAP response.
* @return string The <saml1p:Response> element, as a string.
*/
private static function extractResponse($soapResponse)
{
assert('is_string($soapResponse)');
$doc = new DOMDocument();
if (!$doc->loadXML($soapResponse)) {
throw new SimpleSAML_Error_Exception('Error parsing SAML 1 artifact response.');
}
$soapEnvelope = $doc->firstChild;
if (!SimpleSAML_Utilities::isDOMElementOfType($soapEnvelope, 'Envelope', 'http://schemas.xmlsoap.org/soap/envelope/')) {
throw new SimpleSAML_Error_Exception('Expected artifact response to contain a <soap:Envelope> element.');
}
$soapBody = SimpleSAML_Utilities::getDOMChildren($soapEnvelope, 'Body', 'http://schemas.xmlsoap.org/soap/envelope/');
if (count($soapBody) === 0) {
throw new SimpleSAML_Error_Exception('Couldn\'t find <soap:Body> in <soap:Envelope>.');
}
$soapBody = $soapBody[0];
$responseElement = SimpleSAML_Utilities::getDOMChildren($soapBody, 'Response', 'urn:oasis:names:tc:SAML:1.0:protocol');
if (count($responseElement) === 0) {
throw new SimpleSAML_Error_Exception('Couldn\'t find <saml1p:Response> in <soap:Body>.');
}
$responseElement = $responseElement[0];
/*
* Save the <saml1p:Response> element. Note that we need to import it
* into a new document, in order to preserve namespace declarations.
*/
$newDoc = new DOMDocument();
$newDoc->appendChild($newDoc->importNode($responseElement, TRUE));
$responseXML = $newDoc->saveXML();
return $responseXML;
}
示例2: findEntityDescriptor
/**
* This function locates the EntityDescriptor node in a DOMDocument. This node should
* be the first (and only) node in the document.
*
* This function will throw an exception if it is unable to locate the node.
*
* @param $doc The DOMDocument where we should find the EntityDescriptor node.
* @return The DOMEntity which represents the EntityDescriptor.
*/
private static function findEntityDescriptor($doc)
{
assert('$doc instanceof DOMDocument');
/* Find the EntityDescriptor DOMElement. This should be the first (and only) child of the
* DOMDocument.
*/
$ed = $doc->documentElement;
if ($ed === NULL) {
throw new Exception('Failed to load SAML metadata from empty XML document.');
}
if (SimpleSAML_Utilities::isDOMElementOfType($ed, 'EntityDescriptor', '@md') === FALSE) {
throw new Exception('Expected first element in the metadata document to be an EntityDescriptor element.');
}
return new SAML2_XML_md_EntityDescriptor($ed);
}
示例3: catch
if ($ok !== TRUE) {
$doc = NULL;
}
} catch (DOMException $e) {
$doc = NULL;
}
$errors = SimpleSAML_XML_Errors::end();
if ($doc === NULL || count($errors) > 0) {
$t->data['status'] = 'invalidxml';
$t->data['errortext'] = SimpleSAML_XML_Errors::formatErrors($errors);
$t->show();
exit;
}
$metadata = $doc->firstChild;
/* Check that the metadata is an EntityDescriptor */
if (!SimpleSAML_Utilities::isDOMElementOfType($metadata, 'EntityDescriptor', '@md')) {
$t->data['status'] = 'notentitydescriptor';
$t->show();
exit;
}
/* Check that the entity id of the metadata matches the URL. */
$entityId = $metadata->getAttribute('entityID');
if ($entityId !== $url) {
$t->data['status'] = 'entityid';
$t->data['errortext'] = 'Entity id: ' . $entityId . "\n" . 'URL: ' . $url . "\n";
$t->show();
exit;
}
/* Validate the metadata against the metadata schema (if enabled). */
if ($metaConfig->getBoolean('metashare.validateschema')) {
$errors = SimpleSAML_Utilities::validateXML($doc, 'saml-schema-metadata-2.0.xsd');
示例4: loadXML
/**
* Parse XML metadata and return entities
*/
private function loadXML($data, $source)
{
$entities = array();
$doc = new DOMDocument();
$res = $doc->loadXML($data);
if ($res !== TRUE) {
throw new Exception('Failed to read XML from ' . $source['src']);
}
if ($doc->documentElement === NULL) {
throw new Exception('Opened file is not an XML document: ' . $source['src']);
}
if (SimpleSAML_Utilities::isDOMElementOfType($doc->documentElement, 'EntitiesDescriptor', '@md') === TRUE) {
foreach (SAML2_Utils::xpQuery($doc->documentElement, './saml_metadata:EntityDescriptor|./saml_metadata:EntitiesDescriptor') as $node) {
if ($node->localName === 'EntityDescriptor') {
try {
$entities = array_merge($entities, SimpleSAML_Metadata_SAMLParser::parseDescriptorsElement($node));
} catch (Exception $e) {
$entityID = $node->getAttribute('entityID');
if (empty($entityID)) {
$entityID = "unknown";
}
SimpleSAML_Logger::warning('[metarefresh]: Error while parsing entity (' . $entityID . '): ' . $e->getMessage());
}
} else {
$entities = array_merge($entities, $this->loadXML($node->ownerDocument->saveXML($node), $source));
}
}
} else {
$entities = SimpleSAML_Metadata_SAMLParser::parseDescriptorsElement($doc->documentElement);
}
return $entities;
}