Package io.goobi.viewer.managedbeans
Class UserBean
java.lang.Object
io.goobi.viewer.managedbeans.UserBean
- All Implemented Interfaces:
Serializable
JSF session-scoped backing bean responsible for user authentication, registration, and account
management. Holds the currently logged-in
User
and mediates login/logout across local and OpenID Connect providers.
Lifecycle: Created once per HTTP session; destroyed when the session expires or the
user explicitly logs out. Sensitive credential fields (password, passwordOne,
passwordTwo) are declared transient and are therefore not included in session
serialisation.
Thread safety: Mostly confined to the JSF request thread. The
getAuthenticationProviders() method is synchronized to prevent concurrent
lazy initialisation of the provider list.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassRepresents aTimerTaskthat periodically updates the session timeout counter to keep the user's session information current. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactivateUserAccountAction.voidagreeToTermsOfUse.voidcreateBackupOfCurrentUser.Creates and persists a new local User.Getter for the fieldactivationKey.Returns a list of all existing users (minus the superusers and the current user).Getter for the fieldauthenticationProvider.getAuthenticationProviderName.Getter for the fieldauthenticationProviders.getEmail()Getter for the fieldemail.Checks whether the logged in user has access to the admin backend via being an admin or having CMS/campaign/comments access.Getter for the fieldlastName.getLocalAuthenticationProvider.Getter for the fieldnickName.intgetNumberOfProviderTypes.Getter for the fieldpassword.Getter for the fieldpasswordOne.Getter for the fieldpasswordTwo.getProvidersOfType(String type) getProvidersOfType.Getter for the fieldredirectUrl.getSessionTimeout.Getter for the fieldtranskribusPassword.Getter for the fieldtranskribusUserName.getUser()Getter for the fielduser.getXserviceAuthenticationProvider.booleanhasProvidersOfType(String type) hasProvidersOfType.booleanisAdmin()isAdmin.booleanisAllowEmailChange.booleanisAllowNickNameChange.booleanisAllowPasswordChange.booleanbooleanisLoggedIn.booleanisRequireLoginCaptcha.booleanisShowOpenId.booleanisUserRegistrationEnabled.login()Login action method for local accounts.login(IAuthenticationProvider provider) login.logout()Logout action method.voidlogoutWithMessage(String messageKey) logoutWithMessage.booleanChecks if the current user is required to agree to the terms of use.voidrejectTermsOfUse.Generates a new user password if the key is correct.voidresetPasswordFields.Sends a password reset link to the current e-mail address.voidsetActivationKey(String activationKey) Setter for the fieldactivationKey.voidSetter for the fieldauthenticationProvider.voidsetAuthenticationProviderName.voidSetter for the fieldemail.voidsetHasAdminBackendAccess(Boolean hasAdminBackendAccess) Setter for the fieldhasAdminBackendAccess.voidsetLastName(String lastName) Setter for the fieldlastName.voidsetNickName(String nickName) Setter for the fieldnickName.voidvoidsetPassword(String password) Setter for the fieldpassword.voidsetPasswordOne(String passwordOne) Setter for the fieldpasswordOne.voidsetPasswordTwo(String passwordTwo) Setter for the fieldpasswordTwo.voidsetRedirectUrl(String redirectUrl) Setter for the fieldredirectUrl.voidsetTranskribusPassword(String transkribusPassword) Setter for the fieldtranskribusPassword.voidsetTranskribusUserName(String transkribusUserName) Setter for the fieldtranskribusUserName.voidSetter for the fielduser.booleanshowAuthenticationProviderSelection.transkribusLoginAction.voidupdateSessionTimeoutCounter.booleanuserEquals(long id) userEquals.
-
Constructor Details
-
UserBean
public UserBean()Empty constructor.
-
-
Method Details
-
updateSessionTimeoutCounter
public void updateSessionTimeoutCounter()updateSessionTimeoutCounter. -
getSessionTimeout
getSessionTimeout.- Returns:
- the remaining session timeout formatted as an ISO time string
-
createNewUserAccount
Creates and persists a new local User.- Returns:
- an empty string after attempting to register the new user account
- Throws:
DAOException- if any.
-
activateUserAccountAction
activateUserAccountAction.- Returns:
- the navigation outcome after attempting to activate the user account via email and key
- Throws:
DAOException- if any.
-
login
public String login() throws AuthenticationProviderException, IllegalStateException, InterruptedException, ExecutionExceptionLogin action method for local accounts.- Returns:
- the url mapping to navigate to
- Throws:
AuthenticationProviderException- if any.IllegalStateException- if any.InterruptedException- if any.ExecutionException- if any.
-
login
public String login(IAuthenticationProvider provider) throws AuthenticationProviderException, IllegalStateException, InterruptedException, ExecutionException login.- Parameters:
provider- authentication provider to use for the login attempt- Returns:
- the navigation outcome or redirect URL after the login attempt
- Throws:
IllegalStateException- if any.AuthenticationProviderException- if any.InterruptedException- if any.ExecutionException- if any.
-
logout
Logout action method.- Returns:
- an empty string after logging out the current user and invalidating the session
- Throws:
AuthenticationProviderException- if any.IOException
-
getAllUsers
Returns a list of all existing users (minus the superusers and the current user).- Returns:
- a list of all non-superuser users excluding the currently logged-in user
- Throws:
DAOException- if any.
-
sendPasswordResetLinkAction
Sends a password reset link to the current e-mail address.- Returns:
- the navigation outcome after attempting to send the password reset email
- Throws:
DAOException- if any.
-
resetPasswordAction
Generates a new user password if the key is correct.- Returns:
- the navigation outcome after attempting to reset the password via the activation key
- Throws:
DAOException- if any.
-
transkribusLoginAction
transkribusLoginAction.- Returns:
- an empty string after attempting to authenticate with Transkribus
-
getUser
Getter for the fielduser.- Returns:
- the currently authenticated user, or null if no user is logged in
-
setUser
Setter for the fielduser.- Parameters:
user- the currently authenticated user to set
-
getNickName
Getter for the fieldnickName.- Returns:
- the nickname entered during registration or profile editing
-
setNickName
Setter for the fieldnickName.- Parameters:
nickName- the desired nickname for the user account
-
getEmail
Getter for the fieldemail.- Returns:
- the email address entered for login or registration
-
setEmail
Setter for the fieldemail.- Parameters:
email- the email address for login or registration
-
getPassword
Getter for the fieldpassword.- Returns:
- the plain-text password entered by the user for login or registration
-
setPassword
Setter for the fieldpassword.- Parameters:
password- the plain-text password entered by the user for login or registration
-
isLoggedIn
public boolean isLoggedIn()isLoggedIn.- Returns:
- true if a user is currently logged in and their account is active and not suspended, false otherwise
-
isAdmin
public boolean isAdmin()isAdmin.- Returns:
- true if the currently logged-in user is a superuser (administrator), false otherwise
-
isUserRegistrationEnabled
public boolean isUserRegistrationEnabled()isUserRegistrationEnabled.- Returns:
- true if self-registration for new users is enabled in the configuration, false otherwise
-
isShowOpenId
public boolean isShowOpenId()isShowOpenId.- Returns:
- true if OpenID Connect authentication options should be shown in the UI, false otherwise
-
isCloseTabAfterLogin
public boolean isCloseTabAfterLogin() -
getAuthenticationProviders
Getter for the fieldauthenticationProviders.- Returns:
- a list of all configured authentication providers
-
getLocalAuthenticationProvider
getLocalAuthenticationProvider.- Returns:
- the first configured local authentication provider, or null if none is configured
-
getXserviceAuthenticationProvider
getXserviceAuthenticationProvider.- Returns:
- the first configured userPassword-type authentication provider, or null if none is configured
-
showAuthenticationProviderSelection
public boolean showAuthenticationProviderSelection()showAuthenticationProviderSelection.- Returns:
- true if more than one local or username/password authentication provider is configured, false otherwise
-
setAuthenticationProvider
Setter for the fieldauthenticationProvider.- Parameters:
provider- authentication provider to set as the active one
-
getAuthenticationProvider
Getter for the fieldauthenticationProvider.- Returns:
- the currently active authentication provider
-
setAuthenticationProviderName
setAuthenticationProviderName.- Parameters:
name- name used to look up the matching authentication provider
-
getAuthenticationProviderName
getAuthenticationProviderName.- Returns:
- the name of the currently selected authentication provider, or an empty string if none is selected
-
getPasswordOne
Getter for the fieldpasswordOne.- Returns:
- the first password entry for new account creation or password change
-
setPasswordOne
Setter for the fieldpasswordOne.- Parameters:
passwordOne- first password entry for new account creation
-
getPasswordTwo
Getter for the fieldpasswordTwo.- Returns:
- the confirmation password entry for new account creation or password change
-
setPasswordTwo
Setter for the fieldpasswordTwo.- Parameters:
passwordTwo- confirmation password entry for new account creation
-
resetPasswordFields
public void resetPasswordFields()resetPasswordFields. -
getLastName
Getter for the fieldlastName.- Returns:
- the last name of the user
-
setLastName
Setter for the fieldlastName.- Parameters:
lastName- the last name of the user
-
getRedirectUrl
Getter for the fieldredirectUrl.- Returns:
- the URL to redirect to after a successful login, or null if the default redirect applies
-
setRedirectUrl
Setter for the fieldredirectUrl.- Parameters:
redirectUrl- the URL to redirect to after a successful login, or null to use the default
-
getOrigin
-
setOrigin
-
getActivationKey
Getter for the fieldactivationKey.- Returns:
- the account activation key sent to the user by email
-
setActivationKey
Setter for the fieldactivationKey.- Parameters:
activationKey- the account activation key sent to the user by email
-
getTranskribusUserName
Getter for the fieldtranskribusUserName.- Returns:
- the Transkribus account username for the linked integration
-
setTranskribusUserName
Setter for the fieldtranskribusUserName.- Parameters:
transkribusUserName- the Transkribus account username for the linked integration
-
getTranskribusPassword
Getter for the fieldtranskribusPassword.- Returns:
- the Transkribus account password for the linked integration
-
setTranskribusPassword
Setter for the fieldtranskribusPassword.- Parameters:
transkribusPassword- the Transkribus account password for the linked integration
-
getHasAdminBackendAccess
public Boolean getHasAdminBackendAccess() throws PresentationException, IndexUnreachableException, DAOExceptionChecks whether the logged in user has access to the admin backend via being an admin or having CMS/campaign/comments access. Result is persisted for the duration of the session.- Returns:
- true if the current user has access to the admin backend, false otherwise
- Throws:
DAOExceptionIndexUnreachableExceptionPresentationException
-
setHasAdminBackendAccess
Setter for the fieldhasAdminBackendAccess.- Parameters:
hasAdminBackendAccess- true if the current user has access to the admin backend; false otherwise
-
userEquals
public boolean userEquals(long id) userEquals.- Parameters:
id- database ID to compare against the current user- Returns:
- true if the given database ID matches the ID of the currently logged-in user, false otherwise
-
hasProvidersOfType
hasProvidersOfType.- Parameters:
type- provider type string to match (e.g. "local", "openId")- Returns:
- true if at least one configured authentication provider matches the given type, false otherwise
-
getProvidersOfType
getProvidersOfType.- Parameters:
type- provider type string to filter by (e.g. "local", "openId")- Returns:
- a list of authentication providers of the given type
-
getNumberOfProviderTypes
public int getNumberOfProviderTypes()getNumberOfProviderTypes.- Returns:
- a int.
-
isAllowPasswordChange
public boolean isAllowPasswordChange()isAllowPasswordChange.- Returns:
- true if the currently used authentication provider allows the user to change their password, false otherwise
-
isAllowNickNameChange
public boolean isAllowNickNameChange()isAllowNickNameChange.- Returns:
- true if the currently used authentication provider allows the user to change their nickname, false otherwise
-
isAllowEmailChange
public boolean isAllowEmailChange()isAllowEmailChange.- Returns:
- true if the currently used authentication provider allows the user to change their email address, false otherwise
-
isRequireLoginCaptcha
public boolean isRequireLoginCaptcha()isRequireLoginCaptcha.- Returns:
- true if a CAPTCHA is required for the login form, false otherwise
-
mustAgreeToTermsOfUse
public boolean mustAgreeToTermsOfUse()Checks if the current user is required to agree to the terms of use.- Returns:
- true if a user is logged in and
User.isAgreedToTermsOfUse()returns false for this user
-
agreeToTermsOfUse
agreeToTermsOfUse.- Throws:
DAOException- if any.
-
rejectTermsOfUse
rejectTermsOfUse.- Throws:
DAOException- if any.
-
logoutWithMessage
public void logoutWithMessage(String messageKey) throws AuthenticationProviderException, IOException logoutWithMessage.- Parameters:
messageKey- i18n key for the info message shown after logout- Throws:
AuthenticationProviderException- if any.IOException
-
createBackupOfCurrentUser
public void createBackupOfCurrentUser()createBackupOfCurrentUser.
-