use of org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse in project cas by apereo.
the class InweboAuthenticationHandlerTests method verifyOperation.
@Test
public void verifyOperation() throws Exception {
val inweboService = mock(InweboService.class);
val response = new InweboDeviceNameResponse();
response.setDeviceName("DeviceName");
response.setResult(InweboResult.OK);
when(inweboService.authenticateExtended(anyString(), anyString())).thenReturn(response);
val handler = new InweboAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), new InweboMultifactorAuthenticationProperties(), inweboService);
val credential = new InweboCredential("token");
credential.setOtp("otp");
val result = handler.authenticate(credential);
assertNotNull(result);
assertNotNull(credential.getDeviceName());
assertTrue(handler.supports(credential));
assertTrue(handler.supports(credential.getCredentialClass()));
}
use of org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse in project cas by apereo.
the class InweboService method authenticateExtended.
/**
* Extend the authentication attempt.
*
* @param login the login
* @param token the token
* @return the inwebo device name response
*/
public InweboDeviceNameResponse authenticateExtended(final String login, final String token) {
val inwebo = casProperties.getAuthn().getMfa().getInwebo();
val url = UriComponentsBuilder.fromHttpUrl(inwebo.getServiceApiUrl()).queryParam("action", "authenticateExtended").queryParam("serviceId", inwebo.getServiceId()).queryParam("userId", login).queryParam("token", token).queryParam("format", "json").toUriString();
val json = call(url);
val err = json.get("err").asText("OK");
val response = (InweboDeviceNameResponse) buildResponse(new InweboDeviceNameResponse(), "authenticateExtended(" + login + ')', err);
retrieveDeviceName(json, response);
return response;
}
use of org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse in project cas by apereo.
the class BaseActionTests method deviceResponse.
protected static InweboDeviceNameResponse deviceResponse(final InweboResult result) {
val response = new InweboDeviceNameResponse();
response.setResult(result);
if (result == InweboResult.OK) {
response.setDeviceName(DEVICE_NAME);
}
return response;
}
use of org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse in project cas by apereo.
the class InweboService method checkPushResult.
/**
* Check push result for inwebo device.
*
* @param login the login
* @param sessionId the session id
* @return the inwebo device name response
*/
public InweboDeviceNameResponse checkPushResult(final String login, final String sessionId) {
val inwebo = casProperties.getAuthn().getMfa().getInwebo();
val url = UriComponentsBuilder.fromHttpUrl(inwebo.getServiceApiUrl()).queryParam("action", "checkPushResult").queryParam("serviceId", inwebo.getServiceId()).queryParam("userId", login).queryParam("sessionId", sessionId).queryParam("format", "json").toUriString();
val json = call(url);
val err = json.get("err").asText("OK");
val response = (InweboDeviceNameResponse) buildResponse(new InweboDeviceNameResponse(), "checkPushResult(" + login + ')', err);
retrieveDeviceName(json, response);
return response;
}
use of org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse in project cas by apereo.
the class InweboAuthenticationHandlerTests method verifyFailsOperation.
@Test
public void verifyFailsOperation() {
val inweboService = mock(InweboService.class);
val response = new InweboDeviceNameResponse();
response.setDeviceName("DeviceName");
response.setResult(InweboResult.OK);
when(inweboService.authenticateExtended(anyString(), anyString())).thenReturn(response);
val handler = new InweboAuthenticationHandler(mock(ServicesManager.class), PrincipalFactoryUtils.newPrincipalFactory(), new InweboMultifactorAuthenticationProperties(), inweboService);
val credential = new InweboCredential("token");
assertThrows(FailedLoginException.class, () -> handler.authenticate(credential));
}
Aggregations