KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > frontend > templateone > form > CmsCaptchaService


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/frontend/templateone/form/CmsCaptchaService.java,v $
3  * Date : $Date: 2006/03/27 14:52:20 $
4  * Version: $Revision: 1.4 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (C) 2002 - 2004 Alkacon Software (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.frontend.templateone.form;
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.4 $
47  */

48 public class CmsCaptchaService extends AbstractManageableImageCaptchaService implements ImageCaptchaService {
49
50     /**
51      * Creates a new captcha service.
52      * <p>
53      *
54      * minGuarantedStorageDelayInSeconds = 180s maxCaptchaStoreSize = 100000
55      * captchaStoreLoadBeforeGarbageCollection=75000
56      *
57      * @param captchaSettings the settings to render captcha images
58      */

59     public CmsCaptchaService(CmsCaptchaSettings captchaSettings) {
60
61         super(new MapCaptchaStore(), new CmsCaptchaEngine(captchaSettings), 180, 100000, 75000);
62     }
63     
64     
65     
66     /**
67      * Implant new captcha settings to this service.
68      * <p>
69      * This is an expensive method as new Image filters and many processing objects are allocated anew.
70      * Prefer using the {@link CmsCaptchaServiceCache#getCaptchaService(CmsCaptchaSettings, org.opencms.file.CmsObject)} method instead.
71      * It will return cached instances for equal settings.
72      * <p>
73      *
74      * @param settings the captcha settings to implant.
75      */

76     protected void setSettings(CmsCaptchaSettings settings) {
77
78         CmsCaptchaEngine captchaEngine = (CmsCaptchaEngine)engine;
79         captchaEngine.setSettings(settings);
80     }
81     
82     
83     
84
85 }
86
Popular Tags