/**
  * @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));
 }
 private function getPartyEntityDescriptor(ProfileContext $context)
 {
     $ssoSessionState = $context->getLogoutSsoSessionState();
     $ownEntityId = $context->getOwnEntityDescriptor()->getEntityID();
     $partyId = $ssoSessionState->getOtherPartyId($ownEntityId);
     $partyEntityDescriptor = $this->findParty($partyId, [$this->idpEntityDescriptorStore, $this->spEntityDescriptorStore]);
     if ($partyEntityDescriptor) {
         return $partyEntityDescriptor;
     }
     throw new LightSamlContextException($context, sprintf('Unknown party "%s"', $partyId));
 }
 protected function getDescriptorType(ProfileContext $context)
 {
     $ssoSessionState = $context->getLogoutSsoSessionState();
     $ownEntityId = $context->getOwnEntityDescriptor()->getEntityID();
     if ($ssoSessionState->getIdpEntityId() == $ownEntityId) {
         return SpSsoDescriptor::class;
     } elseif ($ssoSessionState->getSpEntityId() == $ownEntityId) {
         return IdpSsoDescriptor::class;
     } else {
         throw new LightSamlContextException($context, 'Unable to resolve logout target descriptor type');
     }
 }
예제 #4
0
 protected function doExecute(ProfileContext $context)
 {
     $ownEntityDescriptor = $context->getOwnEntityDescriptor();
     $criteriaSet = new CriteriaSet([new DescriptorTypeCriteria(SpSsoDescriptor::class), new ServiceTypeCriteria(AssertionConsumerService::class), new BindingCriteria([SamlConstants::BINDING_SAML2_HTTP_POST])]);
     $endpoints = $this->endpointResolver->resolve($criteriaSet, $ownEntityDescriptor->getAllEndpoints());
     if (empty($endpoints)) {
         $message = 'Missing ACS Service with HTTP POST binding in own SP SSO Descriptor';
         $this->logger->error($message, LogHelper::getActionErrorContext($context, $this));
         throw new LightSamlContextException($context, $message);
     }
     MessageContextHelper::asAuthnRequest($context->getOutboundContext())->setAssertionConsumerServiceURL($endpoints[0]->getEndpoint()->getLocation());
 }
 /**
  * @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);
 }
예제 #6
0
 /**
  * @param ProfileContext $context
  */
 protected function doExecute(ProfileContext $context)
 {
     $response = MessageContextHelper::asResponse($context->getInboundContext());
     $this->sessionProcessor->processAssertions($response->getAllAssertions(), $context->getOwnEntityDescriptor()->getEntityID(), $context->getPartyEntityDescriptor()->getEntityID());
 }
예제 #7
0
 public function test__get_own_entity_descriptor_returns_from_context()
 {
     $profileContext = new ProfileContext(Profiles::METADATA, ProfileContext::ROLE_IDP);
     $profileContext->getOwnEntityContext()->setEntityDescriptor($expectedValue = new EntityDescriptor());
     $this->assertSame($expectedValue, $profileContext->getOwnEntityDescriptor());
 }