From 1de4c3175046e0c9cd5888a2714e1bdee57d1580 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Fri, 25 Apr 2014 10:02:49 -0400 Subject: [PATCH] wtf --- .../services/resources/QRCodeResource.java | 112 +++++++++--------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/services/src/main/java/org/keycloak/services/resources/QRCodeResource.java b/services/src/main/java/org/keycloak/services/resources/QRCodeResource.java index 3ae4b6756e..4638f177d2 100755 --- a/services/src/main/java/org/keycloak/services/resources/QRCodeResource.java +++ b/services/src/main/java/org/keycloak/services/resources/QRCodeResource.java @@ -1,56 +1,56 @@ -package org.keycloak.services.resources; - -import com.google.zxing.BarcodeFormat; -import com.google.zxing.WriterException; -import com.google.zxing.client.j2se.MatrixToImageWriter; -import com.google.zxing.common.BitMatrix; -import com.google.zxing.qrcode.QRCodeWriter; - -import javax.servlet.ServletException; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.StreamingOutput; -import java.io.IOException; -import java.io.OutputStream; - -/** - * @author Stian Thorgersen - */ -@Path("/qrcode") -public class QRCodeResource { - - @GET - @Produces("image/png") - public Response createQrCode(@QueryParam("contents") String contents, @QueryParam("size") String size) throws ServletException, IOException, WriterException { - int width = 256; - int height = 256; - - if (size != null) { - String[] s = size.split("x"); - width = Integer.parseInt(s[0]); - height = Integer.parseInt(s[1]); - } - - if (contents == null) { - return Response.status(Response.Status.BAD_REQUEST).build(); - } - - QRCodeWriter writer = new QRCodeWriter(); - final BitMatrix bitMatrix = writer.encode(contents, BarcodeFormat.QR_CODE, width, height); - - StreamingOutput stream = new StreamingOutput() { - @Override - public void write(OutputStream os) throws IOException, - WebApplicationException { - MatrixToImageWriter.writeToStream(bitMatrix, "png", os); - } - }; - - return Response.ok(stream).build(); - } - -} +package org.keycloak.services.resources; + +import com.google.zxing.BarcodeFormat; +import com.google.zxing.WriterException; +import com.google.zxing.client.j2se.MatrixToImageWriter; +import com.google.zxing.common.BitMatrix; +import com.google.zxing.qrcode.QRCodeWriter; + +import javax.servlet.ServletException; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.StreamingOutput; +import java.io.IOException; +import java.io.OutputStream; + +/** + * @author Stian Thorgersen + */ +@Path("/qrcode") +public class QRCodeResource { + + @GET + @Produces("image/png") + public Response createQrCode(@QueryParam("contents") String contents, @QueryParam("size") String size) throws ServletException, IOException, WriterException { + int width = 256; + int height = 256; + + if (size != null) { + String[] s = size.split("x"); + width = Integer.parseInt(s[0]); + height = Integer.parseInt(s[1]); + } + + if (contents == null) { + return Response.status(Response.Status.BAD_REQUEST).build(); + } + + QRCodeWriter writer = new QRCodeWriter(); + final BitMatrix bitMatrix = writer.encode(contents, BarcodeFormat.QR_CODE, width, height); + + StreamingOutput stream = new StreamingOutput() { + @Override + public void write(OutputStream os) throws IOException, + WebApplicationException { + MatrixToImageWriter.writeToStream(bitMatrix, "png", os); + } + }; + + return Response.ok(stream).build(); + } + +}