Examples of Captcha


Examples of nl.captcha.Captcha

    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

Examples of nl.captcha.Captcha

        }
    }

    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

Examples of nl.captcha.Captcha

   {
      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

Examples of nl.captcha.Captcha

  @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

Examples of nl.captcha.Captcha

     */
    @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

Examples of nl.captcha.Captcha

   
    @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

Examples of nl.captcha.Captcha

  @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

Examples of nl.captcha.Captcha

            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
Copyright © 2018 www.massapi.com. 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.