src/MetadataBuilder.php
public function build($entityID, $acs, $logout, $certificate)
    {
        $entityDescriptor = (new EntityDescriptor())
            ->setEntityID($entityID)
            ->setID(Helper::generateID());

        $spSsoDescriptor = (new SpSsoDescriptor())
            ->addKeyDescriptor(
                (new KeyDescriptor())
                    ->setUse(KeyDescriptor::USE_SIGNING)
                    ->setCertificate($certificate)
            )
            ->addKeyDescriptor(
                (new KeyDescriptor())
                    ->setUse(KeyDescriptor::USE_ENCRYPTION)
                    ->setCertificate($certificate)
            )
            ->setWantAssertionsSigned(true)
            ->setAuthnRequestsSigned(true)
            ->addSingleLogoutService(
                $logout = (new SingleLogoutService())
                    ->setBinding(SamlConstants::BINDING_SAML2_HTTP_REDIRECT)
                    ->setLocation($logout)
            )
            ->addAssertionConsumerService(
                $acs = (new AssertionConsumerService())
                    ->setBinding(SamlConstants::BINDING_SAML2_HTTP_POST)
                    ->setLocation($acs)
            );

        $entityDescriptor->addItem($spSsoDescriptor);

        $serializationContext = new SerializationContext();

        $entityDescriptor->serialize($serializationContext->getDocument(), $serializationContext);

        $data = $serializationContext->getDocument()->saveXML();

        return $data;
    }
public function build($entityID, $acs, $logout, $certificate)
    {
        $entityDescriptor = (new EntityDescriptor())
            ->setEntityID($entityID)
            ->setID(Helper::generateID());

        $spSsoDescriptor = (new SpSsoDescriptor())
            ->addKeyDescriptor(
                (new KeyDescriptor())
                    ->setUse(KeyDescriptor::USE_SIGNING)
                    ->setCertificate($certificate)
            )
            ->addKeyDescriptor(
                (new KeyDescriptor())
                    ->setUse(KeyDescriptor::USE_ENCRYPTION)
                    ->setCertificate($certificate)
            )
            ->setWantAssertionsSigned(true)
            ->setAuthnRequestsSigned(true)
            ->addSingleLogoutService(
                $logout = (new SingleLogoutService())
                    ->setBinding(SamlConstants::BINDING_SAML2_HTTP_REDIRECT)
                    ->setLocation($logout)
            )
            ->addAssertionConsumerService(
                $acs = (new AssertionConsumerService())
                    ->setBinding(SamlConstants::BINDING_SAML2_HTTP_POST)
                    ->setLocation($acs)
            );

        $entityDescriptor->addItem($spSsoDescriptor);

        $serializationContext = new SerializationContext();

        $entityDescriptor->serialize($serializationContext->getDocument(), $serializationContext);

        $data = $serializationContext->getDocument()->saveXML();

        return $data;
    }
public function build ( $ entityID , $ acs , $ logout , $ certificate ) { $ entityDescriptor = ( new EntityDescriptor ( ) ) -> setEntityID ( $ entityID ) -> setID ( Helper :: generateID ( ) ) ; $ spSsoDescriptor = ( new SpSsoDescriptor ( ) ) -> addKeyDescriptor ( ( new KeyDescriptor ( ) ) -> setUse ( KeyDescriptor :: USE_SIGNING ) -> setCertificate ( $ certificate ) ) -> addKeyDescriptor ( ( new KeyDescriptor ( ) ) -> setUse ( KeyDescriptor :: USE_ENCRYPTION ) -> setCertificate ( $ certificate ) ) -> setWantAssertionsSigned ( true ) -> setAuthnRequestsSigned ( true ) -> addSingleLogoutService ( $ logout = ( new SingleLogoutService ( ) ) -> setBinding ( SamlConstants :: BINDING_SAML2_HTTP_REDIRECT ) -> setLocation ( $ logout ) ) -> addAssertionConsumerService ( $ acs = ( new AssertionConsumerService ( ) ) -> setBinding ( SamlConstants :: BINDING_SAML2_HTTP_POST ) -> setLocation ( $ acs ) ) ; $ entityDescriptor -> addItem ( $ spSsoDescriptor ) ; $ serializationContext = new SerializationContext ( ) ; $ entityDescriptor -> serialize ( $ serializationContext -> getDocument ( ) , $ serializationContext ) ; $ data = $ serializationContext -> getDocument ( ) -> saveXML ( ) ; return $ data ; }
Build the SP SAML metadata

@param $entityID
@param $acs
@param $logout
@param $certificate

@return string
Build the SP SAML metadata