Package nl.captcha

Examples of nl.captcha.Captcha$Builder


   @Override
   public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
   {
      HttpSession session = req.getSession();
      Captcha captcha;
      if (session.getAttribute(NAME) == null)
      {
         captcha = new Captcha.Builder(_width, _height).addText().gimp().addNoise().addBackground().build();

         session.setAttribute(NAME, captcha);
         CaptchaServletUtil.writeImage(resp, captcha.getImage());

         return;
      }

      captcha = (Captcha) session.getAttribute(NAME);
      CaptchaServletUtil.writeImage(resp, captcha.getImage());
   }
View Full Code Here


  /**
   * 取得验证码
   */
  public void getImg() throws Exception
  {
    Captcha captcha = (new nl.captcha.Captcha.Builder(200, 50)).addText().addBackground().addNoise().build();
    CaptchaServletUtil.writeImage(super.response, captcha.getImage());
    getSession().setAttribute("simpleCaptcha", captcha);
  }
View Full Code Here

    protected boolean isValid(String value, UIFormInput uiInput) {
        PortletRequestContext ctx = PortletRequestContext.getCurrentInstance();
        PortletRequest req = ctx.getRequest();
        PortletSession session = req.getPortletSession();

        Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);

        return ((captcha != null) && (captcha.isCorrect(value)));
    }
View Full Code Here

        }
    }

    public void serveResource(ResourceRequest req, ResourceResponse resp) throws PortletException, java.io.IOException {
        PortletSession session = req.getPortletSession();
        Captcha captcha;
        if (session.getAttribute(NAME) == null) {
            captcha = new Captcha.Builder(_width, _height).addText().gimp().addNoise().addBackground().build();

            session.setAttribute(NAME, captcha);
            writeImage(resp, captcha.getImage());

            return;
        }

        captcha = (Captcha) session.getAttribute(NAME);
        writeImage(resp, captcha.getImage());

    }
View Full Code Here

   {
      PortalRequestContext prContext = Util.getPortalRequestContext();
      HttpServletRequest request = prContext.getRequest();
      HttpSession session = request.getSession();

      Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);

      if ((captcha != null) && (captcha.isCorrect((String) uiInput.getValue())))
      {
         return;
      }

      //modified by Pham Dinh Tan
View Full Code Here

  @Override
  public Object intercept(ActionRequest actionRequest) throws Exception {

    HttpSession session = actionRequest.getHttpServletRequest().getSession();
    Captcha captcha = (Captcha) session.getAttribute(Captcha.NAME);

    if (captcha != null) {
      Object action = actionRequest.getAction();
      BeanUtil.setDeclaredPropertySilent(action, CAPTCHA_FIELD_NAME, captcha);
    }
View Full Code Here

     */
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        HttpSession session = req.getSession();
        Captcha captcha;
        if (session.getAttribute(NAME) == null) {
            captcha = new Captcha.Builder(_width, _height)
              .addText()
              .gimp()
              .addBorder()
                .addNoise()
                .addBackground()
                .build();

            session.setAttribute(NAME, captcha);
            CaptchaServletUtil.writeImage(resp, captcha.getImage());

            return;
        }

        captcha = (Captcha) session.getAttribute(NAME);
        CaptchaServletUtil.writeImage(resp, captcha.getImage());
    }
View Full Code Here

   
    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {

        Captcha captcha = new Captcha.Builder(_width, _height)
          .addText()
          .addBackground(new GradiatedBackgroundProducer())
            .gimp()
            .addNoise()
            .addBorder()
            .build();

        CaptchaServletUtil.writeImage(resp, captcha.getImage());
        req.getSession().setAttribute(NAME, captcha);
    }
View Full Code Here

  @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        HttpSession session = req.getSession();
        Captcha captcha;
        if (session.getAttribute(NAME) == null) {
          captcha = new Captcha.Builder(_width, _height)
                .addText(new ChineseTextProducer())
                .gimp()
                .addBorder()
                  .addNoise()
                  .addBackground(new GradiatedBackgroundProducer())
                  .build();

          session.setAttribute(NAME, captcha);
          CaptchaServletUtil.writeImage(resp, captcha.getImage());
         
          return;
        }

        captcha = (Captcha) session.getAttribute(NAME);
        CaptchaServletUtil.writeImage(resp, captcha.getImage());
    }
View Full Code Here

            response.sendRedirect("protected/registration.jsp");
        }
    }
   
    private boolean isCaptchaCorrect (HttpServletRequest request) {
        Captcha captcha = (Captcha) request.getSession().getAttribute (Captcha.NAME);
        String answer = request.getParameter("answer");
        if (captcha.isCorrect(answer)) {
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

TOP

Related Classes of nl.captcha.Captcha$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.