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