mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
fix image type
This commit is contained in:
parent
dfba30f83f
commit
f63fcae531
@ -46,22 +46,19 @@ public class CaptchaController
|
|||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
byte[] captchaChallengeAsJpeg;
|
|
||||||
// the output stream to render the captcha image as jpeg into
|
|
||||||
final ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
|
|
||||||
|
|
||||||
// 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!
|
|
||||||
final String captchaId = request.getSession().getId();
|
|
||||||
|
|
||||||
// call the ImageCaptchaService getChallenge method
|
|
||||||
final BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale());
|
|
||||||
|
|
||||||
// flush it in the response
|
|
||||||
response.setHeader("Cache-Control", "no-store");
|
response.setHeader("Cache-Control", "no-store");
|
||||||
response.setHeader("Pragma", "no-cache");
|
response.setHeader("Pragma", "no-cache");
|
||||||
response.setDateHeader("Expires", 0);
|
response.setDateHeader("Expires", 0);
|
||||||
response.setContentType("image/jpeg");
|
response.setContentType("image/png");
|
||||||
|
|
||||||
|
// 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!
|
||||||
|
final String captchaId = request.getSession().getId();
|
||||||
|
|
||||||
|
// call the ImageCaptchaService getChallenge method
|
||||||
|
final BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale());
|
||||||
|
|
||||||
|
// flush it in the response
|
||||||
final ServletOutputStream responseOutputStream = response.getOutputStream();
|
final ServletOutputStream responseOutputStream = response.getOutputStream();
|
||||||
ImageIO.write(challenge, "png", responseOutputStream);
|
ImageIO.write(challenge, "png", responseOutputStream);
|
||||||
responseOutputStream.flush();
|
responseOutputStream.flush();
|
||||||
|
Loading…
Reference in New Issue
Block a user