Update of 
/var/cvs/contributions/CMSContainer_Portlets/portlets-guestbook/src/java/com/finalist/captcha
In directory 
james.mmbase.org:/tmp/cvs-serv15494/portlets-guestbook/src/java/com/finalist/captcha

Modified Files:
      Tag: b1_5
        CaptchaServiceSingleton.java 
Log Message:
CMSC-1120 improved captcha pluginablity


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer_Portlets/portlets-guestbook/src/java/com/finalist/captcha
See also: http://www.mmbase.org/jira/browse/CMSC-1120


Index: CaptchaServiceSingleton.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer_Portlets/portlets-guestbook/src/java/com/finalist/captcha/CaptchaServiceSingleton.java,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -u -b -r1.2 -r1.2.4.1
--- CaptchaServiceSingleton.java        26 Nov 2007 11:42:56 -0000      1.2
+++ CaptchaServiceSingleton.java        28 Oct 2008 13:34:54 -0000      1.2.4.1
@@ -1,11 +1,17 @@
 package com.finalist.captcha;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.finalist.cmsc.mmbase.PropertiesUtil;
+import com.octo.captcha.engine.image.ListImageCaptchaEngine;
 import com.octo.captcha.service.captchastore.FastHashMapCaptchaStore;
 import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;
 import com.octo.captcha.service.image.ImageCaptchaService;
 
 public class CaptchaServiceSingleton {
 
+   private static Log log = LogFactory.getLog(CaptchaServiceSingleton.class);  
    private static ImageCaptchaService instance = initializeService();
 
 
@@ -15,7 +21,19 @@
 
 
    private static ImageCaptchaService initializeService() {
-      NumberListImageCaptchaEngine engine = new NumberListImageCaptchaEngine();
+         String engineClass = 
PropertiesUtil.getProperty("guestbook.captcha.engineClass");
+         ListImageCaptchaEngine engine = null; 
+      
+      if(engineClass == null || engineClass.length() == 0) {
+         engine = new NumberListImageCaptchaEngine();
+      }
+      else {
+         try {
+                       engine = (ListImageCaptchaEngine) 
Class.forName(engineClass).newInstance();
+                 } catch (Exception e) {
+               log.error("Could not instantiate engineClass for guestbook (see 
admin/properties)", e);
+                 }
+      }
       return new DefaultManageableImageCaptchaService(new 
FastHashMapCaptchaStore(), engine, 180, 100000, 75000);
    }
 }
\ No newline at end of file
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to