| 
 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.opencms.db.CmsLoginManager
public class CmsLoginManager
Provides functions used to check the validity of a user login.
Stores invalid login attempts and disables a user account temporarily in case the configured threshold of invalid logins is reached.
The invalid login attempt storage operates on a combination of user name, login remote IP address and user type. This means that a user can be disabled for one remote IP, but still be enabled for another remote IP.
Also allows to temporarily disallow logins (for example in case of maintenance work on the system).
| Field Summary | |
|---|---|
| static int | DISABLE_MINUTES_DEFAULTDefault lock time if treshold for bad login attempts is reached. | 
| static boolean | ENABLE_SECURITY_DEFAULTDefault setting for the security option. | 
| protected  int | m_disableMillisThe milliseconds to disable an account if the threshold is reached. | 
| protected  int | m_disableMinutesThe minutes to disable an account if the threshold is reached. | 
| protected  boolean | m_enableSecurityThe flag to determine if the security option ahould be enabled on the login dialog. | 
| protected  int | m_maxBadAttemptsThe number of bad login attempts allowed before an account is temporarily disabled. | 
| protected  Map<String,org.opencms.db.CmsLoginManager.CmsUserData> | m_storageThe storage for the bad login attempts. | 
| static int | MAX_BAD_ATTEMPTS_DEFAULTDefault for bad login attempts. | 
| Constructor Summary | |
|---|---|
| CmsLoginManager(int disableMinutes,
                int maxBadAttempts,
                boolean enableSecurity)Creates a new storage for invalid logins. | |
| Method Summary | |
|---|---|
| protected  void | addInvalidLogin(String userName,
                String remoteAddress)Adds an invalid attempt to login for the given user / IP to the storage. | 
|  void | checkInvalidLogins(String userName,
                   String remoteAddress)Checks if the threshold for the invalid logins has been reached for the given user. | 
|  void | checkLoginAllowed()Checks if a login is currently allowed. | 
|  int | getDisableMinutes()Returns the minutes an account gets disabled after too many failed login attempts. | 
|  CmsLoginMessage | getLoginMessage()Returns the current login message that is displayed if a user logs in. | 
|  int | getMaxBadAttempts()Returns the number of bad login attempts allowed before an account is temporarily disabled. | 
|  boolean | isEnableSecurity()Returns if the security option ahould be enabled on the login dialog. | 
| protected  void | removeInvalidLogins(String userName,
                    String remoteAddress)Removes all invalid attempts to login for the given user / IP. | 
|  void | removeLoginMessage(CmsObject cms)Removes the current login message. | 
|  void | setLoginMessage(CmsObject cms,
                CmsLoginMessage message)Sets the login message to display if a user logs in. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final int DISABLE_MINUTES_DEFAULT
public static final boolean ENABLE_SECURITY_DEFAULT
public static final int MAX_BAD_ATTEMPTS_DEFAULT
protected int m_disableMillis
protected int m_disableMinutes
protected boolean m_enableSecurity
protected int m_maxBadAttempts
protected Map<String,org.opencms.db.CmsLoginManager.CmsUserData> m_storage
| Constructor Detail | 
|---|
public CmsLoginManager(int disableMinutes,
                       int maxBadAttempts,
                       boolean enableSecurity)
disableMinutes - the minutes to disable an account if the threshold is reachedmaxBadAttempts - the number of bad login attempts allowed before an account is temporarily disabledenableSecurity - flag to determine if the security option should be enabled on the login dialog| Method Detail | 
|---|
public void checkInvalidLogins(String userName,
                               String remoteAddress)
                        throws CmsAuthentificationException
In case the configured threshold is reached, an Exception is thrown.
userName - the name of the userremoteAddress - the remote address (IP) from which the login attempt was made
CmsAuthentificationException - in case the threshold of invalid login attempts has been reached
public void checkLoginAllowed()
                       throws CmsAuthentificationException
In case no logins are allowed, an Exception is thrown.
CmsAuthentificationException - in case no logins are allowedpublic int getDisableMinutes()
public boolean isEnableSecurity()
true if the security option ahould be enabled on the login dialog, otherwise falsepublic CmsLoginMessage getLoginMessage()
 
 if null is returned, no login message has been currently set.
public int getMaxBadAttempts()
public void removeLoginMessage(CmsObject cms)
                        throws CmsRoleViolationException
 
 This operation requires that the current user has role permissions of CmsRole.ROOT_ADMIN
cms - the current OpenCms user context
CmsRoleViolationException - in case the current user does not have the required role permissions
public void setLoginMessage(CmsObject cms,
                            CmsLoginMessage message)
                     throws CmsRoleViolationException
 
 This operation requires that the current user has role permissions of CmsRole.ROOT_ADMIN
cms - the current OpenCms user contextmessage - the message to set
CmsRoleViolationException - in case the current user does not have the required role permissions
protected void addInvalidLogin(String userName,
                               String remoteAddress)
In case the configured threshold is reached, the user is disabled for the configured time.
userName - the name of the userremoteAddress - the remore address (IP) from which the login attempt was made
protected void removeInvalidLogins(String userName,
                                   String remoteAddress)
userName - the name of the userremoteAddress - the remore address (IP) from which the login attempt was made| 
 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||