|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.lang.Thread
com.jcorporate.expresso.core.security.DelayThread
Simple class called to suspend thread execution for x many seconds before offering a retry to login. Helps to slow down brute force attacks. [a 40,000 word dictionary attack prolonged by 3 seconds a piece adds potentially 33 hours to the attack time. Yes this can be partially bypassed through simultaneous requests, but it still adds significant reponse time]
Why this class instead of just sleep(3000) or whatever? The answer is that this thread is often called from multi-thread handling servers with only one instance. You can't just call sleep() without becoming the Monitor "Owner", but synchronized(this) will sleep the whole login object. Thus effective keeping all login processing happening. A definite DOS attack. Thus we sleep the requesting thread while waiting on this "lock object"What about people issuing bad requests in parallel? Simple! It all has to queue up for a lock on a single instance. Thus delay may be signicantly longer if lots of people are issuing bad requests. Thus creating an effective CPU choke point.
| Field Summary | |
protected Object |
lockObject
|
protected static DelayThread |
theInstance
|
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
DelayThread()
|
|
DelayThread(int numSeconds)
Create the object and when run, pause for x number of seconds. |
|
| Method Summary | |
static void |
delay()
Executed in the main thread. |
static void |
delay(int numSeconds)
Executed in the main thread. |
int |
getDelay()
return the current setting for number of seconds to delay |
static void |
kill()
Function interrupts the thread so that it exits. |
void |
run()
Execution path - simply pause for secondsDelay number of seconds. |
void |
setDelay(int numSeconds)
Sets the number of seconds to delay when run. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected static DelayThread theInstance
protected volatile Object lockObject
| Constructor Detail |
public DelayThread()
public DelayThread(int numSeconds)
numSeconds - the number of seconds to pause when this thread runs.| Method Detail |
public void setDelay(int numSeconds)
numSeconds - The number of seconds to run.public int getDelay()
public void run()
public static void delay()
public static void kill()
public static void delay(int numSeconds)
numSeconds - - The number of seconds to delay
|
Expresso 5-6 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||