1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.acegisecurity.captcha;
20
21 /***
22 * <p>
23 * return false if ny CaptchaChannelProcessorTemplate of mapped urls has been
24 * requested more than thresold; <br>
25 * Default keyword : REQUIRES_CAPTCHA_ABOVE_THRESOLD_REQUESTS
26 * </p>
27 *
28 * @author Marc-Antoine Garrigue
29 * @version $Id: AlwaysTestAfterMaxRequestsCaptchaChannelProcessor.java,v 1.2 2005/11/17 00:55:49 benalex Exp $
30 */
31 public class AlwaysTestAfterMaxRequestsCaptchaChannelProcessor
32 extends CaptchaChannelProcessorTemplate {
33
34
35 /*** Keyword for this channelProcessor */
36 public static final String DEFAULT_KEYWORD = "REQUIRES_CAPTCHA_ABOVE_THRESOLD_REQUESTS";
37
38
39
40 /***
41 * Constructor
42 */
43 public AlwaysTestAfterMaxRequestsCaptchaChannelProcessor() {
44 super();
45 this.setKeyword(DEFAULT_KEYWORD);
46 }
47
48
49
50 /***
51 * Verify wheter the context is valid concerning humanity
52 *
53 * @param context
54 *
55 * @return true if valid, false otherwise
56 */
57 boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) {
58 if (context.getHumanRestrictedResourcesRequestsCount() < getThresold()) {
59 logger.debug("context is valid : request count < thresold");
60
61 return true;
62 } else {
63 logger.debug("context is not valid : request count > thresold");
64
65 return false;
66 }
67 }
68 }