public function __construct(array $config)
 {
     if (!isset($config['name_id_format'])) {
         $config['name_id_format'] = NameIDPolicy::PERSISTENT;
     }
     if (!isset($config['suppress_name_id_policy'])) {
         $config['suppress_name_id_policy'] = false;
     }
     if (!array_key_exists('binding', $config)) {
         $config['binding'] = array();
     }
     if (!isset($config['binding']['authn_request'])) {
         $config['binding']['authn_request'] = Bindings::SAML2_HTTP_POST;
     }
     if (!isset($config['binding']['response'])) {
         $config['binding']['response'] = Bindings::SAML2_HTTP_POST;
     }
     if (!isset($config['binding']['logout_request'])) {
         $config['binding']['logout_request'] = Bindings::SAML2_HTTP_POST;
     }
     $this->spMeta = new SpMeta();
     $this->spMeta->setNameIdFormat($this->resolveNameIDFormat($config['name_id_format']));
     $this->spMeta->setSuppressNameIdPolicy($this->resolveNameIDFormat($config['suppress_name_id_policy']));
     $this->spMeta->setAuthnRequestBinding($this->resolveBinding($config['binding']['authn_request']));
     $this->spMeta->setResponseBinding($this->resolveBinding($config['binding']['response']));
     $this->spMeta->setLogoutRequestBinding($this->resolveBinding($config['binding']['logout_request']));
 }
 function testOne()
 {
     $spMeta = new SpMeta();
     $spMeta->setNameIdFormat(NameIDPolicy::PERSISTENT);
     $request = CommonHelper::buildAuthnRequestFromEntityDescriptors(__DIR__ . '/../../../../../../../resources/sample/EntityDescriptor/sp-ed2.xml', __DIR__ . '/../../../../../../../resources/sample/EntityDescriptor/idp2-ed.xml', $spMeta);
     $id = $request->getID();
     $this->assertNotEmpty($id);
     $this->assertEquals(43, strlen($id));
     $time = $request->getIssueInstant();
     $this->assertNotEmpty($time);
     $this->assertLessThan(2, abs(time() - $time));
     $this->checkRequestObject($request, $id, $time);
     // serialize to XML Document and check xml
     $context = new SerializationContext();
     $request->getXml($context->getDocument(), $context);
     $this->checkRequestXml($context->getDocument(), $id);
     // Deserialize new request out of xml
     $request = new AuthnRequest();
     $request->loadFromXml($context->getDocument()->firstChild);
     $this->checkRequestObject($request, $id, $time);
     // serialize again to xml and check xml
     $context = new SerializationContext();
     $request->getXml($context->getDocument(), $context);
     $this->checkRequestXml($context->getDocument(), $id);
 }
 /**
  * @param string $sp
  * @param string $idp
  * @param SpMeta $spMeta
  * @return LogoutRequest
  * @throws \InvalidArgumentException
  */
 public static function buildLogoutRequestFromEntityDescriptors($sp, $idp, SpMeta $spMeta = null)
 {
     if (is_string($sp)) {
         $sp = self::getEntityDescriptorFromXmlFile($sp);
     } else {
         if (!$sp instanceof EntityDescriptor) {
             throw new \InvalidArgumentException('SP parameter must be instance of EntityDescriptor or string');
         }
     }
     if (is_string($idp)) {
         $idp = self::getEntityDescriptorFromXmlFile($idp);
     } else {
         if (!$idp instanceof EntityDescriptor) {
             throw new \InvalidArgumentException('IDP parameter must be instance of EntityDescriptor or string');
         }
     }
     if (!$spMeta) {
         $spMeta = new SpMeta();
         $spMeta->setNameIdFormat(NameIDPolicy::PERSISTENT);
     }
     $builder = new LogoutRequestBuilder($sp, $idp, $spMeta);
     $result = $builder->build('urn:oasis:names:tc:SAML:2.0:nameid-format:transient', 'user', '_677952a2-7fb3-4e7a-b439-326366e677db');
     return $result;
 }