Ejemplo n.º 1
0
 protected function doExecute(ProfileContext $context)
 {
     if (null == $context->getInboundContext()->getMessage()) {
         return;
     }
     $this->logger->debug(sprintf('Forwarding relay state: "%s"', $context->getInboundMessage()->getRelayState()));
     $context->getOutboundMessage()->setRelayState($context->getInboundMessage()->getRelayState());
 }
 public function test_sets_inbound_message_issuer_entity_id_to_party_context()
 {
     $action = new EntityIdFromMessageIssuerAction(TestHelper::getLoggerMock($this));
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getInboundContext()->setMessage(new AuthnRequest());
     $context->getInboundMessage()->setIssuer(new Issuer($expectedEntityId = 'http://localhost/id'));
     $action->execute($context);
     $this->assertEquals($expectedEntityId, $context->getPartyEntityContext()->getEntityId());
 }
 /**
  * @param string $ownRole
  * @param string $destination
  *
  * @return ProfileContext
  */
 private function buildContext($ownRole, $destination)
 {
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, $ownRole);
     $context->getInboundContext()->setMessage(new AuthnRequest());
     if ($destination) {
         $context->getInboundMessage()->setDestination($destination);
     }
     $context->getOwnEntityContext()->setEntityDescriptor(new EntityDescriptor());
     return $context;
 }
 /**
  * @expectedException \LightSaml\Error\LightSamlContextException
  * @expectedExceptionMessage Error from name id validator
  */
 public function test_wrapps_validation_exception_in_context_exception()
 {
     $nameIdValidatorMock = $this->getNameIdValidatorMock();
     $action = new IssuerValidatorAction(TestHelper::getLoggerMock($this), $nameIdValidatorMock, $allowedFormat = SamlConstants::NAME_ID_FORMAT_EMAIL);
     $context = new ProfileContext(Profiles::SSO_IDP_RECEIVE_AUTHN_REQUEST, ProfileContext::ROLE_IDP);
     $context->getInboundContext()->setMessage(new AuthnRequest());
     $expectedIssuer = new Issuer('http://localhost', $allowedFormat);
     $context->getInboundMessage()->setIssuer($expectedIssuer);
     $nameIdValidatorMock->expects($this->once())->method('validateNameId')->with($expectedIssuer)->willThrowException(new LightSamlValidationException('Error from name id validator'));
     $action->execute($context);
 }
Ejemplo n.º 5
0
 public function test__get_inbound_message_returns_from_context()
 {
     $profileContext = new ProfileContext(Profiles::METADATA, ProfileContext::ROLE_IDP);
     $profileContext->getInboundContext()->setMessage($expectedValue = $this->getMockForAbstractClass(SamlMessage::class));
     $this->assertSame($expectedValue, $profileContext->getInboundMessage());
 }