Package com.google.code.kaptcha

Examples of com.google.code.kaptcha.Producer


        String randomSecretKey = UUID.randomUUID().toString()//random string for the captcha.
        String imagePath = StratosConstants.CAPTCHA_IMAGES_PATH + RegistryConstants.PATH_SEPARATOR +
                           randomSecretKey + ".jpg";

        Config config = new Config(new Properties());
        Producer captchaProducer = config.getProducerImpl();
        String captchaText = captchaProducer.createText();

        BufferedImage image = captchaProducer.createImage(captchaText);

        File tempFile = File.createTempFile("temp-", ".jpg");

        try {
            ImageIO.write(image, "jpg", tempFile);
View Full Code Here


    public void testHandleRequestToCaptchaImage() throws Exception {
        HttpServletResponse response = mock(HttpServletResponse.class);
        session = mock(HttpSession.class);
        request.setSession(session);
        ServletOutputStream out = mock(ServletOutputStream.class);
        Producer captchaProducer = mock(Producer.class);

        int imageType = 1;

        when(response.getOutputStream()).thenReturn(out);
        when(service.getCaptchaProducer()).thenReturn(captchaProducer);
        when(captchaProducer.createText()).thenReturn(GENERATED_CAPTCHA_TEXT);
        when(captchaProducer.createImage(GENERATED_CAPTCHA_TEXT)).
                thenReturn(new BufferedImage(IMAGE_WIDTH, IMAGE_HEIGHT, imageType));

        service.refreshCaptchaImage(request, response);

        verify(response).setContentType("image/jpeg");
View Full Code Here

TOP

Related Classes of com.google.code.kaptcha.Producer

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.