SimpleSAML_Metadata_SAMLParser::getMetadata20SP PHP Method

getMetadata20SP() public method

This is an associative array with the following fields: - 'entityid': The entity id of the entity described in the metadata. - 'AssertionConsumerService': String with the URL of the assertion consumer service which supports the browser-post binding. - 'SingleLogoutService': String with the URL where we should send logout requests/responses. - 'NameIDFormat': The name ID format this SP expects. This may be unset. - 'certData': X509Certificate for entity (if present). Metadata must be loaded with one of the parse functions before this function can be called.
public getMetadata20SP ( ) : array
return array An associative array with metadata or NULL if we are unable to generate metadata for a SAML 2.x SP.
    public function getMetadata20SP()
    {
        $ret = $this->getMetadataCommon();
        $ret['metadata-set'] = 'saml20-sp-remote';
        // find SP information which supports the SAML 2.0 protocol
        $spd = $this->getSPDescriptors(self::$SAML20Protocols);
        if (count($spd) === 0) {
            return null;
        }
        // we currently only look at the first SPDescriptor which supports SAML 2.0
        $spd = $spd[0];
        // add expire time to metadata
        if (array_key_exists('expire', $spd)) {
            $ret['expire'] = $spd['expire'];
        }
        // find the assertion consumer service endpoints
        $ret['AssertionConsumerService'] = $spd['AssertionConsumerService'];
        // find the single logout service endpoint
        $ret['SingleLogoutService'] = $spd['SingleLogoutService'];
        // find the NameIDFormat. This may not exist
        if (count($spd['nameIDFormats']) > 0) {
            // SimpleSAMLphp currently only supports a single NameIDFormat pr. SP. We use the first one
            $ret['NameIDFormat'] = $spd['nameIDFormats'][0];
        }
        // add the list of attributes the SP should receive
        if (array_key_exists('attributes', $spd)) {
            $ret['attributes'] = $spd['attributes'];
        }
        if (array_key_exists('attributes.required', $spd)) {
            $ret['attributes.required'] = $spd['attributes.required'];
        }
        if (array_key_exists('attributes.NameFormat', $spd)) {
            $ret['attributes.NameFormat'] = $spd['attributes.NameFormat'];
        }
        // add name & description
        if (array_key_exists('name', $spd)) {
            $ret['name'] = $spd['name'];
        }
        if (array_key_exists('description', $spd)) {
            $ret['description'] = $spd['description'];
        }
        // add public keys
        if (!empty($spd['keys'])) {
            $ret['keys'] = $spd['keys'];
        }
        // add validate.authnrequest
        if (array_key_exists('AuthnRequestsSigned', $spd)) {
            $ret['validate.authnrequest'] = $spd['AuthnRequestsSigned'];
        }
        // add saml20.sign.assertion
        if (array_key_exists('WantAssertionsSigned', $spd)) {
            $ret['saml20.sign.assertion'] = $spd['WantAssertionsSigned'];
        }
        // add extensions
        $this->addExtensions($ret, $spd);
        // prioritize mdui:DisplayName as the name if available
        if (!empty($ret['UIInfo']['DisplayName'])) {
            $ret['name'] = $ret['UIInfo']['DisplayName'];
        }
        return $ret;
    }

Usage Example

 /**
  * Retrieve metadata for the correct set from a SAML2Parser.
  *
  * @param SimpleSAML_Metadata_SAMLParser $entity  A SAML2Parser representing an entity.
  * @param string $set  The metadata set we are looking for.
  * @return array|NULL  The associative array with the metadata, or NULL if no metadata for
  *                     the given set was found.
  */
 private static function getParsedSet(SimpleSAML_Metadata_SAMLParser $entity, $set)
 {
     assert('is_string($set)');
     switch ($set) {
         case 'saml20-idp-remote':
             return $entity->getMetadata20IdP();
         case 'saml20-sp-remote':
             return $entity->getMetadata20SP();
         case 'shib13-idp-remote':
             return $entity->getMetadata1xIdP();
         case 'shib13-sp-remote':
             return $entity->getMetadata1xSP();
         case 'attributeauthority-remote':
             $ret = $entity->getAttributeAuthorities();
             return $ret[0];
         default:
             SimpleSAML_Logger::warning('MetaData - Handler.MDX: Unknown metadata set: ' . $set);
     }
     return NULL;
 }
All Usage Examples Of SimpleSAML_Metadata_SAMLParser::getMetadata20SP