use of org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider in project cas by apereo.
the class YubiKeyAuthenticationPrepareLoginActionTests method setup.
@BeforeEach
public void setup() {
val applicationContext = new StaticApplicationContext();
applicationContext.refresh();
ApplicationContextProvider.holdApplicationContext(applicationContext);
TestMultifactorAuthenticationProvider.registerProviderIntoApplicationContext(applicationContext, new YubiKeyMultifactorAuthenticationProvider());
ApplicationContextProvider.registerBeanIntoApplicationContext(applicationContext, MultifactorAuthenticationPrincipalResolver.identical(), UUID.randomUUID().toString());
}
use of org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider in project cas by apereo.
the class YubiKeyAuthenticationEventExecutionPlanConfiguration method yubikeyMultifactorAuthenticationProvider.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public MultifactorAuthenticationProvider yubikeyMultifactorAuthenticationProvider(final CasConfigurationProperties casProperties, @Qualifier("yubicoClient") final YubicoClient yubicoClient, @Qualifier("httpClient") final HttpClient httpClient, @Qualifier("yubikeyBypassEvaluator") final MultifactorAuthenticationProviderBypassEvaluator yubikeyBypassEvaluator, @Qualifier("failureModeEvaluator") final MultifactorAuthenticationFailureModeEvaluator failureModeEvaluator) {
val yubi = casProperties.getAuthn().getMfa().getYubikey();
val p = new YubiKeyMultifactorAuthenticationProvider(yubicoClient, httpClient);
p.setBypassEvaluator(yubikeyBypassEvaluator);
p.setFailureMode(yubi.getFailureMode());
p.setFailureModeEvaluator(failureModeEvaluator);
p.setOrder(yubi.getRank());
p.setId(yubi.getId());
return p;
}
use of org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider in project cas by apereo.
the class YubiKeyAccountCheckRegistrationActionTests method verifyActionRegister.
@Test
public void verifyActionRegister() throws Exception {
val context = new MockRequestContext();
val request = new MockHttpServletRequest();
context.setExternalContext(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
val authentication = CoreAuthenticationTestUtils.getAuthentication();
WebUtils.putAuthentication(authentication, context);
WebUtils.putMultifactorAuthenticationProviderIdIntoFlowScope(context, new YubiKeyMultifactorAuthenticationProvider());
val registry = new ClosedYubiKeyAccountRegistry(new DenyAllYubiKeyAccountValidator());
val action = new YubiKeyAccountCheckRegistrationAction(registry);
assertEquals(CasWebflowConstants.TRANSITION_ID_REGISTER, action.execute(context).getId());
}
use of org.apereo.cas.adaptors.yubikey.YubiKeyMultifactorAuthenticationProvider in project cas by apereo.
the class YubiKeyAccountSaveRegistrationActionTests method verifyActionFails.
@Test
public void verifyActionFails() throws Exception {
val context = mock(RequestContext.class);
when(context.getMessageContext()).thenReturn(mock(MessageContext.class));
when(context.getFlowScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
when(context.getConversationScope()).thenReturn(new LocalAttributeMap<>());
when(context.getRequestParameters()).thenReturn(new MockParameterMap());
val request = new MockHttpServletRequest();
when(context.getExternalContext()).thenReturn(new ServletExternalContext(new MockServletContext(), request, new MockHttpServletResponse()));
WebUtils.putMultifactorAuthenticationProviderIdIntoFlowScope(context, new YubiKeyMultifactorAuthenticationProvider());
WebUtils.putAuthentication(CoreAuthenticationTestUtils.getAuthentication(), context);
val action = new YubiKeyAccountSaveRegistrationAction(new OpenYubiKeyAccountRegistry(new AcceptAllYubiKeyAccountValidator()));
assertEquals(CasWebflowConstants.TRANSITION_ID_ERROR, action.execute(context).getId());
}
Aggregations