Пример #1
0
 /**
  * @param ProfileContext $context
  *
  * @return void
  */
 protected function doExecute(ProfileContext $context)
 {
     $bindingType = $this->bindingFactory->detectBindingType($context->getHttpRequest());
     if (null == $bindingType) {
         $message = 'Unable to resolve binding type, invalid or unsupported http request';
         $this->logger->critical($message, LogHelper::getActionErrorContext($context, $this));
         throw new LightSamlBindingException($message);
     }
     $this->logger->debug(sprintf('Detected binding type: %s', $bindingType), LogHelper::getActionContext($context, $this));
     $binding = $this->bindingFactory->create($bindingType);
     $binding->receive($context->getHttpRequest(), $context->getInboundContext());
     $context->getInboundContext()->setBindingType($bindingType);
     $this->logger->info('Received message', LogHelper::getActionContext($context, $this, array('message' => $context->getInboundContext()->getDeserializationContext()->getDocument()->saveXML())));
 }
 /**
  * @param ProfileContext $context
  */
 protected function doExecute(ProfileContext $context)
 {
     $ownEntityDescriptor = $context->getOwnEntityDescriptor();
     /** @var SerializationContext $serializationContext */
     $serializationContext = $context->getSubContext(ProfileContexts::SERIALIZATION, SerializationContext::class);
     $serializationContext->getDocument()->formatOutput = true;
     $ownEntityDescriptor->serialize($serializationContext->getDocument(), $serializationContext);
     $xml = $serializationContext->getDocument()->saveXML();
     $response = new Response($xml);
     $contentType = 'text/xml';
     $acceptableContentTypes = array_flip($context->getHttpRequest()->getAcceptableContentTypes());
     foreach ($this->supportedContextTypes as $supportedContentType) {
         if (isset($acceptableContentTypes[$supportedContentType])) {
             $contentType = $supportedContentType;
             break;
         }
     }
     $response->headers->replace(array('Content-Type' => $contentType));
     $context->getHttpResponseContext()->setResponse($response);
 }
Пример #3
0
 public function test__get_http_request_returns_from_context()
 {
     $profileContext = new ProfileContext(Profiles::METADATA, ProfileContext::ROLE_IDP);
     $profileContext->getHttpRequestContext()->setRequest($expectedValue = new Request());
     $this->assertSame($expectedValue, $profileContext->getHttpRequest());
 }