/**
  * @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());
 }
 /**
  * @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)
 {
     $endpoint = $context->getEndpoint();
     MessageContextHelper::asSamlMessage($context->getOutboundContext())->setDestination($endpoint->getLocation());
     $this->logger->debug(sprintf('Destination set to "%s"', $endpoint->getLocation()), LogHelper::getActionContext($context, $this));
 }
 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());
 }