Skip to content
This repository
Browse code

Added base64 encoding to ca distribution.

  • Loading branch information...
commit 030156f10897eff915e5b4c5b2808aeca8588b09 1 parent 26d3d32
Dave Grant authored April 06, 2013
4  jester-servlet/src/main/java/org/jscep/jester/servlet/CaDistributionServlet.java
... ...
@@ -1,5 +1,6 @@
1 1
 package org.jscep.jester.servlet;
2 2
 
  3
+import org.apache.commons.codec.binary.Base64OutputStream;
3 4
 import org.jscep.jester.EstMediator;
4 5
 import org.jscep.jester.io.EntityEncoder;
5 6
 
@@ -22,7 +23,8 @@
22 23
 
23 24
     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
24 25
         response.setContentType(APPLICATION_PKCS7_MIME_SMIME_CERTS_ONLY);
  26
+        response.addHeader("Content-Transfer-Encoding", "base64");
25 27
 
26  
-        encoder.encode(est.getCaCertificates(), response.getOutputStream());
  28
+        encoder.encode(est.getCaCertificates(), new Base64OutputStream(response.getOutputStream()));
27 29
     }
28 30
 }
4  jester-servlet/src/test/java/org/jscep/jester/servlet/CaDistributionServletTest.java
... ...
@@ -1,5 +1,6 @@
1 1
 package org.jscep.jester.servlet;
2 2
 
  3
+import org.apache.commons.codec.binary.Base64;
3 4
 import org.jboss.arquillian.container.test.api.Deployment;
4 5
 import org.jboss.arquillian.junit.Arquillian;
5 6
 import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -47,6 +48,7 @@ public void testContentType() throws IOException, ServletException {
47 48
         servlet.doGet(request, response);
48 49
 
49 50
         verify(response).setContentType(CaDistributionServlet.APPLICATION_PKCS7_MIME_SMIME_CERTS_ONLY);
  51
+        verify(response).addHeader("Content-Transfer-Encoding", "base64");
50 52
     }
51 53
 
52 54
     @Test
@@ -60,6 +62,6 @@ public void testOutput() throws IOException, ServletException {
60 62
         servlet.doGet(request, response);
61 63
         byte[] actual = bOut.toByteArray();
62 64
 
63  
-        assertArrayEquals(CsrAttributeEncoderStub.TEST_BYTES, actual);
  65
+        assertArrayEquals(Base64.encodeBase64(CaDistributionEncoderStub.TEST_BYTES), actual);
64 66
     }
65 67
 }

0 notes on commit 030156f

Please sign in to comment.
Something went wrong with that request. Please try again.