本文整理匯總了PHP中SimpleSAML_Utilities::validateXML方法的典型用法代碼示例。如果您正苦於以下問題:PHP SimpleSAML_Utilities::validateXML方法的具體用法?PHP SimpleSAML_Utilities::validateXML怎麽用?PHP SimpleSAML_Utilities::validateXML使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SimpleSAML_Utilities
的用法示例。
在下文中一共展示了SimpleSAML_Utilities::validateXML方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validateXML
public function validateXML()
{
if (!isset($this->metadataXML)) {
throw new Exception('Metadata not available.');
}
$doc = new DOMDocument();
$res = $doc->loadXML($this->metadataXML);
if ($res !== TRUE) {
throw new Exception('Failed to parse Metadata XML: ' . $this->metadataXML);
}
# echo '<pre>'; print_r($res);
$val = SimpleSAML_Utilities::validateXML($doc, 'saml-schema-metadata-2.0.xsd');
if ($val) {
$this->setResult(sspmod_fedlab_Tester::STATUS_FATAL, 'metadata', 'metadata_schemavalid', 'Metadata MUST be schema valid', $val);
} else {
$this->setResult(sspmod_fedlab_Tester::STATUS_OK, 'metadata', 'metadata_schemavalid', 'Metadata MUST be schema valid');
}
}
示例2:
}
$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');
if ($errors !== '') {
$t->data['status'] = 'validation';
$t->data['errortext'] = $errors;
$t->show();
exit;
}
}
/* Add the metadata to the metadata store. */
$store->addMetadata($metadata);
$t->data['status'] = 'ok';
$t->show();
exit;