예제 #1
0
 /**
  * @param ProfileContext $context
  *
  * @return void
  */
 public function doExecute(ProfileContext $context)
 {
     $binding = $this->bindingFactory->create($context->getEndpoint()->getBinding());
     $outboundContext = $context->getOutboundContext();
     $context->getHttpResponseContext()->setResponse($binding->send($outboundContext));
     $this->logger->info('Sending message', LogHelper::getActionContext($context, $this, array('message' => $outboundContext->getSerializationContext()->getDocument()->saveXML())));
 }
 /**
  * @param ProfileContext $context
  *
  * @return void
  */
 protected function doExecute(ProfileContext $context)
 {
     $ownEntityDescriptor = $context->getOwnEntityDescriptor();
     $issuer = new Issuer($ownEntityDescriptor->getEntityID());
     $issuer->setFormat(SamlConstants::NAME_ID_FORMAT_ENTITY);
     MessageContextHelper::asSamlMessage($context->getOutboundContext())->setIssuer($issuer);
     $this->logger->debug(sprintf('Issuer set to "%s"', $ownEntityDescriptor->getEntityID()), LogHelper::getActionContext($context, $this));
 }
예제 #3
0
 /**
  * @param ProfileContext $context
  */
 protected function doExecute(ProfileContext $context)
 {
     $message = MessageContextHelper::asSamlMessage($context->getOutboundContext());
     $state = new RequestState();
     $state->setId($message->getID());
     $state->setNonce($message);
     $this->requestStore->set($state);
 }
 /**
  * @param ProfileContext $context
  */
 protected function doExecute(ProfileContext $context)
 {
     $logoutRequest = MessageContextHelper::asLogoutRequest($context->getOutboundContext());
     $ssoSessionState = $context->getLogoutSsoSessionState();
     $nameId = new NameID();
     $nameId->setValue($ssoSessionState->getNameId());
     $nameId->setFormat($ssoSessionState->getNameIdFormat());
     $logoutRequest->setNameID($nameId);
 }
예제 #5
0
 public function test_sets_outbounding_message_destination_to_endpoint_context_value()
 {
     $action = new DestinationAction(TestHelper::getLoggerMock($this));
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getOutboundContext()->setMessage($message = new AuthnRequest());
     $context->getEndpointContext()->setEndpoint($endpoint = new SingleSignOnService());
     $endpoint->setLocation($location = 'http://idp.com/login');
     $action->execute($context);
     $this->assertEquals($location, $message->getDestination());
 }
 public function test_sets_relat_state_from_inbound_to_outbound_message()
 {
     $action = new ForwardRelayStateAction(TestHelper::getLoggerMock($this));
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getInboundContext()->setMessage($inboundMessage = new AuthnRequest());
     $context->getOutboundContext()->setMessage($outboundMessage = new Response());
     $inboundMessage->setRelayState($relayState = '123');
     $action->execute($context);
     $this->assertEquals($relayState, $context->getOutboundMessage()->getRelayState());
 }
 public function test_sets_not_on_or_after_to_outbound_logout_request()
 {
     $timeProviderMock = $this->getTimeProviderMock();
     $action = new SetNotOnOrAfterAction($this->getLoggerMock(), $timeProviderMock, $skew = 100);
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getOutboundContext()->setMessage($logoutRequest = new LogoutRequest());
     $timeProviderMock->expects($this->once())->method('getTimestamp')->willReturn($baseTimestamp = 1445953125);
     $action->execute($context);
     $expectedTimestamp = $baseTimestamp + $skew;
     $this->assertEquals($expectedTimestamp, $logoutRequest->getNotOnOrAfterTimestamp());
 }
 public function test_sets_own_entity_id_to_outbounding_message_issuer_with_name_id_format_entity()
 {
     $action = new CreateMessageIssuerAction(TestHelper::getLoggerMock($this));
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getOutboundContext()->setMessage($message = new AuthnRequest());
     $context->getOwnEntityContext()->setEntityDescriptor(new EntityDescriptor($ownEntityId = 'http://own.entity.id'));
     $action->execute($context);
     $this->assertNotNull($message->getIssuer());
     $this->assertEquals($ownEntityId, $message->getIssuer()->getValue());
     $this->assertEquals(SamlConstants::NAME_ID_FORMAT_ENTITY, $message->getIssuer()->getFormat());
 }
 public function test_sets_name_id_to_outbound_logout_request()
 {
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getOutboundContext()->setMessage($logoutRequest = new LogoutRequest());
     $context->getLogoutContext()->setSsoSessionState((new SsoSessionState())->setNameId($nameId = 'name.id')->setNameIdFormat($nameIdFormat = 'name.id.format'));
     $action = new SetNameIdAction($this->getLoggerMock());
     $action->execute($context);
     $this->assertNotNull($logoutRequest->getNameID());
     $this->assertEquals($nameId, $logoutRequest->getNameID()->getValue());
     $this->assertEquals($nameIdFormat, $logoutRequest->getNameID()->getFormat());
 }
