mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-08-20 12:30:44 +02:00
Fixing captcha error because of OpenJDK
This commit is contained in:
parent
862a53e147
commit
dfba30f83f
@ -22,6 +22,7 @@ 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;
|
||||||
@ -56,19 +57,13 @@ public class CaptchaController
|
|||||||
// 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());
|
||||||
|
|
||||||
// a jpeg encoder
|
|
||||||
final JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(jpegOutputStream);
|
|
||||||
jpegEncoder.encode(challenge);
|
|
||||||
|
|
||||||
captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
|
|
||||||
|
|
||||||
// flush it in the response
|
// 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/jpeg");
|
||||||
final ServletOutputStream responseOutputStream = response.getOutputStream();
|
final ServletOutputStream responseOutputStream = response.getOutputStream();
|
||||||
responseOutputStream.write(captchaChallengeAsJpeg);
|
ImageIO.write(challenge, "png", responseOutputStream);
|
||||||
responseOutputStream.flush();
|
responseOutputStream.flush();
|
||||||
responseOutputStream.close();
|
responseOutputStream.close();
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user