mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
rolling back captcha fix
This commit is contained in:
parent
f63fcae531
commit
63fe8c5493
@ -22,7 +22,6 @@ package com.wisemapping.controller;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.servlet.ServletOutputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@ -46,22 +45,31 @@ public class CaptchaController
|
|||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
response.setHeader("Cache-Control", "no-store");
|
byte[] captchaChallengeAsJpeg;
|
||||||
response.setHeader("Pragma", "no-cache");
|
// the output stream to render the captcha image as jpeg into
|
||||||
response.setDateHeader("Expires", 0);
|
final ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
|
||||||
response.setContentType("image/png");
|
|
||||||
|
|
||||||
// get the session id that will identify the generated captcha.
|
// get the session id that will identify the generated captcha.
|
||||||
//the same id must be used to validate the response, the session id is a good candidate!
|
//the same id must be used to validate the response, the session id is a good candidate!
|
||||||
final String captchaId = request.getSession().getId();
|
final String captchaId = request.getSession().getId();
|
||||||
|
|
||||||
// call the ImageCaptchaService getChallenge method
|
// call the ImageCaptchaService getChallenge method
|
||||||
final BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale());
|
final BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale());
|
||||||
|
|
||||||
// flush it in the response
|
// a jpeg encoder
|
||||||
final ServletOutputStream responseOutputStream = response.getOutputStream();
|
final JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(jpegOutputStream);
|
||||||
ImageIO.write(challenge, "png", responseOutputStream);
|
jpegEncoder.encode(challenge);
|
||||||
responseOutputStream.flush();
|
|
||||||
|
captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
|
||||||
|
|
||||||
|
// flush it in the response
|
||||||
|
response.setHeader("Cache-Control", "no-store");
|
||||||
|
response.setHeader("Pragma", "no-cache");
|
||||||
|
response.setDateHeader("Expires", 0);
|
||||||
|
response.setContentType("image/jpeg");
|
||||||
|
final ServletOutputStream responseOutputStream = response.getOutputStream();
|
||||||
|
responseOutputStream.write(captchaChallengeAsJpeg);
|
||||||
|
responseOutputStream.flush();
|
||||||
responseOutputStream.close();
|
responseOutputStream.close();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user