001 package jsp;
002
003 import javax.servlet.*;
004 import javax.servlet.http.*;
005 import javax.servlet.jsp.*;
006 import java.security.cert.Certificate;
007 import org.apache.geronimo.ca.helper.util.CAHelperUtils;
008 import org.apache.geronimo.crypto.CaUtils;
009 import org.apache.geronimo.crypto.CertificateUtil;
010 import org.apache.geronimo.management.geronimo.*;
011 import java.math.BigInteger;
012
013 public final class installPersonalCertificate_jsp extends org.apache.jasper.runtime.HttpJspBase
014 implements org.apache.jasper.runtime.JspSourceDependent {
015
016 private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
017
018 private static java.util.List _jspx_dependants;
019
020 private javax.el.ExpressionFactory _el_expressionfactory;
021 private org.apache.InstanceManager _jsp_instancemanager;
022
023 public Object getDependants() {
024 return _jspx_dependants;
025 }
026
027 public void _jspInit() {
028 _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
029 _jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
030 }
031
032 public void _jspDestroy() {
033 }
034
035 public void _jspService(HttpServletRequest request, HttpServletResponse response)
036 throws java.io.IOException, ServletException {
037
038 PageContext pageContext = null;
039 HttpSession session = null;
040 ServletContext application = null;
041 ServletConfig config = null;
042 JspWriter out = null;
043 Object page = this;
044 JspWriter _jspx_out = null;
045 PageContext _jspx_page_context = null;
046
047
048 try {
049 response.setContentType("text/html; charset=ISO-8859-1");
050 pageContext = _jspxFactory.getPageContext(this, request, response,
051 null, true, 8192, true);
052 _jspx_page_context = pageContext;
053 application = pageContext.getServletContext();
054 config = pageContext.getServletConfig();
055 session = pageContext.getSession();
056 out = pageContext.getOut();
057 _jspx_out = out;
058
059
060 String csrId = request.getParameter("csrId");
061 CertificateRequestStore certReqStore = CAHelperUtils.getCertificateRequestStore();
062 BigInteger sNo = certReqStore.getSerialNumberForRequest(csrId);
063 String base64Cert = null;
064 String fpSHA1 = null;
065 String fpMD5 = null;
066 if(sNo != null) {
067 CertificateStore certStore = CAHelperUtils.getCertificateStore();
068 Certificate cert = certStore.getCertificate(sNo);
069 request.setAttribute("cert", cert);
070 base64Cert = CaUtils.base64Certificate(cert);
071 fpSHA1 = CertificateUtil.generateFingerprint(cert, "SHA1");
072 fpMD5 = CertificateUtil.generateFingerprint(cert, "MD5");
073 }
074
075 out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\r\n<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">\r\n<title>Install Personal Certificate</title>\r\n</head>\r\n<body>\r\n<h2>Install Personal Certificate</h2>\r\n<p>This page enables you to download and install a personal certificate into your web browser.</p>\r\n\r\n");
076 if(sNo == null) {
077 out.write("\r\nEither the CSR is yet to be fulfilled or the csrId ");
078 out.print(csrId);
079 out.write(" is invalid.\r\n");
080 } else {
081 out.write("<SCRIPT LANGUAGE=\"VBScript\">\r\n<!--\r\nSub Install_Onclick\r\n certificate = document.installForm.cert.value\r\n On Error Resume Next\r\n Dim Enroll\r\n\r\n Set Enroll = CreateObject(\"CEnroll.CEnroll.2\")\r\n if ( (Err.Number = 438) OR (Err.Number = 429) ) Then\r\n Err.Clear\r\n Set Enroll = CreateObject(\"CEnroll.CEnroll.1\")\r\n End If\r\n if Err.Number <> 0 then\r\n MsgBox(\"Error in creating CEnroll object. error:\" & Hex(err))\r\n Else\r\n Call Enroll.acceptPKCS7(certificate)\r\n If err.Number <> 0 then\r\n MsgBox(\"Certificate installation failed. error: \"& Hex(err))\r\n Else\r\n MsgBox(\"Certificate installed sucessfully\")\r\n End if\r\n End If\r\nEnd sub\r\n-->\r\n</SCRIPT>\r\n\r\nTo install your certificate into Internet Explorer, click on the <i>Install Certificate</i> button below.\r\nFor other web browsers, click on <a href=\"DownloadCertificateServlet?csrId=");
082 out.print(csrId);
083 out.write("\">this link</a>.\r\n<form method=\"POST\">\r\n <input type=\"button\" value=\"Install Certificate\" onClick=\"Install_Onclick()\"/>\r\n</form>\r\n\r\n<br><b>Base64 encoded Certificate Text</b>\r\n<br>\r\n<form name=\"installForm\" method=\"POST\">\r\n <textarea name=\"cert\" rows=\"10\" cols=\"80\" READONLY>");
084 out.print(base64Cert);
085 out.write("</textarea>\r\n</form>\r\n\r\n <table border=\"0\">\r\n <tr>\r\n <th colspan=\"2\" align=\"left\">Certificate Details</th>\r\n </tr>\r\n <tr>\r\n <th align=\"right\">Finger Prints</th>\r\n <td>SHA1 ");
086 out.print(fpSHA1);
087 out.write("<br>MD5 ");
088 out.print(fpMD5);
089 out.write("</td>\r\n </tr>\r\n <tr>\r\n <th align=\"right\">Version:</th>\r\n <td>");
090 out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${cert.version}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
091 out.write("</td>\r\n </tr>\r\n <tr>\r\n <th align=\"right\">Subject:</th>\r\n <td>");
092 out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${cert.subjectDN.name}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
093 out.write("</td>\r\n </tr>\r\n <tr>\r\n <th align=\"right\">Issuer:</th>\r\n <td>");
094 out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${cert.issuerDN.name}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
095 out.write("</td>\r\n </tr>\r\n <tr>\r\n <th align=\"right\">Serial Number:</th>\r\n <td>");
096 out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${cert.serialNumber}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
097 out.write("</td>\r\n </tr>\r\n <tr>\r\n <th align=\"right\">Valid From:</th>\r\n <td>");
098 out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${cert.notBefore}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
099 out.write("</td>\r\n </tr>\r\n <tr>\r\n <th align=\"right\">Valid To:</th>\r\n <td>");
100 out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${cert.notAfter}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
101 out.write("</td>\r\n </tr>\r\n <tr>\r\n <th align=\"right\">Signature Alg:</th>\r\n <td>");
102 out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${cert.sigAlgName}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
103 out.write("</td>\r\n </tr>\r\n <tr>\r\n <th align=\"right\">Public Key Alg:</th>\r\n <td>");
104 out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${cert.publicKey.algorithm}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
105 out.write("</td>\r\n </tr>\r\n <tr>\r\n <th align=\"right\" valign=\"top\">cert.toString()</th>\r\n <td><pre>");
106 out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${cert}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
107 out.write("</pre></td>\r\n </tr>\r\n </table>\r\n");
108 }
109 out.write("<br><a href=\"");
110 out.print(request.getContextPath());
111 out.write("\">Back to CA Helper home</a>\r\n\r\n</body>\r\n</html>\r\n");
112 } catch (Throwable t) {
113 if (!(t instanceof SkipPageException)){
114 out = _jspx_out;
115 if (out != null && out.getBufferSize() != 0)
116 try { out.clearBuffer(); } catch (java.io.IOException e) {}
117 if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
118 }
119 } finally {
120 _jspxFactory.releasePageContext(_jspx_page_context);
121 }
122 }
123 }