public function testMarshalling() { $response = new SAML2_Response(); $response->setStatus(array('Code' => 'OurStatusCode', 'SubCode' => 'OurSubStatusCode', 'Message' => 'OurMessageText')); $responseElement = $response->toUnsignedXML(); $statusElements = SAML2_Utils::xpQuery($responseElement, './saml_protocol:Status'); $this->assertCount(1, $statusElements); $statusCodeElements = SAML2_Utils::xpQuery($statusElements[0], './saml_protocol:StatusCode'); $this->assertCount(1, $statusCodeElements); $this->assertEquals('OurStatusCode', $statusCodeElements[0]->getAttribute("Value")); $nestedStatusCodeElements = SAML2_Utils::xpQuery($statusCodeElements[0], './saml_protocol:StatusCode'); $this->assertCount(1, $nestedStatusCodeElements); $this->assertEquals('OurSubStatusCode', $nestedStatusCodeElements[0]->getAttribute("Value")); $statusMessageElements = SAML2_Utils::xpQuery($statusElements[0], './saml_protocol:StatusMessage'); $this->assertCount(1, $statusMessageElements); $this->assertEquals('OurMessageText', $statusMessageElements[0]->textContent); }
protected function _createBaseResponse(EngineBlock_Saml2_AuthnRequestAnnotationDecorator $request) { if ($request->getVoContext() && $request->isVoContextExplicit()) { $this->setVirtualOrganisationContext($request->getVoContext()); } if ($keyId = $request->getKeyId()) { $this->setKeyId($keyId); } $requestWasUnsolicited = $request->isUnsolicited(); $response = new SAML2_Response(); /** @var SAML2_AuthnRequest $request */ $response->setRelayState($request->getRelayState()); $response->setId($this->getNewId(IdFrame::ID_USAGE_SAML2_RESPONSE)); $response->setIssueInstant(time()); if (!$requestWasUnsolicited) { $response->setInResponseTo($request->getId()); } $response->setDestination($request->getIssuer()); $response->setIssuer($this->getUrl('idpMetadataService', $request->getIssuer(), $request)); $acs = $this->getRequestAssertionConsumer($request); $response->setDestination($acs->location); $response->setStatus(array('Code' => SAML2_Const::STATUS_SUCCESS)); $response = new EngineBlock_Saml2_ResponseAnnotationDecorator($response); $response->setDeliverByBinding($acs->binding); return $response; }