| java.lang.Object net.myvietnam.mvncore.security.FloodControl
FloodControl | public class FloodControl (Code) | | This class is used to control the number of actions per hour. This is usually
used to prevent the flood of any action. You should call FloodControl.setOption()
when your application is inited.
Note that the action id from 0 to 999 is belong to mvnCore, application used it
should not use the value in this range
|
MAX_MVNCORE_ACTION_ID | public static int MAX_MVNCORE_ACTION_ID(Code) | | The value from 0 to 999 should belong to mvnCore
|
REMOVE_INTERVAL | final static long REMOVE_INTERVAL(Code) | | |
ensureNotReachMaximum | public static void ensureNotReachMaximum(Integer action, String strIP) throws FloodException(Code) | | This is a utility method to ensure that the action has not reached the mamximum.
It calls the method reachMaximum and throw an exception if it reached the maximum.
A program could use this method to use the default error message, otherwise
it has to use reachMaximum
Parameters: action - Integer the action to ensure Parameters: strIP - String the IP to ensure throws: FloodException - if it reached the maximum See Also: FloodControl.reachMaximum(IntegerString) |
getActionsPerHour | public static int getActionsPerHour(Integer action)(Code) | | |
increaseCount | public static void increaseCount(Integer action, String strIP)(Code) | | Increase the number of action. This method should be called the the program
has done this action. Forget to call this method will void the reachMaximum method.
Parameters: action - Integer the action to increase the number of times Parameters: strIP - String the IP to increase the number of times |
reachMaximum | public static boolean reachMaximum(Integer action, String strIP)(Code) | | Check that an action of an IP has reach the maximum number of allowed times
Parameters: action - Integer the action to check Parameters: strIP - String the IP to check boolean true if it has reached the maximum |
resetActionHistory | public static void resetActionHistory(Integer action, String strIP)(Code) | | Reset the action history. This method is useful in such a case in the login
process that after login successfully, the value should be reset. Please note
that this is just an example and usually no need to use this method.
Parameters: action - Integer Parameters: strIP - String |
setOption | public static void setOption(Integer action, int actionsPerHour)(Code) | | To set the mamximum number of actions per hour for an action.
If the caller does not call this method, the the action has no limit
Parameters: action - Integer the action that want to set the option Parameters: actionsPerHour - int the maximum number of actions per hour |
|
|