[jboss-cvs] jboss-seam/src/main/org/jboss/seam/captcha ...

Gavin King gavin.king at jboss.com
Wed Feb 14 02:36:27 EST 2007


  User: gavin   
  Date: 07/02/14 02:36:27

  Modified:    src/main/org/jboss/seam/captcha      Captcha.java
                        CaptchaImage.java CaptchaResponse.java
                        CaptchaResponseValidator.java CaptchaService.java
  Log:
  minor improvs
  
  Revision  Changes    Path
  1.3       +7 -1      jboss-seam/src/main/org/jboss/seam/captcha/Captcha.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Captcha.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/captcha/Captcha.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- Captcha.java	8 Feb 2007 06:35:13 -0000	1.2
  +++ Captcha.java	14 Feb 2007 07:36:27 -0000	1.3
  @@ -11,6 +11,12 @@
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.contexts.Contexts;
   
  +/**
  + * Supports captcha functionality for any JSF page.
  + * 
  + * @author Gavin King
  + *
  + */
   @Name("org.jboss.seam.captcha.captcha")
   @Scope(ScopeType.PAGE)
   @Install(dependencies="org.jboss.seam.captcha.captchaService")
  @@ -27,7 +33,7 @@
      
      boolean validateResponse(String response)
      {
  -      boolean valid = CaptchaService.instance().getService().validateResponseForID(id, response);
  +      boolean valid = CaptchaService.instance().validateResponseForID(id, response);
         if (!valid) 
         {
            init();
  
  
  
  1.2       +4 -4      jboss-seam/src/main/org/jboss/seam/captcha/CaptchaImage.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CaptchaImage.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/captcha/CaptchaImage.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- CaptchaImage.java	14 Feb 2007 07:32:38 -0000	1.1
  +++ CaptchaImage.java	14 Feb 2007 07:36:27 -0000	1.2
  @@ -48,12 +48,12 @@
   
         try
         {
  -         Lifecycle.beginRequest(getServletContext(), request.getSession(), request);
  +         Lifecycle.beginRequest( getServletContext(), request.getSession(), request );
   
            String captchaId = request.getQueryString();
   
  -         BufferedImage challenge = CaptchaService.instance().getService().getImageChallengeForID(
  -                  captchaId, request.getLocale());
  +         BufferedImage challenge = CaptchaService.instance()
  +               .getImageChallengeForID( captchaId, request.getLocale() );
   
            ImageIO.write(challenge, "jpeg", out);
         }
  @@ -76,7 +76,7 @@
         response.setHeader("Pragma", "no-cache");
         response.setDateHeader("Expires", 0);
         response.setContentType("image/jpeg");
  -      response.getOutputStream().write(out.toByteArray());
  +      response.getOutputStream().write( out.toByteArray() );
         response.getOutputStream().flush();
         response.getOutputStream().close();
      }
  
  
  
  1.2       +2 -1      jboss-seam/src/main/org/jboss/seam/captcha/CaptchaResponse.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CaptchaResponse.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/captcha/CaptchaResponse.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- CaptchaResponse.java	8 Feb 2007 06:21:52 -0000	1.1
  +++ CaptchaResponse.java	14 Feb 2007 07:36:27 -0000	1.2
  @@ -12,6 +12,7 @@
   @Documented
   @Target(ElementType.METHOD)
   @ValidatorClass(CaptchaResponseValidator.class)
  -public @interface CaptchaResponse {
  +public @interface CaptchaResponse 
  +{
      String message() default "input characters did not match";
   }
  
  
  
  1.2       +7 -0      jboss-seam/src/main/org/jboss/seam/captcha/CaptchaResponseValidator.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CaptchaResponseValidator.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/captcha/CaptchaResponseValidator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- CaptchaResponseValidator.java	8 Feb 2007 06:21:52 -0000	1.1
  +++ CaptchaResponseValidator.java	14 Feb 2007 07:36:27 -0000	1.2
  @@ -4,6 +4,13 @@
   
   import org.hibernate.validator.Validator;
   
  +/**
  + * Validates that the input entered by the user matches
  + * the captcha image.
  + * 
  + * @author Gavin King
  + *
  + */
   public class CaptchaResponseValidator implements Validator
   {
   
  
  
  
  1.2       +4 -2      jboss-seam/src/main/org/jboss/seam/captcha/CaptchaService.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: CaptchaService.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/captcha/CaptchaService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- CaptchaService.java	8 Feb 2007 06:35:13 -0000	1.1
  +++ CaptchaService.java	14 Feb 2007 07:36:27 -0000	1.2
  @@ -8,6 +8,7 @@
   import org.jboss.seam.annotations.Intercept;
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
  +import org.jboss.seam.annotations.Unwrap;
   import org.jboss.seam.contexts.Contexts;
   
   import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;
  @@ -27,17 +28,18 @@
         service = new DefaultManageableImageCaptchaService();
      }
      
  +   @Unwrap
      public ImageCaptchaService getService()
      {
         return service;
      }
      
  -   public static CaptchaService instance()
  +   public static ImageCaptchaService instance()
      {
         if ( !Contexts.isApplicationContextActive() )
         {
            throw new IllegalStateException("No active application scope");
         }
  -      return (CaptchaService) Component.getInstance(CaptchaService.class);
  +      return (ImageCaptchaService) Component.getInstance(CaptchaService.class);
      }
   }
  
  
  



More information about the jboss-cvs-commits mailing list