1 28 package net.sf.jguard.example.struts.admin.actions; 29 30 import java.io.IOException ; 31 32 import javax.servlet.http.HttpServletRequest ; 33 import javax.servlet.http.HttpServletResponse ; 34 35 import net.sf.jguard.example.struts.actions.BaseAction; 36 import net.sf.jguard.jee.authentication.http.CaptchaChallengeBuilder; 37 38 import org.apache.log4j.Logger; 39 import org.apache.struts.action.ActionForm; 40 import org.apache.struts.action.ActionForward; 41 import org.apache.struts.action.ActionMapping; 42 43 import com.octo.captcha.service.CaptchaServiceException; 44 import com.sun.image.codec.jpeg.ImageFormatException; 45 46 52 public class CaptchaAction extends BaseAction { 53 private static Logger logger = Logger.getLogger(CaptchaAction.class); 54 55 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 56 57 try { 58 CaptchaChallengeBuilder.buildCaptchaChallenge(request, response); 59 } catch (IllegalArgumentException e) { 60 logger.error(e.getMessage()); 61 return mapping.findForward("CaptchaKO"); 62 } catch (CaptchaServiceException e) { 63 logger.error(e.getMessage()); 64 return mapping.findForward("CaptchaKO"); 65 } catch (ImageFormatException e) { 66 logger.error(e.getMessage()); 67 return mapping.findForward("CaptchaKO"); 68 } catch (IOException e) { 69 logger.error(e.getMessage()); 70 return mapping.findForward("CaptchaKO"); 71 } 72 73 return null; 74 } 75 76 77 78 } 79 | Popular Tags |