예제 #10
0
 /**
  * @param ProfileContext $context
  */
 protected function doExecute(ProfileContext $context)
 {
     $message = MessageContextHelper::asSamlMessage($context->getOutboundContext());
     $state = new RequestState();
     $state->setId($message->getID());
     $partyEntityId = $context->getPartyEntityContext() ? $context->getPartyEntityContext()->getEntityId() : '';
     if ($context->getPartyEntityContext() && $context->getPartyEntityContext()->getEntityDescriptor()) {
         $partyEntityId = $context->getPartyEntityContext()->getEntityDescriptor()->getEntityID();
     }
     $state->getParameters()->add([RequestStateParameters::ID => $message->getID(), RequestStateParameters::TYPE => get_class($message), RequestStateParameters::TIMESTAMP => $message->getIssueInstantTimestamp(), RequestStateParameters::PARTY => $partyEntityId, RequestStateParameters::RELAY_STATE => $message->getRelayState()]);
     if ($message instanceof LogoutRequest) {
         $state->getParameters()->add([RequestStateParameters::NAME_ID => $message->getNameID()->getValue(), RequestStateParameters::NAME_ID_FORMAT => $message->getNameID()->getFormat(), RequestStateParameters::SESSION_INDEX => $message->getSessionIndex()]);
     }
     $this->requestStore->set($state);
 }
 /**
  * @param ProfileContext $context
  *
  * @return void
  */
 protected function doExecute(ProfileContext $context)
 {
     $response = MessageContextHelper::asResponse($context->getOutboundContext());
     foreach ($this->assertionActions as $index => $action) {
         $name = sprintf('assertion_%s', $index);
         /** @var AssertionContext $assertionContext */
         $assertionContext = $context->getSubContext($name, AssertionContext::class);
         $assertionContext->setId($index);
         $action->execute($assertionContext);
         if ($assertionContext->getEncryptedAssertion()) {
             $response->addEncryptedAssertion($assertionContext->getEncryptedAssertion());
         } elseif ($assertionContext->getAssertion()) {
             $response->addAssertion($assertionContext->getAssertion());
         } else {
             $this->logger->warning('No assertion was built', LogHelper::getActionContext($context, $this));
         }
     }
 }
예제 #12
0
 public function test_finds_acs_endpoint_and_sets_outbounding_authn_request_acs_url()
 {
     $action = new ACSUrlAction($loggerMock = TestHelper::getLoggerMock($this), $endpointResolverMock = $this->getEndpointResolverMock());
     $context = new ProfileContext(Profiles::SSO_SP_SEND_AUTHN_REQUEST, ProfileContext::ROLE_SP);
     $context->getOwnEntityContext()->setEntityDescriptor($entityDescriptorMock = $this->getEntityDescriptorMock());
     $entityDescriptorMock->expects($this->once())->method('getAllEndpoints')->willReturn([TestHelper::getEndpointReferenceMock($this, $endpoint = new AssertionConsumerService('http://localhost/acs'))]);
     $endpointResolverMock->expects($this->once())->method('resolve')->with($this->isInstanceOf(CriteriaSet::class), $this->isType('array'))->willReturnCallback(function (CriteriaSet $criteriaSet, array $candidates) {
         $this->assertTrue($criteriaSet->has(DescriptorTypeCriteria::class));
         $this->assertEquals(SpSsoDescriptor::class, $criteriaSet->getSingle(DescriptorTypeCriteria::class)->getDescriptorType());
         $this->assertTrue($criteriaSet->has(ServiceTypeCriteria::class));
         $this->assertEquals(AssertionConsumerService::class, $criteriaSet->getSingle(ServiceTypeCriteria::class)->getServiceType());
         $this->assertTrue($criteriaSet->has(BindingCriteria::class));
         $this->assertEquals([SamlConstants::BINDING_SAML2_HTTP_POST], $criteriaSet->getSingle(BindingCriteria::class)->getAllBindings());
         return $candidates;
     });
     $context->getOutboundContext()->setMessage($authnRequest = new AuthnRequest());
     $action->execute($context);
     $this->assertEquals($endpoint->getLocation(), $authnRequest->getAssertionConsumerServiceURL());
 }
