01: /*
02: * File : $Source: /usr/local/cvs/alkacon/com.alkacon.opencms.formgenerator/src/com/alkacon/opencms/formgenerator/CmsCaptchaService.java,v $
03: * Date : $Date: 2007-12-21 14:34:00 $
04: * Version: $Revision: 1.1 $
05: *
06: * This file is part of the Alkacon OpenCms Add-On Module Package
07: *
08: * Copyright (c) 2007 Alkacon Software GmbH (http://www.alkacon.com)
09: *
10: * The Alkacon OpenCms Add-On Module Package is free software:
11: * you can redistribute it and/or modify
12: * it under the terms of the GNU General Public License as published by
13: * the Free Software Foundation, either version 3 of the License, or
14: * (at your option) any later version.
15: *
16: * The Alkacon OpenCms Add-On Module Package is distributed
17: * in the hope that it will be useful,
18: * but WITHOUT ANY WARRANTY; without even the implied warranty of
19: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20: * GNU General Public License for more details.
21: *
22: * You should have received a copy of the GNU General Public License
23: * along with the Alkacon OpenCms Add-On Module Package.
24: * If not, see http://www.gnu.org/licenses/.
25: *
26: * For further information about Alkacon Software GmbH, please see the
27: * company website: http://www.alkacon.com.
28: *
29: * For further information about OpenCms, please see the
30: * project website: http://www.opencms.org.
31: */
32: package com.alkacon.opencms.formgenerator;
33:
34: import com.octo.captcha.service.captchastore.MapCaptchaStore;
35: import com.octo.captcha.service.image.AbstractManageableImageCaptchaService;
36: import com.octo.captcha.service.image.ImageCaptchaService;
37:
38: /**
39: * Provides the facility to create and cache the captcha images.
40: * <p>
41: *
42: * @author Thomas Weckert
43: *
44: * @author Achim Westermann
45: *
46: * @version $Revision: 1.1 $
47: *
48: * @since 7.0.4
49: */
50: public class CmsCaptchaService extends
51: AbstractManageableImageCaptchaService implements
52: ImageCaptchaService {
53:
54: /**
55: * Creates a new captcha service.
56: * <p>
57: *
58: * The following settings are used:
59: * <pre>
60: * minGuarantedStorageDelayInSeconds = 180s
61: * maxCaptchaStoreSize = 100000
62: * captchaStoreLoadBeforeGarbageCollection = 75000
63: * </pre>
64: * <p>
65: *
66: * @param captchaSettings the settings to render captcha images
67: */
68: public CmsCaptchaService(CmsCaptchaSettings captchaSettings) {
69:
70: super (new MapCaptchaStore(), new CmsCaptchaEngine(
71: captchaSettings), 180, 100000, 75000);
72: }
73:
74: /**
75: * Implant new captcha settings to this service.
76: * <p>
77: * This is an expensive method as new Image filters and many processing objects are allocated anew.
78: * Prefer using the {@link CmsCaptchaServiceCache#getCaptchaService(CmsCaptchaSettings, org.opencms.file.CmsObject)} method instead.
79: * It will return cached instances for equal settings.
80: * <p>
81: *
82: * @param settings the captcha settings to implant.
83: */
84: protected void setSettings(CmsCaptchaSettings settings) {
85:
86: CmsCaptchaEngine captchaEngine = (CmsCaptchaEngine) engine;
87: captchaEngine.setSettings(settings);
88: }
89:
90: }
|