Permalink
Browse files

Added base64 encoding to ca distribution.

  • Loading branch information...
1 parent 26d3d32 commit 030156f10897eff915e5b4c5b2808aeca8588b09 @seize-the-dave seize-the-dave committed Apr 6, 2013
View
4 jester-servlet/src/main/java/org/jscep/jester/servlet/CaDistributionServlet.java
@@ -1,5 +1,6 @@
package org.jscep.jester.servlet;
+import org.apache.commons.codec.binary.Base64OutputStream;
import org.jscep.jester.EstMediator;
import org.jscep.jester.io.EntityEncoder;
@@ -22,7 +23,8 @@
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(APPLICATION_PKCS7_MIME_SMIME_CERTS_ONLY);
+ response.addHeader("Content-Transfer-Encoding", "base64");
- encoder.encode(est.getCaCertificates(), response.getOutputStream());
+ encoder.encode(est.getCaCertificates(), new Base64OutputStream(response.getOutputStream()));
}
}
View
4 jester-servlet/src/test/java/org/jscep/jester/servlet/CaDistributionServletTest.java
@@ -1,5 +1,6 @@
package org.jscep.jester.servlet;
+import org.apache.commons.codec.binary.Base64;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -47,6 +48,7 @@ public void testContentType() throws IOException, ServletException {
servlet.doGet(request, response);
verify(response).setContentType(CaDistributionServlet.APPLICATION_PKCS7_MIME_SMIME_CERTS_ONLY);
+ verify(response).addHeader("Content-Transfer-Encoding", "base64");
}
@Test
@@ -60,6 +62,6 @@ public void testOutput() throws IOException, ServletException {
servlet.doGet(request, response);
byte[] actual = bOut.toByteArray();
- assertArrayEquals(CsrAttributeEncoderStub.TEST_BYTES, actual);
+ assertArrayEquals(Base64.encodeBase64(CaDistributionEncoderStub.TEST_BYTES), actual);
}
}

0 comments on commit 030156f

Please sign in to comment.