本文整理汇总了PHP中Symfony\Component\Security\Core\Authentication\Token\TokenInterface::getLoa方法的典型用法代码示例。如果您正苦于以下问题:PHP TokenInterface::getLoa方法的具体用法?PHP TokenInterface::getLoa怎么用?PHP TokenInterface::getLoa使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Security\Core\Authentication\Token\TokenInterface
的用法示例。
在下文中一共展示了TokenInterface::getLoa方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* @param SamlToken|TokenInterface $token
* @return TokenInterface|void
*/
public function authenticate(TokenInterface $token)
{
$translatedAssertion = $this->attributeDictionary->translate($token->assertion);
$nameId = $translatedAssertion->getNameID();
$institution = $translatedAssertion->getAttribute('schacHomeOrganization');
$identity = $this->identityService->findByNameIdAndInstitution($nameId, $institution);
// if no identity can be found, we're done.
if ($identity === null) {
throw new BadCredentialsException('Unable to find Identity matching the criteria. Has the identity been registered before?');
}
$raCredentials = $this->identityService->getRaCredentials($identity);
// if no credentials can be found, we're done.
if (!$raCredentials) {
throw new BadCredentialsException('The Identity is not registered as (S)RA(A) and therefor does not have access to this application');
}
// determine the role based on the credentials given
$roles = [];
if ($raCredentials->isSraa) {
$roles[] = 'ROLE_SRAA';
}
if ($raCredentials->isRaa) {
$roles[] = 'ROLE_RAA';
} else {
$roles[] = 'ROLE_RA';
}
// set the token
$authenticatedToken = new SamlToken($token->getLoa(), $roles);
$authenticatedToken->setUser($identity);
return $authenticatedToken;
}