public class AccountBlocker extends AbstractXmlElement implements CleanupThread.Cleaner
The Account Blocker prevents password and token guessing attempts: It blocks a user (or the whole system) after too many failed login attempts.
When a user entered a wrong password or wrong token more than afterFailedLogins times, this user becomes blocked: He will be prevented from logging in again within the next blockFor milliseconds (writing 3600000 means "for 1 hour").
The failed login attempts have to occur within the last afterFailedLoginsWithin milliseconds (writing 9223372036854775807 means "forever").
If more than blockWholeSystemAfter users become blocked at a time, the all users will become blocked. (This is necessary to limit memory usage.)
Say, for example, a scripted dictionary attack tries to guess a user's password. Using the configuration shown above, which is the default configuration if no accountBlocker is declared, this results in 5 guesses per 3600000 milliseconds; or equivalently 42720 guesses per year.
The probability of hitting a uniformly at random chosen word of the standard German vocabulary within one year is therefore about 56%.
Therefore, a more secure password should be chosen, containing letters, digits and special characters.
| Constructor and Description |
|---|
AccountBlocker() |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanup() |
boolean |
fail(String username) |
int |
getAfterFailedLogins() |
long |
getAfterFailedLoginsWithin() |
long |
getBlockFor() |
int |
getBlockWholeSystemAfter() |
boolean |
isBlocked(String username) |
protected void |
parseAttributes(XMLStreamReader token) |
void |
setAfterFailedLogins(int afterFailedLogins) |
void |
setAfterFailedLoginsWithin(long afterFailedLoginsWithin) |
void |
setBlockFor(long blockFor) |
void |
setBlockWholeSystemAfter(int blockWholeSystemAfter) |
void |
unblock(String username) |
doAfterParsing, getBoolean, getElementName, move2RootElementIfNeeded, parse, parseCharacters, parseChildren, toXml, write, writeIfNotNullprotected void parseAttributes(XMLStreamReader token) throws Exception
parseAttributes in class AbstractXmlElementExceptionpublic boolean isBlocked(String username)
public void unblock(String username)
public boolean fail(String username)
public void cleanup()
cleanup in interface CleanupThread.Cleanerpublic int getBlockWholeSystemAfter()
public void setBlockWholeSystemAfter(int blockWholeSystemAfter)
public int getAfterFailedLogins()
public void setAfterFailedLogins(int afterFailedLogins)
public long getAfterFailedLoginsWithin()
public void setAfterFailedLoginsWithin(long afterFailedLoginsWithin)
public long getBlockFor()
public void setBlockFor(long blockFor)
Copyright © 2022. All Rights Reserved.