Search in sources :

Example 1 with InweboDeviceNameResponse

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()));
}
Also used : lombok.val(lombok.val) ServicesManager(org.apereo.cas.services.ServicesManager) InweboMultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties) InweboDeviceNameResponse(org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse) Test(org.junit.jupiter.api.Test)

Example 2 with InweboDeviceNameResponse

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;
}
Also used : lombok.val(lombok.val) InweboDeviceNameResponse(org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse)

Example 3 with InweboDeviceNameResponse

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;
}
Also used : lombok.val(lombok.val) InweboDeviceNameResponse(org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse)

Example 4 with InweboDeviceNameResponse

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;
}
Also used : lombok.val(lombok.val) InweboDeviceNameResponse(org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse)

Example 5 with InweboDeviceNameResponse

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));
}
Also used : lombok.val(lombok.val) ServicesManager(org.apereo.cas.services.ServicesManager) InweboMultifactorAuthenticationProperties(org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties) InweboDeviceNameResponse(org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse) Test(org.junit.jupiter.api.Test)

Aggregations

lombok.val (lombok.val)15 InweboDeviceNameResponse (org.apereo.cas.support.inwebo.service.response.InweboDeviceNameResponse)15 Test (org.junit.jupiter.api.Test)12 InweboMultifactorAuthenticationProperties (org.apereo.cas.configuration.model.support.mfa.InweboMultifactorAuthenticationProperties)2 ServicesManager (org.apereo.cas.services.ServicesManager)2