1 18 package org.apache.geronimo.ca.helper; 19 20 import java.io.ByteArrayOutputStream ; 21 import java.io.IOException ; 22 import java.util.Properties ; 23 24 import javax.servlet.ServletException ; 25 import javax.servlet.http.HttpServletRequest ; 26 import javax.servlet.http.HttpServletResponse ; 27 28 import org.apache.geronimo.ca.helper.util.CAHelperUtils; 29 30 35 public class CertificateRequestServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet { 36 39 public CertificateRequestServlet() { 40 super(); 41 } 42 43 46 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException , IOException { 47 doPost(request, response); 48 } 49 50 53 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException , IOException { 54 String reqCN = request.getParameter("reqCN"); 56 String reqOU = request.getParameter("reqOU"); 57 String reqO = request.getParameter("reqO"); 58 String reqL = request.getParameter("reqL"); 59 String reqST = request.getParameter("reqST"); 60 String reqC = request.getParameter("reqC"); 61 String spkac = request.getParameter("spkac"); 62 63 if(spkac == null || spkac.equals("")) { 64 throw new ServletException ("Browser did not generate SignedPublicKeyAndChallenge. Resubmit your certificate request."); 66 } 67 Properties csrProps = new Properties (); 69 csrProps.setProperty("CN", reqCN); 70 csrProps.setProperty("OU", reqOU); 71 csrProps.setProperty("O", reqO); 72 csrProps.setProperty("L", reqL); 73 csrProps.setProperty("ST", reqST); 74 csrProps.setProperty("C", reqC); 75 csrProps.setProperty("SPKAC", spkac); 76 77 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 78 csrProps.store(baos, "Request received through CA Helper Application"); 79 baos.close(); 80 81 String csrId = CAHelperUtils.getCertificateRequestStore().storeRequest(null, baos.toString()); 83 84 request.setAttribute("id", csrId); 86 getServletContext().getRequestDispatcher("/receivedCSR.jsp").forward(request, response); 87 } 88 } 89 | Popular Tags |