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);
}
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;
}
Aggregations