com.memority.citadel.shared.api.im.AuthMethodStatus Maven / Gradle / Ivy
Show all versions of citadel-api Show documentation
/*
* Copyright (c) 2016-2023 Memority. All Rights Reserved.
*
* This file is part of Memority Citadel API , a Memority project.
*
* This file is released under the Memority Public Artifacts End-User License Agreement,
* see
* Unauthorized copying of this file, via any medium is strictly prohibited.
*/
package com.memority.citadel.shared.api.im;
/**
* For a complete description of the authentication methods, please refer to https://share.memority.fr/wiki/pages/viewpage.action?pageId=33474793
*
* Describe the state of an Authentication Method for a given Identity.
*/
public enum AuthMethodStatus {
/**
* Authentication Method is disabled for the User, meaning he/she cannot use it. This translates into the user not
* having the corresponding authentication method right.
*/
DISABLED (false),
/**
* Authentication Method is enabled for the User, but not active, meaning it cannot be used yet to authenticate.
*/
ENABLED (true),
/**
* Authentication Method is being activated. Authentication may be performed, but some additional operations will
* be required to make it fully usable (typically, change the password).
*/
ACTIVATING (true),
/**
* Authentication Method is active and usable for standard authentication.
*/
ACTIVE (true);
private final boolean authorized;
AuthMethodStatus(boolean authorized) {
this.authorized = authorized;
}
/**
* Check if Status is authorized
*
* @return whether the status is authorized
*/
public boolean isAuthorized() {
return authorized;
}
/**
* Indicate whether this status can be manually transitioned to the given one.
* Typically, transition to and from DISABLED can be done through right grants or using
* the associated TO and FROM attributes.
*
* @param to the target status
* @return true
if transition is authorized, false
otherwise
*/
public boolean canTransitionTo(AuthMethodStatus to) {
if (this == to) {
return true;
}
switch (this) {
case ACTIVATING:
return to == ACTIVE || to == ENABLED;
case ACTIVE:
return to == ENABLED;
case ENABLED:
return to == ACTIVATING || to == ACTIVE;
case DISABLED:
default:
return false;
}
}
/**
* Access constants related to the authentication method status.
*/
public static class Constants {
private Constants() {}
/**
* The i18n prefix to use for the different state value
*/
public static final String I18N_PREFIX = "ctd.common.authMethodStatus";
}
}