View Javadoc

1   /*
2    * JCaptcha, the open source java framework for captcha definition and integration
3    * Copyright (c)  2007 jcaptcha.net. All Rights Reserved.
4    * See the LICENSE.txt file distributed with this package.
5    */
6   
7   package com.octo.captcha.service;
8   
9   import com.octo.captcha.Captcha;
10  import com.octo.captcha.engine.CaptchaEngine;
11  import com.octo.captcha.engine.MockCaptchaEngine;
12  import com.octo.captcha.service.captchastore.CaptchaStore;
13  import com.octo.captcha.service.captchastore.MapCaptchaStore;
14  
15  /***
16   * <p><ul><li></li></ul></p>
17   *
18   * @author <a href="mailto:mag@jcaptcha.net">Marc-Antoine Garrigue</a>
19   * @version 1.0
20   */
21  public class MockedCaptchaService extends AbstractCaptchaService {
22      public static final String CLONE_CHALLENGE = "clonedChallenge";
23  
24      public MockedCaptchaService() {
25          super(new MapCaptchaStore(), new MockCaptchaEngine());
26      }
27  
28      protected MockedCaptchaService(CaptchaStore captchaStore, CaptchaEngine captchaEngine) {
29          super(captchaStore, captchaEngine);
30      }
31  
32      /***
33       * This method must be implemented by sublcasses and : Retrieve the challenge from the captcha Make and return a
34       * clone of the challenge Return the clone It has be design in order to let the service dipose the challenge of the
35       * captcha after rendering. It should be implemented for all captcha type (@see ImageCaptchaService implementations
36       * for exemple)
37       *
38       * @return a Challenge Clone
39       */
40      protected Object getChallengeClone(Captcha captcha) {
41          return new String(captcha.getChallenge().toString()) + CLONE_CHALLENGE;
42      }
43  
44  
45  }