use of org.apereo.cas.adaptors.duo.authn.DuoSecurityDirectCredential in project cas by apereo.
the class DuoSecurityDirectAuthenticationAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) {
val authentication = WebUtils.getAuthentication(requestContext);
val c = new DuoSecurityDirectCredential(resolvePrincipal(authentication.getPrincipal()), provider.getId());
WebUtils.putCredential(requestContext, c);
return success();
}
use of org.apereo.cas.adaptors.duo.authn.DuoSecurityDirectCredential in project cas by apereo.
the class DuoSecurityRestHttpRequestCredentialFactoryTests method verifyOperation.
@Test
public void verifyOperation() {
val factory = new DuoSecurityRestHttpRequestCredentialFactory();
val request = new MockHttpServletRequest();
val body = new LinkedMultiValueMap<String, String>();
assertTrue(factory.fromRequest(request, body).isEmpty());
body.put(RestHttpRequestCredentialFactory.PARAMETER_USERNAME, List.of("user"));
assertTrue(factory.fromRequest(request, body).isEmpty());
body.put(DuoSecurityRestHttpRequestCredentialFactory.PARAMETER_NAME_PASSCODE, List.of("123456"));
body.put(DuoSecurityRestHttpRequestCredentialFactory.PARAMETER_NAME_PROVIDER, List.of("custom-duo"));
var credentials = factory.fromRequest(request, body);
assertFalse(credentials.isEmpty());
var credential = (DuoSecurityPasscodeCredential) credentials.get(0);
assertEquals(credential.getProviderId(), "custom-duo");
credentials = factory.fromAuthentication(request, body, CoreAuthenticationTestUtils.getAuthentication(), new TestMultifactorAuthenticationProvider());
val directCredential = (DuoSecurityDirectCredential) credentials.get(0);
assertEquals(TestMultifactorAuthenticationProvider.ID, directCredential.getProviderId());
assertNotNull(directCredential.getPrincipal());
}
Aggregations