/**
  * @param AuthenticatedUser $user
  * @return ConsentList|null
  */
 public function findAllFor(AuthenticatedUser $user)
 {
     if (!$user->getAttributes()->containsAttributeDefinedBy($this->identifyingAttribute)) {
         $message = sprintf('Cannot get consent list for user: user does not have identifying attribute "%s"', $this->identifyingAttribute->getName());
         $this->logger->error($message);
         return null;
     }
     $userIdentifier = $user->getAttributes()->getAttributeByDefinition($this->identifyingAttribute);
     $identifyingValues = $userIdentifier->getValue();
     $identifyingValue = array_shift($identifyingValues);
     if (!is_string($identifyingValue)) {
         $message = sprintf('In order to get the consent list for a user, the identifying attribute must have a string value. "%s"' . 'given for identifying attribute "%s"', gettype($identifyingValue), $this->identifyingAttribute->getName());
         $this->logger->error($message);
         return null;
     }
     return $this->consentRepository->findAllFor($identifyingValue);
 }
 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;
 }
Пример #3
0
 public function getId()
 {
     return $this->authenticatedUser->getNameId();
 }
 /**
  * @test
  * @group Authentication
  * @group Attributes
  */
 public function epti_attribute_is_correctly_set_when_creating_an_authenticated_user()
 {
     $expectedAttributeSet = AttributeSet::create([new Attribute(new AttributeDefinition('eduPersonTargetedID', 'urn:mace:dir:attribute-def:eduPersonTargetedID'), ['abcd-some-value-xyz']), new Attribute(new AttributeDefinition('displayName', 'urn:mace:dir:attribute-def:displayName'), ['Tester'])]);
     $assertionWithEpti = $this->getAssertionWithEpti();
     $attributeDictionary = $this->getAttributeDictionary();
     $assertionAdapter = $this->mockAssertionAdapterWith(AttributeSet::createFrom($assertionWithEpti, $attributeDictionary), 'abcd-some-value-xyz');
     $authenticatedUser = AuthenticatedUser::createFrom($assertionAdapter, []);
     $actualAttributeSet = $authenticatedUser->getAttributes();
     $this->assertEquals($expectedAttributeSet, $actualAttributeSet);
 }