Package org.opencms.ui.login
Class CmsLoginController
- java.lang.Object
-
- org.opencms.ui.login.CmsLoginController
-
public class CmsLoginController extends java.lang.Object
Controller class which actually handles the login dialog logic.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmsLoginController.CmsLoginTargetInfo
Represents the login target information.static class
CmsLoginController.LoginContext
The login context.protected static class
CmsLoginController.UserAgreementHelper
Helper subclass of CmsLoginUserAgreement which can be used without a page context.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
KEY_ACCOUNT_LOCKED
Additional info key to mark accounts as locked due to inactivity.protected CmsTwoFactorAuthenticationHandler
m_otpHandler
The two-factor authentication handler.
-
Constructor Summary
Constructors Constructor Description CmsLoginController(CmsObject adminCms, CmsLoginHelper.LoginParameters params)
Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getFormLink(CmsObject cms)
Returns the link to the login form.static java.lang.String
getLoginTarget(CmsObject currentCms, CmsWorkplaceSettings settings, java.lang.String requestedResource)
Gets the login target link.protected java.lang.String
getPasswordChangeMessage()
Returns the message to be displayed for the user data check dialog.java.lang.String
getPcType()
Gets the PC type.java.lang.String
getResetPasswordLink()
Returns the reset password link.protected void
handleError(CmsObject currentCms, java.lang.String user, java.lang.Exception e)
Handles exceptions during the login process and displays appropriate error messages.protected void
initSessionAndSendMessages(CmsObject currentCms, CmsObject loginCms)
Switches the session to a new one with the logged in CmsObject.boolean
isShowSecure()
Returns true if the security option should be displayed in the login dialog.static void
logout()
Logs the current user out by invalidating the session an reloading the current URI.static void
logout(CmsObject cms, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Logs out the current user redirecting to the login form afterwards.void
onClickForgotPassword()
Called when the user clicks on the 'forgot password' button.void
onClickLogin()
Called when the user clicks on the login button.void
onInit()
Called on initialization.void
setUi(CmsLoginUI ui)
Sets the login ui reference.
-
-
-
Field Detail
-
KEY_ACCOUNT_LOCKED
public static final java.lang.String KEY_ACCOUNT_LOCKED
Additional info key to mark accounts as locked due to inactivity.- See Also:
- Constant Field Values
-
m_otpHandler
protected CmsTwoFactorAuthenticationHandler m_otpHandler
The two-factor authentication handler.
-
-
Constructor Detail
-
CmsLoginController
public CmsLoginController(CmsObject adminCms, CmsLoginHelper.LoginParameters params)
Creates a new instance.- Parameters:
adminCms
- the admin cms contextparams
- the parameters for the UI
-
-
Method Detail
-
getFormLink
public static java.lang.String getFormLink(CmsObject cms)
Returns the link to the login form.- Parameters:
cms
- the current cms context- Returns:
- the login form link
-
getLoginTarget
public static java.lang.String getLoginTarget(CmsObject currentCms, CmsWorkplaceSettings settings, java.lang.String requestedResource) throws CmsException
Gets the login target link.- Parameters:
currentCms
- the current CMS contextsettings
- the workplace settingsrequestedResource
- the requested resource parameter- Returns:
- the login target
- Throws:
CmsException
- in case the user has insufficient permissions to access the login target
-
logout
public static void logout()
Logs the current user out by invalidating the session an reloading the current URI.Important: This works only within vaadin apps.
-
logout
public static void logout(CmsObject cms, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
Logs out the current user redirecting to the login form afterwards.- Parameters:
cms
- the cms contextrequest
- the servlet requestresponse
- the servlet response- Throws:
java.io.IOException
- if writing to the response fails
-
getPcType
public java.lang.String getPcType()
Gets the PC type.- Returns:
- the PC type
-
getResetPasswordLink
public java.lang.String getResetPasswordLink()
Returns the reset password link.- Returns:
- the reset password link
-
isShowSecure
public boolean isShowSecure()
Returns true if the security option should be displayed in the login dialog.- Returns:
- true if the security option should be displayed in the login dialog
-
onClickForgotPassword
public void onClickForgotPassword()
Called when the user clicks on the 'forgot password' button.
-
onClickLogin
public void onClickLogin()
Called when the user clicks on the login button.
-
onInit
public void onInit()
Called on initialization.
-
setUi
public void setUi(CmsLoginUI ui)
Sets the login ui reference.- Parameters:
ui
- the login ui
-
getPasswordChangeMessage
protected java.lang.String getPasswordChangeMessage()
Returns the message to be displayed for the user data check dialog.- Returns:
- the message to display
-
handleError
protected void handleError(CmsObject currentCms, java.lang.String user, java.lang.Exception e)
Handles exceptions during the login process and displays appropriate error messages.- Parameters:
currentCms
- the CMS contextuser
- the user being logged ine
- the error
-
initSessionAndSendMessages
protected void initSessionAndSendMessages(CmsObject currentCms, CmsObject loginCms)
Switches the session to a new one with the logged in CmsObject.This needs to be called in the last request to the Vaadin servlet in the login process, because switching the session breaks the Vaadin session state.
- Parameters:
currentCms
- the CmsObject for the current request from the Vaadin UIloginCms
- the CmsObject which was used for the actual login operation
-
-