From dfba30f83fc4aff79673eff1d96665446110ac0c Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 24 Nov 2010 00:09:06 +0100 Subject: [PATCH] Fixing captcha error because of OpenJDK --- .../javascript/XMLMindmapSerializerFactory.js | 0 .../controller/CaptchaController.java | 25 ++++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) create mode 100644 mindplot/src/main/javascript/XMLMindmapSerializerFactory.js diff --git a/mindplot/src/main/javascript/XMLMindmapSerializerFactory.js b/mindplot/src/main/javascript/XMLMindmapSerializerFactory.js new file mode 100644 index 00000000..e69de29b diff --git a/wise-webapp/src/main/java/com/wisemapping/controller/CaptchaController.java b/wise-webapp/src/main/java/com/wisemapping/controller/CaptchaController.java index 347f4399..05af4e1b 100644 --- a/wise-webapp/src/main/java/com/wisemapping/controller/CaptchaController.java +++ b/wise-webapp/src/main/java/com/wisemapping/controller/CaptchaController.java @@ -22,6 +22,7 @@ package com.wisemapping.controller; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; +import javax.imageio.ImageIO; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; @@ -54,22 +55,16 @@ public class CaptchaController final String captchaId = request.getSession().getId(); // call the ImageCaptchaService getChallenge method - final BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale()); - - // a jpeg encoder - final JPEGImageEncoder jpegEncoder = JPEGCodec.createJPEGEncoder(jpegOutputStream); - jpegEncoder.encode(challenge); - - captchaChallengeAsJpeg = jpegOutputStream.toByteArray(); + final BufferedImage challenge = captchaService.getImageChallengeForID(captchaId,request.getLocale()); - // 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(); + // 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(); + ImageIO.write(challenge, "png", responseOutputStream); + responseOutputStream.flush(); responseOutputStream.close(); return null; }