/** * Removes all invalid attempts to login for the given user / IP.<p> * * @param userName the name of the user * @param remoteAddress the remore address (IP) from which the login attempt was made */ protected void removeInvalidLogins(String userName, String remoteAddress) { if (m_maxBadAttempts < 0) { // invalid login storage is disabled return; } String key = createStorageKey(userName, remoteAddress); // just remove the user from the storage m_storage.remove(key); }
/** * Removes all invalid attempts to login for the given user / IP.<p> * * @param userName the name of the user * @param remoteAddress the remore address (IP) from which the login attempt was made */ public void removeInvalidLogins(String userName, String remoteAddress) { if (m_maxBadAttempts < 0) { // invalid login storage is disabled return; } String key = createStorageKey(userName, remoteAddress); // just remove the user from the storage m_storage.remove(key); } }
/** * Adds an invalid attempt to login for the given user / IP to the storage.<p> * * In case the configured threshold is reached, the user is disabled for the configured time.<p> * * @param userName the name of the user * @param remoteAddress the remore address (IP) from which the login attempt was made */ protected void addInvalidLogin(String userName, String remoteAddress) { if (m_maxBadAttempts < 0) { // invalid login storage is disabled return; } String key = createStorageKey(userName, remoteAddress); // look up the user in the storage CmsUserData userData = m_storage.get(key); if (userData != null) { // user data already contained in storage userData.increaseInvalidLoginCount(); } else { // create an new data object for this user userData = new CmsUserData(); m_storage.put(key, userData); } }
/** * Adds an invalid attempt to login for the given user / IP to the storage.<p> * * In case the configured threshold is reached, the user is disabled for the configured time.<p> * * @param userName the name of the user * @param remoteAddress the remore address (IP) from which the login attempt was made */ protected void addInvalidLogin(String userName, String remoteAddress) { if (m_maxBadAttempts < 0) { // invalid login storage is disabled return; } String key = createStorageKey(userName, remoteAddress); // look up the user in the storage CmsUserData userData = (CmsUserData)m_storage.get(key); if (userData != null) { // user data already contained in storage userData.increaseInvalidLoginCount(); } else { // create an new data object for this user userData = new CmsUserData(); m_storage.put(key, userData); } }
/** * Checks if the threshold for the invalid logins has been reached for the given user.<p> * * In case the configured threshold is reached, an Exception is thrown.<p> * * @param userName the name of the user * @param remoteAddress the remote address (IP) from which the login attempt was made * * @throws CmsAuthentificationException in case the threshold of invalid login attempts has been reached */ public void checkInvalidLogins(String userName, String remoteAddress) throws CmsAuthentificationException { if (m_maxBadAttempts < 0) { // invalid login storage is disabled return; } String key = createStorageKey(userName, remoteAddress); // look up the user in the storage CmsUserData userData = (CmsUserData)m_storage.get(key); if ((userData != null) && (userData.isDisabled())) { // threshold of invalid logins is reached throw new CmsUserDisabledException(Messages.get().container( Messages.ERR_LOGIN_FAILED_TEMP_DISABLED_4, new Object[] {userName, remoteAddress, userData.getReleaseDate(), userData.getInvalidLoginCount()})); } }
/** * Checks if the threshold for the invalid logins has been reached for the given user.<p> * * In case the configured threshold is reached, an Exception is thrown.<p> * * @param userName the name of the user * @param remoteAddress the remote address (IP) from which the login attempt was made * * @throws CmsAuthentificationException in case the threshold of invalid login attempts has been reached */ public void checkInvalidLogins(String userName, String remoteAddress) throws CmsAuthentificationException { if (m_maxBadAttempts < 0) { // invalid login storage is disabled return; } String key = createStorageKey(userName, remoteAddress); // look up the user in the storage CmsUserData userData = m_storage.get(key); if ((userData != null) && (userData.isDisabled())) { // threshold of invalid logins is reached throw new CmsUserDisabledException( Messages.get().container( Messages.ERR_LOGIN_FAILED_TEMP_DISABLED_4, new Object[] { userName, remoteAddress, userData.getReleaseDate(), userData.getInvalidLoginCount()})); } }