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);
 }
Example #2
0
 /**
  * @return \AerialShip\LightSaml\Model\Protocol\AuthnRequest
  */
 protected function getRequest()
 {
     $request = CommonHelper::buildAuthnRequestFromEntityDescriptors(__DIR__ . '/../../../../../resources/sample/EntityDescriptor/sp-ed2.xml', __DIR__ . '/../../../../../resources/sample/EntityDescriptor/idp2-ed.xml');
     $certificate = new X509Certificate();
     $certificate->loadFromFile(__DIR__ . '/../../../../../resources/sample/Certificate/saml.crt');
     $key = new \XMLSecurityKey(\XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
     $key->loadKey(__DIR__ . '/../../../../../resources/sample/Certificate/saml.pem', true, false);
     $signature = new SignatureCreator();
     $signature->setCertificate($certificate);
     $signature->setXmlSecurityKey($key);
     $request->setSignature($signature);
     $request->setRelayState($this->relayState);
     return $request;
 }