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 thresold is greater than millis since last captcha test has occured;<br>
20 * Default keyword : REQUIRES_CAPTCHA_AFTER_THRESOLD_IN_MILLIS
21 * </p>
22 *
23 * @author Marc-Antoine Garrigue
24 * @version $Id: AlwaysTestAfterTimeInMillisCaptchaChannelProcessor.java,v 1.2 2005/11/17 00:55:49 benalex Exp $
25 */
26 public class AlwaysTestAfterTimeInMillisCaptchaChannelProcessor
27 extends CaptchaChannelProcessorTemplate {
28
29
30 /*** Keyword for this channelProcessor */
31 public static final String DEFAULT_KEYWORD = "REQUIRES_CAPTCHA_AFTER_THRESOLD_IN_MILLIS";
32
33
34
35 /***
36 * Constructor
37 */
38 public AlwaysTestAfterTimeInMillisCaptchaChannelProcessor() {
39 super();
40 this.setKeyword(DEFAULT_KEYWORD);
41 }
42
43
44
45 /***
46 * Verify wheter the context is valid concerning humanity
47 *
48 * @param context the CaptchaSecurityContext
49 *
50 * @return true if valid, false otherwise
51 */
52 boolean isContextValidConcerningHumanity(CaptchaSecurityContext context) {
53 if ((System.currentTimeMillis()
54 - context.getLastPassedCaptchaDateInMillis()) < getThresold()) {
55 logger.debug(
56 "context is valid : last passed captcha date - current time < thresold");
57
58 return true;
59 } else {
60 logger.debug(
61 "context is not valid : last passed captcha date - current time > thresold");
62
63 return false;
64 }
65 }
66 }