Package io.meeds.social.security.service
Class AccountDeactivationService
java.lang.Object
io.meeds.social.security.service.AccountDeactivationService
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final org.exoplatform.commons.api.settings.data.ScopeCoordinates of the per-user marker recording a confirmed deletion request: one row per requester under its user context, valued with the request time in epoch milliseconds.static final Stringstatic final StringThe only creation source qualifying an account as managed by the platform itself, as stamped by the users management UI (org.exoplatform.portal.rest.UserRestResourcesV1#CREATION_SOURCE_UI). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisDeactivationAllowed(String username) The deactivation is offered only for accounts whose lifecycle belongs to the platform: the super user and externally synchronized accounts (LDAP) are excluded, and among the others only those created through the platform UI qualify.booleanisDeletionAllowed(String username) The deletion request rides the deactivation one: it is offered only when the admin enabled it on top of the deactivation, to users already qualifying for the deactivation.voidrequestDeactivation(String username, String otpMethod, String otpCode, boolean deleteRequested) Deactivates the account of the designated user after validating the OTP code: this is the single authoritative OTP validation of the flow.protected voidsendUserConfirmationEmail(String username, boolean deleteRequested) Sends the confirmation email to the user, before the account gets disabled.
-
Field Details
-
ACCOUNT_DEACTIVATION_REQUESTED_EVENT
- See Also:
-
ACCOUNT_DELETION_REQUESTED_EVENT
- See Also:
-
DELETION_REQUEST_SCOPE
public static final org.exoplatform.commons.api.settings.data.Scope DELETION_REQUEST_SCOPECoordinates of the per-user marker recording a confirmed deletion request: one row per requester under its user context, valued with the request time in epoch milliseconds. The deletion processing job reads them back through SettingService#getContextsByTypeAndScopeAndSettingName. -
DELETION_REQUEST_SETTING_NAME
- See Also:
-
UI_CREATION_SOURCE
The only creation source qualifying an account as managed by the platform itself, as stamped by the users management UI (org.exoplatform.portal.rest.UserRestResourcesV1#CREATION_SOURCE_UI).- See Also:
-
-
Constructor Details
-
AccountDeactivationService
public AccountDeactivationService()
-
-
Method Details
-
isDeactivationAllowed
The deactivation is offered only for accounts whose lifecycle belongs to the platform: the super user and externally synchronized accounts (LDAP) are excluded, and among the others only those created through the platform UI qualify. An account with no creation source predates the stamping of that attribute: it keeps the option rather than losing it on an unknown provenance. -
isDeletionAllowed
The deletion request rides the deactivation one: it is offered only when the admin enabled it on top of the deactivation, to users already qualifying for the deactivation. -
requestDeactivation
public void requestDeactivation(String username, String otpMethod, String otpCode, boolean deleteRequested) throws IllegalAccessException Deactivates the account of the designated user after validating the OTP code: this is the single authoritative OTP validation of the flow. When the deletion is also requested, the request time is durably recorded before the account gets disabled, so a recording failure never silently downgrades a deletion request to a plain deactivation; without a deletion request, any stale marker left by a previously re-enabled account is cleared instead.- Throws:
IllegalStateException- when the deactivation isn't allowed for the user (admin option off, externally synchronized account or account whose creation source isn't managed by the platform), or when the deletion is requested while the admin deletion option is offIllegalAccessException- when the OTP code is blank, invalid or the validation tentatives are exhausted
-
sendUserConfirmationEmail
Sends the confirmation email to the user, before the account gets disabled. When the deletion was also requested, the email additionally reminds that the account will be deleted in 30 days. The sending is best effort: a mail server failure doesn't prevent the deactivation deliberately requested by the user.
-