/** * @test * @group AttributeSet * @group AttributeDictionary * @group AssertionAdapter */ public function attribute_set_with_fallbacks_can_be_configured_when_creating_an_assertion_adapter() { $assertion = Mockery::mock(SAML2_Assertion::class); $assertion->shouldReceive('getAttributes')->andReturn([]); $dictionary = new AttributeDictionary(); ConfigurableAttributeSetFactory::configureWhichAttributeSetToCreate(AttributeSetWithFallbacks::class); $adapter = new AssertionAdapter($assertion, $dictionary); $attributeSet = $adapter->getAttributeSet(); ConfigurableAttributeSetFactory::configureWhichAttributeSetToCreate(AttributeSet::class); $this->assertInstanceOf(AttributeSetWithFallbacks::class, $attributeSet); }
public function authenticate(TokenInterface $token) { ConfigurableAttributeSetFactory::configureWhichAttributeSetToCreate(AttributeSetWithFallbacks::class); $translatedAssertion = $this->attributeDictionary->translate($token->assertion); $authenticatingAuthorities = array_map(function ($authenticatingAuthority) { return new EntityId($authenticatingAuthority); }, $token->assertion->getAuthenticatingAuthority()); $user = AuthenticatedUser::createFrom($translatedAssertion, $authenticatingAuthorities); $authenticatedToken = new SamlToken(['ROLE_USER']); $authenticatedToken->setUser($user); return $authenticatedToken; }
/** * @test * @group AssertionAdapter * @group AttributeSet */ public function the_attribute_set_to_use_has_to_implement_attribute_set_factory() { $this->setExpectedException('\\Surfnet\\SamlBundle\\Exception\\InvalidArgumentException', 'implement'); ConfigurableAttributeSetFactory::configureWhichAttributeSetToCreate('Non\\Existent\\Class'); }
public function __construct(SAML2_Assertion $assertion, AttributeDictionary $attributeDictionary) { $this->assertion = $assertion; $this->attributeSet = ConfigurableAttributeSetFactory::createFrom($assertion, $attributeDictionary); $this->attributeDictionary = $attributeDictionary; }