![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/vendor/litesaml/lightsaml/src/Model/Metadata/ |
<?php namespace LightSaml\Model\Metadata; use LightSaml\Error\LightSamlXmlException; use LightSaml\Model\AbstractSamlModel; use LightSaml\Model\Context\DeserializationContext; use LightSaml\Model\SamlElementInterface; use LightSaml\SamlConstants; abstract class Metadata extends AbstractSamlModel { /** * @param string $path * * @return EntitiesDescriptor|EntityDescriptor */ public static function fromFile($path) { $deserializatonContext = new DeserializationContext(); $xml = file_get_contents($path); return self::fromXML($xml, $deserializatonContext); } /** * @param string $xml * * @return EntityDescriptor|EntitiesDescriptor * * @throws \Exception */ public static function fromXML($xml, DeserializationContext $context) { if (false == is_string($xml)) { throw new \InvalidArgumentException('Expecting string'); } $context->getDocument()->loadXML($xml); $node = $context->getDocument()->firstChild; while ($node && $node instanceof \DOMComment) { $node = $node->nextSibling; } if (null === $node) { throw new LightSamlXmlException('Empty XML'); } if (SamlConstants::NS_METADATA !== $node->namespaceURI) { throw new LightSamlXmlException(sprintf("Invalid namespace '%s' of the root XML element, expected '%s'", $node->namespaceURI, SamlConstants::NS_METADATA)); } $map = [ 'EntityDescriptor' => '\LightSaml\Model\Metadata\EntityDescriptor', 'EntitiesDescriptor' => '\LightSaml\Model\Metadata\EntitiesDescriptor', ]; $rootElementName = $node->localName; if (array_key_exists($rootElementName, $map)) { if ($class = $map[$rootElementName]) { /** @var SamlElementInterface $result */ $result = new $class(); } else { throw new \LogicException('Deserialization of %s root element is not implemented'); } } else { throw new LightSamlXmlException(sprintf("Unknown SAML metadata '%s'", $rootElementName)); } $result->deserialize($node, $context); return $result; } }