Package org.exoplatform.portal.rest
Interface UserAccountService
public interface UserAccountService
Administrator operations on user accounts, reached by the REST resources
of this module at call time through the container, since its
implementation lives in the web security module, above this one in the
module graph.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe creation source stamped on an account created by an administrator from the users-management screen: such an account keeps the self-service deactivation optionstatic final StringCode answered as 400 when the super user's account is deactivatedstatic final StringCode of an email already held by an account, answered as 400static final StringCode of a language that is not a supported locale, answered as 400static final StringName of the one-time-password method that confirms an administrator session: a code sent by email, generated and validated for this purpose only, so that a code issued for another flow never confirms a sessionstatic final Stringstatic final Stringstatic final StringThe parts a read-back reports missing, in this orderstatic final StringCode of an invalid role value, answered as 400static final StringCode answered as 400 when an administrator deactivates their own accountstatic final StringPrefix of the code answered as 500 when the account was created but some of its parts were not stored, and the account was deactivated:USER:CREATED_INCOMPLETE:<username>:<parts>static final StringPrefix of the code answered as 500 when the account was created, some of its parts were not stored, and the deactivation did not hold either:USER:CREATED_INCOMPLETE_ENABLED:<username>:<parts>static final StringCode answered as 500 when nothing was created: the store refused the insert, or the read-back found no account of this requeststatic final StringCode answered as 500 when the new password of an internal-store account does not authenticate after its change; nothing else is writtenstatic final StringCode answered as 500 when the new password of a deactivated internal-store account cannot be checked by the user handler in place; nothing else is writtenstatic final StringCode answered as 500 when the read-back after an update found a field other than requested: the names, the email, the enabled flag, or the language when the update carried onestatic final StringCode answered as 500 when every generated login collided and nothing was createdstatic final StringCode of a login already held by a live account, answered as 400static final StringCode of a login once held by a deleted account, which is never created again, answered as 400static final StringCode answered as 400 when the username policy of the platform refuses the form of a generated login, so that the administrator types one instead -
Method Summary
Modifier and TypeMethodDescriptionvoidconfirmSession(String username, String otpCode) Validates and consumes a one-time-password code sent to the user by theOTP_METHODmethod.createUser(UserAccount account, Locale locale) Creates an account as an administrator described it: the login is the one given, validated, or a generated one; the password is optional, and a blank one leaves the account with no credential until the user sets one from the onboarding email; the role decides the memberships; the language, when given, is stored as the user's preferred language.getLanguage(String username) Reads the preferred language stored for an accountvoidupdateUser(UserAccount account, Locale locale, String modifier) Updates an existing account as an administrator edited it: names, email, enabled flag, a password when given and a language when given.
-
Field Details
-
OTP_METHOD
Name of the one-time-password method that confirms an administrator session: a code sent by email, generated and validated for this purpose only, so that a code issued for another flow never confirms a session- See Also:
-
CREATION_SOURCE_UI
The creation source stamped on an account created by an administrator from the users-management screen: such an account keeps the self-service deactivation option- See Also:
-
ROLE_INVALID
Code of an invalid role value, answered as 400- See Also:
-
LANGUAGE_INVALID
Code of a language that is not a supported locale, answered as 400- See Also:
-
USERNAME_ALREADY_EXISTS
Code of a login already held by a live account, answered as 400- See Also:
-
USERNAME_ALREADY_EXISTS_AS_DELETED
Code of a login once held by a deleted account, which is never created again, answered as 400- See Also:
-
USERNAME_GENERATION_NOT_ALLOWED
Code answered as 400 when the username policy of the platform refuses the form of a generated login, so that the administrator types one instead- See Also:
-
EMAIL_ALREADY_EXISTS
Code of an email already held by an account, answered as 400- See Also:
-
USER_CREATION_FAILED
Code answered as 500 when nothing was created: the store refused the insert, or the read-back found no account of this request- See Also:
-
USER_USERNAME_GENERATION_EXHAUSTED
Code answered as 500 when every generated login collided and nothing was created- See Also:
-
USER_CREATED_INCOMPLETE
Prefix of the code answered as 500 when the account was created but some of its parts were not stored, and the account was deactivated:USER:CREATED_INCOMPLETE:<username>:<parts>- See Also:
-
USER_CREATED_INCOMPLETE_ENABLED
Prefix of the code answered as 500 when the account was created, some of its parts were not stored, and the deactivation did not hold either:USER:CREATED_INCOMPLETE_ENABLED:<username>:<parts>- See Also:
-
USER_UPDATE_INCOMPLETE
Code answered as 500 when the read-back after an update found a field other than requested: the names, the email, the enabled flag, or the language when the update carried one- See Also:
-
USER_PASSWORD_NOT_STORED
Code answered as 500 when the new password of an internal-store account does not authenticate after its change; nothing else is written- See Also:
-
USER_PASSWORD_NOT_VERIFIABLE
Code answered as 500 when the new password of a deactivated internal-store account cannot be checked by the user handler in place; nothing else is written- See Also:
-
SELF_DISABLE
Code answered as 400 when an administrator deactivates their own account- See Also:
-
DISABLE_SUPER_USER
Code answered as 400 when the super user's account is deactivated- See Also:
-
PART_MEMBERSHIPS
The parts a read-back reports missing, in this order- See Also:
-
PART_LANGUAGE
- See Also:
-
PART_ENABLED
- See Also:
-
-
Method Details
-
confirmSession
Validates and consumes a one-time-password code sent to the user by theOTP_METHODmethod. A code validates once: a second validation of the same code, even within its validity window, is refused.- Parameters:
username- user who received the codeotpCode- code typed by the user- Throws:
IllegalAccessException- when the code is blank, wrong, expired, already consumed, or when the user exceeded the allowed attempts
-
createUser
Creates an account as an administrator described it: the login is the one given, validated, or a generated one; the password is optional, and a blank one leaves the account with no credential until the user sets one from the onboarding email; the role decides the memberships; the language, when given, is stored as the user's preferred language. Once written, the persisted state is read back in a new transaction, and an account whose parts were not all stored is deactivated.- Parameters:
account- the account to createlocale- the locale of the validation messages- Returns:
- the login of the created account, generated or given
- Throws:
IllegalArgumentException- with the code of the refused field as message:USERNAME:,PASSWORD:,FIRSTNAME:,LASTNAME:orEMAIL:followed by the validation message, or one ofUSERNAME_ALREADY_EXISTS,USERNAME_ALREADY_EXISTS_AS_DELETED,USERNAME_GENERATION_NOT_ALLOWED,EMAIL_ALREADY_EXISTS,ROLE_INVALID,LANGUAGE_INVALIDUserAccountCreationException- when the store did not complete the creation as requested, with the code as message
-
updateUser
void updateUser(UserAccount account, Locale locale, String modifier) throws UserAccountUpdateException Updates an existing account as an administrator edited it: names, email, enabled flag, a password when given and a language when given. Every refusal is checked before the first write. The password is changed first, through the active change-password connector, and an internal-store account's new password is then proven to authenticate. The other writes follow; they are then read back in a new transaction.- Parameters:
account- the account as edited, identified by its loginlocale- the locale of the validation messagesmodifier- the login of the administrator who edits it- Throws:
IllegalArgumentException- with the code of the refused field as message:PASSWORD:,FIRSTNAME:,LASTNAME:orEMAIL:followed by the validation message, or one ofEMAIL_ALREADY_EXISTS,LANGUAGE_INVALID,SELF_DISABLE,DISABLE_SUPER_USER,USER:EMPTYorUSER:NOT_FOUND; nothing is written thenUserAccountUpdateException- when the store did not complete the update as requested, with the code as messageIllegalStateException- with no code when the connector refuses the password (an external store's account) or a store read before any write fails; nothing is written then
-
getLanguage
Reads the preferred language stored for an account- Parameters:
username- the login of the account- Returns:
- the preferred language stored for the account, which may no longer be a supported locale; null when none is stored
-
generateUsername
String generateUsername()- Returns:
- a candidate login that is not guessable from the user's name, email or creation order: a letter followed by eleven characters drawn at random from lowercase letters and digits
-