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