예제 #13
0
 /**
  * @param ProfileContext $context
  *
  * @return void
  */
 protected function doExecute(ProfileContext $context)
 {
     $endpoint = $context->getEndpoint();
     MessageContextHelper::asSamlMessage($context->getOutboundContext())->setDestination($endpoint->getLocation());
     $this->logger->debug(sprintf('Destination set to "%s"', $endpoint->getLocation()), LogHelper::getActionContext($context, $this));
 }
예제 #14
0
 protected function doExecute(ProfileContext $context)
 {
     $context->getOutboundContext()->setMessage(new AuthnRequest());
 }
 protected function doExecute(ProfileContext $context)
 {
     $context->getOutboundContext()->setMessage(new Response());
 }
예제 #16
0
 protected function doExecute(ProfileContext $context)
 {
     $id = Helper::generateID();
     MessageContextHelper::asSamlMessage($context->getOutboundContext())->setId($id);
     $this->logger->info(sprintf('Message ID set to "%s"', $id), LogHelper::getActionContext($context, $this, array('message_id' => $id)));
 }
예제 #17
0
 /**
  * @param ProfileContext $context
  *
  * @return void
  */
 protected function doExecute(ProfileContext $context)
 {
     MessageContextHelper::asSamlMessage($context->getOutboundContext())->setVersion($this->version);
     $this->logger->debug(sprintf('Message Version set to "%s"', $this->version), LogHelper::getActionContext($context, $this));
 }
예제 #18
0
 public function test__get_outbound_message_returns_from_context()
 {
     $profileContext = new ProfileContext(Profiles::METADATA, ProfileContext::ROLE_IDP);
     $profileContext->getOutboundContext()->setMessage($expectedValue = $this->getMockForAbstractClass(SamlMessage::class));
     $this->assertSame($expectedValue, $profileContext->getOutboundMessage());
 }
 protected function doExecute(ProfileContext $context)
 {
     $logoutRequest = new LogoutRequest();
     $context->getOutboundContext()->setMessage($logoutRequest);
 }
예제 #20
0
 /**
  * @param ProfileContext $context
  *
  * @return void
  */
 protected function doExecute(ProfileContext $context)
 {
     if ($context->getInboundContext()->getMessage()) {
         MessageContextHelper::asStatusResponse($context->getOutboundContext())->setInResponseTo(MessageContextHelper::asSamlMessage($context->getInboundContext())->getID());
     }
 }
 /**
  * @param ProfileContext $context
  */
 protected function doExecute(ProfileContext $context)
 {
     $logoutRequest = MessageContextHelper::asLogoutRequest($context->getOutboundContext());
     $logoutRequest->setNotOnOrAfter($this->timeProvider->getTimestamp() + $this->secondsSkew);
 }
 /**
  * @param ProfileContext $context
  *
  * @return void
  */
 protected function doExecute(ProfileContext $context)
 {
     MessageContextHelper::asSamlMessage($context->getOutboundContext())->setIssueInstant($this->timeProvider->getTimestamp());
     $this->logger->info(sprintf('Message IssueInstant set to "%s"', MessageContextHelper::asSamlMessage($context->getOutboundContext())->getIssueInstantString()), LogHelper::getActionContext($context, $this));
 }
예제 #23
0
 /**
  * @param ProfileContext $context
  */
 protected function doExecute(ProfileContext $context)
 {
     $statusResponse = MessageContextHelper::asStatusResponse($context->getOutboundContext());
     $statusResponse->setStatus(new Status(new StatusCode($this->statusCode), $this->statusCode));
 }
 /**
  * @param ProfileContext $context
  */
 protected function doExecute(ProfileContext $context)
 {
     $logoutRequest = MessageContextHelper::asLogoutRequest($context->getOutboundContext());
     $ssoSessionState = $context->getLogoutSsoSessionState();
     $logoutRequest->setSessionIndex($ssoSessionState->getSessionIndex());
 }