SAML2\Message::fromXML PHP Method

fromXML() public static method

Convert an XML element into a message.
public static fromXML ( DOMElement $xml ) : Message
$xml DOMElement The root XML element
return Message The message
    public static function fromXML(\DOMElement $xml)
    {
        if ($xml->namespaceURI !== Constants::NS_SAMLP) {
            throw new \Exception('Unknown namespace of SAML message: ' . var_export($xml->namespaceURI, true));
        }
        switch ($xml->localName) {
            case 'AttributeQuery':
                return new AttributeQuery($xml);
            case 'AuthnRequest':
                return new AuthnRequest($xml);
            case 'LogoutResponse':
                return new LogoutResponse($xml);
            case 'LogoutRequest':
                return new LogoutRequest($xml);
            case 'Response':
                return new Response($xml);
            case 'ArtifactResponse':
                return new ArtifactResponse($xml);
            case 'ArtifactResolve':
                return new ArtifactResolve($xml);
            default:
                throw new \Exception('Unknown SAML message: ' . var_export($xml->localName, true));
        }
    }

Usage Example

コード例 #1
0
ファイル: MessageTest.php プロジェクト: NIIF/saml2
 /**
  * @group Message
  */
 public function testCorrectSignatureMethodCanBeExtractedFromResponse()
 {
     $response = new \DOMDocument();
     $response->load(__DIR__ . '/Response/response.xml');
     $privateKey = CertificatesMock::getPrivateKey();
     $unsignedMessage = Message::fromXML($response->documentElement);
     $unsignedMessage->setSignatureKey($privateKey);
     $unsignedMessage->setCertificates(array(CertificatesMock::PUBLIC_KEY_PEM));
     $signedMessage = Message::fromXML($unsignedMessage->toSignedXML());
     $this->assertEquals($privateKey->getAlgorith(), $signedMessage->getSignatureMethod());
 }
All Usage Examples Of SAML2\Message::fromXML