Package org.opencms.jsp
Class CmsJspLoginBean
java.lang.Object
org.opencms.jsp.CmsJspBean
org.opencms.jsp.CmsJspActionElement
org.opencms.jsp.CmsJspLoginBean
- Direct Known Subclasses:
CmsJspLoginPersistingBean
,CmsLoginHelper
Provides convenient wrappers useful to create user login pages.
Initialize this bean at the beginning of your JSP like this:
<jsp:useBean id="cmslogin" class="org.opencms.jsp.CmsJspLoginBean"> <% cmslogin.init(pageContext, request, response); %> </jsp:useBean>
- Since:
- 6.0.0
-
Field Summary
Fields inherited from class org.opencms.jsp.CmsJspActionElement
NOT_INITIALIZED
-
Constructor Summary
ConstructorDescriptionEmpty constructor, required for every JavaBean.CmsJspLoginBean
(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Constructor, with parameters. -
Method Summary
Modifier and TypeMethodDescriptionReturns the link to the form that contains the login element.Returns the exception that was thrown after login, or null if no Exception was thrown (i.e.getUser()
Returns the currently logged in user.Returns the user name of the currently logged in user.boolean
Returns true if the current user is not the guest user, i.e.boolean
Indicates if a login was successful or not.void
Logs a system user in to OpenCms.void
Logs a system user into OpenCms.void
Logs a system user in to OpenCms.static void
logLoginException
(CmsRequestContext requestContext, String userName, CmsException currentLoginException) Logs any login exception.void
logout()
Logs a user out, i.e.void
setVerificationCode
(String code) Sets the verification code for two-factor authentication.Methods inherited from class org.opencms.jsp.CmsJspActionElement
editable, editable, editable, editableManualClose, editableManualOpen, getContent, getContent, getMessages, getMessages, getMessages, getMessages, getNavigation, getNavigationUri, img, img, include, include, include, include, include, include, includeSilent, includeSilent, includeSilent, includeSilent, info, label, link, link, properties, properties, property, property, property, property, template, template, template, toAbsolute, user
Methods inherited from class org.opencms.jsp.CmsJspBean
getCmsObject, getController, getJspContext, getMessage, getRequest, getRequestContext, getResponse, handleException, handleMissingFlexController, init, isNotInitialized, isSupressingExceptions, setContentType, setStatus, setSupressingExceptions
-
Constructor Details
-
CmsJspLoginBean
public CmsJspLoginBean()Empty constructor, required for every JavaBean. -
CmsJspLoginBean
public CmsJspLoginBean(javax.servlet.jsp.PageContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) Constructor, with parameters.- Parameters:
context
- the JSP page context objectreq
- the JSP requestres
- the JSP response
-
-
Method Details
-
logLoginException
public static void logLoginException(CmsRequestContext requestContext, String userName, CmsException currentLoginException) Logs any login exception.- Parameters:
requestContext
- the request contextuserName
- the user namecurrentLoginException
- the exception to log
-
getFormLink
Returns the link to the form that contains the login element.- Returns:
- the link to the form that contains the login element
-
getLoginException
Returns the exception that was thrown after login, or null if no Exception was thrown (i.e. login was successful or not attempted).- Returns:
- the exception thrown after login
-
getUser
Returns the currently logged in user.- Returns:
- the currently logged in user
-
getUserName
Returns the user name of the currently logged in user.- Returns:
- the user name of the currently logged in user
-
isLoggedIn
Returns true if the current user is not the guest user, i.e. if he already has logged in with some other user account.- Returns:
- true if the current user is already logged in
-
isLoginSuccess
Indicates if a login was successful or not.- Returns:
- true if the login was successful
-
login
Logs a system user in to OpenCms.- Parameters:
userName
- the users namepassword
- the password
-
login
Logs a system user into OpenCms.Note that if a login project name is provided, this project must exist, otherwise the login is regarded as a failure even if the user data was correct.
- Parameters:
userName
- the users namepassword
- the passwordprojectName
- the project to switch to after login (if null project is not switched)
-
login
public void login(String userName, String password, String projectName, String redirectUri) throws IOException Logs a system user in to OpenCms.Note that if a login project name is provided, this project must exist, otherwise the login is regarded as a failure even if the user data was correct.
- Parameters:
userName
- the users namepassword
- the passwordprojectName
- the project to switch to after login (if null project is not switched)redirectUri
- the URI to redirect to after login (if null the current URI is used)- Throws:
IOException
- in case redirect after login was not successful
-
logout
Logs a user out, i.e. destroys the current users session, after that the current page will be redirected to itself one time to ensure that the users session is truly destroyed.- Throws:
IOException
- if redirect after logout fails
-
setVerificationCode
Sets the verification code for two-factor authentication.- Parameters:
code
- the verification code
-