use of org.apereo.cas.adaptors.duo.authn.DuoSecurityAuthenticationService in project cas by apereo.
the class DetermineDuoUserAccountAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
final Authentication authentication = WebUtils.getAuthentication(requestContext);
final Principal p = authentication.getPrincipal();
final Collection<MultifactorAuthenticationProvider> providers = WebUtils.getResolvedMultifactorAuthenticationProviders(requestContext);
for (final MultifactorAuthenticationProvider pr : providers) {
final DuoMultifactorAuthenticationProvider duoProvider = this.provider.findProvider(pr.getId(), DuoMultifactorAuthenticationProvider.class);
final DuoSecurityAuthenticationService duoAuthenticationService = duoProvider.getDuoAuthenticationService();
final DuoUserAccount account = duoAuthenticationService.getDuoUserAccount(p.getId());
if (account.getStatus() == DuoUserAccountAuthStatus.ENROLL && StringUtils.isNotBlank(duoProvider.getRegistrationUrl())) {
requestContext.getFlowScope().put("duoRegistrationUrl", duoProvider.getRegistrationUrl());
return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_ENROLL);
}
}
return success();
}
use of org.apereo.cas.adaptors.duo.authn.DuoSecurityAuthenticationService in project cas by apereo.
the class PrepareDuoWebLoginFormAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
final Principal p = WebUtils.getAuthentication(requestContext).getPrincipal();
final DuoCredential c = requestContext.getFlowScope().get(CasWebflowConstants.VAR_ID_CREDENTIAL, DuoCredential.class);
c.setUsername(p.getId());
final Collection<MultifactorAuthenticationProvider> providers = WebUtils.getResolvedMultifactorAuthenticationProviders(requestContext);
providers.forEach(pr -> {
final DuoSecurityAuthenticationService duoAuthenticationService = provider.findProvider(pr.getId(), DuoMultifactorAuthenticationProvider.class).getDuoAuthenticationService();
final MutableAttributeMap<Object> viewScope = requestContext.getViewScope();
viewScope.put("sigRequest", duoAuthenticationService.signRequestToken(p.getId()));
viewScope.put("apiHost", duoAuthenticationService.getApiHost());
viewScope.put("commandName", "credential");
viewScope.put("principal", p);
});
return success();
}
Aggregations