Package sk.iway.iwcm

Class SpamProtection

java.lang.Object
sk.iway.iwcm.SpamProtection

public class SpamProtection extends Object
SpamProtection.java This class keeps a track of user's posts on our server and forbids any more posts, if he already reached a limit. Behaviour of this class can be modified by configuration parameters: 1. spamProtectionTimeout - what is the maximum time span between two distinct posts 2. spamProtectionHourlyLimit - limit of posts that a user can send in an hour
  • Field Details

  • Constructor Details

    • SpamProtection

      protected SpamProtection()
  • Method Details

    • clearOldData

      protected static void clearOldData()
    • canPost

      public static boolean canPost(String module, String post, javax.servlet.http.HttpServletRequest request)
      Determines, whether a post to a given module and from a given IP address is allowed to be posted.
      Parameters:
      module - Module, which is used to make a post
      post - Text version of a post - unused
      request -
      Returns:
      Boolean - whether the post can be performed or not
    • crossMinuteLimit

      public static long crossMinuteLimit(String module, javax.servlet.http.HttpServletRequest request)
      Kontrola počtu zápisov za minútu
      Parameters:
      module -
      request -
      Returns:
    • crossMinitLimit

      public static long crossMinitLimit(String module, javax.servlet.http.HttpServletRequest request)
      Momentalne kvoli ing insurance Systém CMS dovolí prepísať profil maximálne 3x za sebou v priebehu jednej minúty, v takom prípade povolí zápis až 5 minút od posledného zápisu
      Parameters:
      module -
      request -
      Returns:
    • getMinitPostLimit

      public static int getMinitPostLimit(String module)
    • getHourlyPostLimit

      public static int getHourlyPostLimit(String module)
    • getTimeout

      public static long getTimeout(String module)
    • getWaitTimeout

      public static long getWaitTimeout(String module, javax.servlet.http.HttpServletRequest request)
      Vracia cas do vyprsania obmedzenia !Pozor, neriesi rychle klikanie pouzivatela, len hodinovy Limit! Standardne, ak netreba ziskavat cas, staci volat metodu canPost(module, post, request)
    • fakeFirstPostTimeForTesting

      protected static void fakeFirstPostTimeForTesting(String module, String ip, long time)
    • getMinutePostLimit

      public static int getMinutePostLimit(String module)
    • destroy

      public static void destroy()
    • clearAll

      public static void clearAll()
      Clear all maps