SAML2\Assertion::getAttributeNameFormat PHP Method

getAttributeNameFormat() public method

If more than one NameFormat is used in the received attributes, this returns the unspecified NameFormat.
public getAttributeNameFormat ( ) : string
return string The NameFormat used on all attributes.
    public function getAttributeNameFormat()
    {
        return $this->nameFormat;
    }

Usage Example

Beispiel #1
0
    /**
     * If this assertion mixes Attribute NameFormats, the AttributeNameFormat
     * of this assertion will be set to unspecified.
     */
    public function testMixedAttributeNameFormats()
    {
        $xml = <<<XML
            <saml:Assertion
                    xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
                    xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
                    xmlns:xs="http://www.w3.org/2001/XMLSchema"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    Version="2.0"
                    ID="_93af655219464fb403b34436cfb0c5cb1d9a5502"
                    IssueInstant="1970-01-01T01:33:31Z">
      <saml:Issuer>Provider</saml:Issuer>
      <saml:Conditions/>
      <saml:AttributeStatement>
        <saml:Attribute Name="1.3.6.1.4.1.25178.1.2.9" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
            <saml:AttributeValue xsi:type="xs:string">string</saml:AttributeValue>
        </saml:Attribute>
        <saml:Attribute Name="urn:EntityConcernedSubID" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:basic">
            <saml:AttributeValue xsi:type="xs:string">string</saml:AttributeValue>
        </saml:Attribute>
      </saml:AttributeStatement>
    </saml:Assertion>
XML;
        $assertion = new Assertion(DOMDocumentFactory::fromString($xml)->firstChild);
        $nameFormat = $assertion->getAttributeNameFormat();
        $this->assertEquals('urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified', $nameFormat);
    }