Search in sources :

Example 16 with RememberDeviceSettings

use of io.gravitee.am.model.RememberDeviceSettings in project gravitee-access-management by gravitee-io.

the class AuthenticationFlowHandlerTest method shouldRedirectToMFAEnrollmentPage_device_unknown.

@Test
public void shouldRedirectToMFAEnrollmentPage_device_unknown() throws Exception {
    router.route().order(-1).handler(rc -> {
        // set client
        Client client = new Client();
        client.setFactors(Collections.singleton("factor-1"));
        rc.put(ConstantKeys.CLIENT_CONTEXT_KEY, client);
        MFASettings mfaSettings = new MFASettings();
        final RememberDeviceSettings rememberDevice = new RememberDeviceSettings();
        rememberDevice.setActive(true);
        mfaSettings.setRememberDevice(rememberDevice);
        rc.session().put(DEVICE_ALREADY_EXISTS_KEY, false);
        client.setMfaSettings(mfaSettings);
        // set user
        io.gravitee.am.model.User endUser = new io.gravitee.am.model.User();
        rc.getDelegate().setUser(new User(endUser));
        rc.next();
    });
    testRequest(HttpMethod.GET, "/login", null, resp -> {
        String location = resp.headers().get("location");
        assertNotNull(location);
        assertTrue(location.endsWith("/mfa/enroll"));
    }, HttpStatusCode.FOUND_302, "Found", null);
}
Also used : User(io.gravitee.am.gateway.handler.common.vertx.web.auth.user.User) RememberDeviceSettings(io.gravitee.am.model.RememberDeviceSettings) MFASettings(io.gravitee.am.model.MFASettings) Client(io.gravitee.am.model.oidc.Client) Test(org.junit.Test)

Example 17 with RememberDeviceSettings

use of io.gravitee.am.model.RememberDeviceSettings in project gravitee-access-management by gravitee-io.

the class PatchRememberDeviceSettings method patch.

public RememberDeviceSettings patch(RememberDeviceSettings _toPatch) {
    RememberDeviceSettings toPatch = _toPatch == null ? new RememberDeviceSettings() : new RememberDeviceSettings(_toPatch);
    SetterUtils.safeSet(toPatch::setDeviceIdentifierId, this.getDeviceIdentifierId());
    SetterUtils.safeSet(toPatch::setActive, this.getActive());
    final Optional<Long> expirationTimeSeconds = isNull(this.getExpirationTimeSeconds()) ? Optional.empty() : this.getExpirationTimeSeconds();
    SetterUtils.safeSet(toPatch::setExpirationTimeSeconds, expirationTimeSeconds.filter(Objects::nonNull).map(Math::abs));
    return toPatch;
}
Also used : RememberDeviceSettings(io.gravitee.am.model.RememberDeviceSettings) Objects(java.util.Objects)

Aggregations

RememberDeviceSettings (io.gravitee.am.model.RememberDeviceSettings)17 MFASettings (io.gravitee.am.model.MFASettings)16 Test (org.junit.Test)16 Client (io.gravitee.am.model.oidc.Client)8 User (io.gravitee.am.gateway.handler.common.vertx.web.auth.user.User)5 User (io.gravitee.am.model.User)4 EnrolledFactor (io.gravitee.am.model.factor.EnrolledFactor)4 JsonObject (io.vertx.core.json.JsonObject)2 Objects (java.util.Objects)1