/**
  * @param ProfileContext $context
  */
 protected function doExecute(ProfileContext $context)
 {
     if ($context->getEndpointContext()->getEndpoint()) {
         $this->logger->debug(sprintf('Endpoint already set with location "%s" and binding "%s"', $context->getEndpoint()->getLocation(), $context->getEndpoint()->getBinding()), LogHelper::getActionContext($context, $this, array('endpointLocation' => $context->getEndpoint()->getLocation(), 'endpointBinding' => $context->getEndpoint()->getBinding())));
         return;
     }
     $criteriaSet = $this->getCriteriaSet($context);
     $message = $context->getInboundContext()->getMessage();
     if ($message instanceof AuthnRequest) {
         if (null !== $message->getAssertionConsumerServiceIndex()) {
             $criteriaSet->add(new IndexCriteria($message->getAssertionConsumerServiceIndex()));
         }
         if (null !== $message->getAssertionConsumerServiceURL()) {
             $criteriaSet->add(new LocationCriteria($message->getAssertionConsumerServiceURL()));
         }
     }
     $candidates = $this->endpointResolver->resolve($criteriaSet, $context->getPartyEntityDescriptor()->getAllEndpoints());
     /** @var EndpointReference $endpointReference */
     $endpointReference = array_shift($candidates);
     if (null == $endpointReference) {
         $message = sprintf("Unable to determine endpoint for entity '%s'", $context->getPartyEntityDescriptor()->getEntityID());
         $this->logger->emergency($message, LogHelper::getActionErrorContext($context, $this));
         throw new LightSamlContextException($context, $message);
     }
     $this->logger->debug(sprintf('Endpoint resolved to location "%s" and binding "%s"', $endpointReference->getEndpoint()->getLocation(), $endpointReference->getEndpoint()->getBinding()), LogHelper::getActionContext($context, $this, array('endpointLocation' => $endpointReference->getEndpoint()->getLocation(), 'endpointBinding' => $endpointReference->getEndpoint()->getBinding())));
     $context->getEndpointContext()->setEndpoint($endpointReference->getEndpoint());
 }
예제 #2
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());
 }
예제 #3
0
 public function test__get_endpoint_returns_from_context()
 {
     $profileContext = new ProfileContext(Profiles::METADATA, ProfileContext::ROLE_IDP);
     $profileContext->getEndpointContext()->setEndpoint($expectedValue = $this->getMockForAbstractClass(Endpoint::class));
     $this->assertSame($expectedValue, $profileContext->getEndpoint());
 }