Search in sources :

Example 1 with FactorType

use of com.okta.authn.sdk.resource.FactorType in project okta-auth-java by okta.

the class AuthHelper method proceedToVerifyView.

public static ModelAndView proceedToVerifyView(final AuthenticationResponse authenticationResponse, final AuthenticationClient authenticationClient, final AuthenticationStateHandler ignoringStateHandler) throws AuthenticationException {
    final String factorId = authenticationResponse.getFactors().get(0).getId();
    final FactorType factorType = authenticationResponse.getFactors().get(0).getType();
    final String stateToken = authenticationResponse.getStateToken();
    // we only support Email factor for sample purpose
    if (factorType == FactorType.EMAIL) {
        AuthenticationResponse authResponse = authenticationClient.verifyFactor(factorId, stateToken, ignoringStateHandler);
        final ModelAndView emailAuthView = new ModelAndView("verify-email-authenticator");
        emailAuthView.addObject("authenticationResponse", authResponse);
        return emailAuthView;
    } else {
        final ModelAndView errorView = new ModelAndView("home");
        errorView.addObject("error", "Factor type " + factorType + " + is not supported in this sample yet");
        return errorView;
    }
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) FactorType(com.okta.authn.sdk.resource.FactorType) AuthenticationResponse(com.okta.authn.sdk.resource.AuthenticationResponse)

Example 2 with FactorType

use of com.okta.authn.sdk.resource.FactorType in project okta-auth-java by okta.

the class MfaVerifyView method relativeLink.

public static String relativeLink(Factor factor) {
    FactorType type = factor.getType();
    String templateName;
    switch(type) {
        case U2F:
            templateName = "u2f";
            break;
        case TOKEN_SOFTWARE_TOTP:
            templateName = "totp";
            break;
        case SMS:
            templateName = "sms";
            break;
        default:
            templateName = "unknown";
    }
    return templateName;
}
Also used : FactorType(com.okta.authn.sdk.resource.FactorType)

Example 3 with FactorType

use of com.okta.authn.sdk.resource.FactorType in project cerberus by Nike-Inc.

the class InitialLoginStateHandlerTest method handleMfaEnroll.

@Test
public void handleMfaEnroll() throws Exception {
    String email = "email";
    String id = "id";
    AuthStatus expectedStatus = AuthStatus.MFA_REQUIRED;
    FactorProvider provider = FactorProvider.OKTA;
    FactorType type = FactorType.TOKEN_SOFTWARE_TOTP;
    String deviceId = "device id";
    String status = "status";
    AuthenticationResponse expectedResponse = mock(AuthenticationResponse.class);
    User user = mock(User.class);
    when(user.getId()).thenReturn(id);
    when(user.getLogin()).thenReturn(email);
    when(expectedResponse.getUser()).thenReturn(user);
    DefaultFactor factor = mock(DefaultFactor.class);
    when(factor.getType()).thenReturn(type);
    when(factor.getProvider()).thenReturn(provider);
    when(factor.getStatus()).thenReturn(status);
    when(factor.getId()).thenReturn(deviceId);
    when(expectedResponse.getFactors()).thenReturn(Lists.newArrayList(factor));
    // do the call
    initialLoginStateHandler.handleMfaEnroll(expectedResponse);
    AuthResponse actualResponse = authenticationResponseFuture.get(1, TimeUnit.SECONDS);
    // verify results
    assertEquals(id, actualResponse.getData().getUserId());
    assertEquals(email, actualResponse.getData().getUsername());
    assertEquals(expectedStatus, actualResponse.getStatus());
}
Also used : User(com.okta.authn.sdk.resource.User) AuthStatus(com.nike.cerberus.auth.connector.AuthStatus) DefaultFactor(com.okta.authn.sdk.impl.resource.DefaultFactor) FactorType(com.okta.authn.sdk.resource.FactorType) AuthenticationResponse(com.okta.authn.sdk.resource.AuthenticationResponse) FactorProvider(com.okta.authn.sdk.resource.FactorProvider) AuthResponse(com.nike.cerberus.auth.connector.AuthResponse) Test(org.junit.Test)

Example 4 with FactorType

use of com.okta.authn.sdk.resource.FactorType in project cerberus by Nike-Inc.

the class AbstractOktaStateHandler method isPush.

/**
 * Determines whether a trigger is required for a provided MFA factor
 *
 * @param factor Okta MFA factor
 * @return boolean trigger required
 */
public boolean isPush(Factor factor) {
    final FactorType type = factor.getType();
    final FactorProvider provider = factor.getProvider();
    return (provider.equals(FactorProvider.OKTA) && type == FactorType.PUSH);
}
Also used : FactorType(com.okta.authn.sdk.resource.FactorType) FactorProvider(com.okta.authn.sdk.resource.FactorProvider)

Example 5 with FactorType

use of com.okta.authn.sdk.resource.FactorType in project cerberus by Nike-Inc.

the class AbstractOktaStateHandlerTest method getDeviceNameOktaSms.

@Test
public void getDeviceNameOktaSms() {
    FactorProvider provider = FactorProvider.OKTA;
    FactorType type = FactorType.SMS;
    DefaultFactor factor = mock(DefaultFactor.class);
    when(factor.getType()).thenReturn(type);
    when(factor.getProvider()).thenReturn(provider);
    String result = this.abstractOktaStateHandler.getDeviceName(factor);
    assertEquals("Okta Text Message Code", result);
}
Also used : DefaultFactor(com.okta.authn.sdk.impl.resource.DefaultFactor) FactorType(com.okta.authn.sdk.resource.FactorType) FactorProvider(com.okta.authn.sdk.resource.FactorProvider) Test(org.junit.Test)

Aggregations

FactorType (com.okta.authn.sdk.resource.FactorType)10 FactorProvider (com.okta.authn.sdk.resource.FactorProvider)8 DefaultFactor (com.okta.authn.sdk.impl.resource.DefaultFactor)7 Test (org.junit.Test)7 AuthenticationResponse (com.okta.authn.sdk.resource.AuthenticationResponse)3 AuthResponse (com.nike.cerberus.auth.connector.AuthResponse)2 AuthStatus (com.nike.cerberus.auth.connector.AuthStatus)2 User (com.okta.authn.sdk.resource.User)2 ModelAndView (org.springframework.web.servlet.ModelAndView)1