use of org.apereo.cas.authentication.Authentication in project cas by apereo.
the class AbstractServiceValidateController method validateAuthenticationContext.
/**
* Validate authentication context pair.
*
* @param assertion the assertion
* @param request the request
* @return the pair
*/
protected Pair<Boolean, Optional<MultifactorAuthenticationProvider>> validateAuthenticationContext(final Assertion assertion, final HttpServletRequest request) {
LOGGER.debug("Locating the primary authentication associated with this service request [{}]", assertion.getService());
final RegisteredService service = this.servicesManager.findServiceBy(assertion.getService());
RegisteredServiceAccessStrategyUtils.ensureServiceAccessIsAllowed(assertion.getService(), service);
final Map<String, MultifactorAuthenticationProvider> providers = this.applicationContext.getBeansOfType(MultifactorAuthenticationProvider.class, false, true);
final Authentication authentication = assertion.getPrimaryAuthentication();
final Optional<String> requestedContext = this.multifactorTriggerSelectionStrategy.resolve(providers.values(), request, service, authentication);
if (!requestedContext.isPresent()) {
LOGGER.debug("No particular authentication context is required for this request");
return Pair.of(Boolean.TRUE, Optional.empty());
}
return this.authenticationContextValidator.validate(authentication, requestedContext.get(), service);
}
use of org.apereo.cas.authentication.Authentication in project cas by apereo.
the class Cas30JsonResponseView method createAuthenticationSuccess.
private CasJsonServiceResponseAuthenticationSuccess createAuthenticationSuccess(final Map<String, Object> model) {
final CasJsonServiceResponseAuthenticationSuccess success = new CasJsonServiceResponseAuthenticationSuccess();
success.setAttributes(getModelAttributes(model));
final Principal principal = getPrincipal(model);
success.setUser(principal.getId());
success.setProxyGrantingTicket(getProxyGrantingTicketIou(model));
final Collection<Authentication> chainedAuthentications = getChainedAuthentications(model);
if (chainedAuthentications != null && !chainedAuthentications.isEmpty()) {
final List<String> proxies = chainedAuthentications.stream().map(authn -> authn.getPrincipal().getId()).collect(Collectors.toList());
success.setProxies(proxies);
}
return success;
}
use of org.apereo.cas.authentication.Authentication in project cas by apereo.
the class Cas10ResponseViewTests method setUp.
@Before
public void setUp() {
this.model = new HashMap<>();
final List<Authentication> list = new ArrayList<>();
list.add(CoreAuthenticationTestUtils.getAuthentication("someothername"));
this.model.put("assertion", new DefaultAssertionBuilder(CoreAuthenticationTestUtils.getAuthentication()).with(list).with(CoreAuthenticationTestUtils.getService("TestService")).with(true).build());
}
use of org.apereo.cas.authentication.Authentication in project cas by apereo.
the class OidcCasClientRedirectActionBuilder method build.
@Override
public RedirectAction build(final CasClient casClient, final WebContext context) {
final Optional<Authentication> auth = oidcAuthorizationRequestSupport.isCasAuthenticationAvailable(context);
auth.ifPresent(authentication -> oidcAuthorizationRequestSupport.configureClientForMaxAgeAuthorizationRequest(casClient, context, authentication));
OidcAuthorizationRequestSupport.configureClientForPromptLoginAuthorizationRequest(casClient, context);
OidcAuthorizationRequestSupport.configureClientForPromptNoneAuthorizationRequest(casClient, context);
final RedirectAction action = super.build(casClient, context);
LOGGER.debug("Final redirect action is [{}]", action);
return action;
}
use of org.apereo.cas.authentication.Authentication in project cas by apereo.
the class OAuth20AccessTokenControllerTests method addRefreshToken.
private RefreshToken addRefreshToken(final Principal principal, final RegisteredService registeredService) {
final Authentication authentication = getAuthentication(principal);
final WebApplicationServiceFactory factory = new WebApplicationServiceFactory();
final Service service = factory.createService(registeredService.getServiceId());
final RefreshToken refreshToken = oAuthRefreshTokenFactory.create(service, authentication);
oAuth20AccessTokenController.getTicketRegistry().addTicket(refreshToken);
return refreshToken;
}
Aggregations