log.trace(">doGet()");
// Check if authorized
EjbcaWebBean ejbcawebbean= (org.ejbca.ui.web.admin.configuration.EjbcaWebBean)
req.getSession().getAttribute("ejbcawebbean");
RAInterfaceBean rabean = (org.ejbca.ui.web.admin.rainterface.RAInterfaceBean)
req.getSession().getAttribute("rabean");
if ( ejbcawebbean == null ){
try {
ejbcawebbean = (org.ejbca.ui.web.admin.configuration.EjbcaWebBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName());
} catch (ClassNotFoundException exc) {
throw new ServletException(exc.getMessage());
}catch (Exception exc) {
throw new ServletException (" Cannot create bean of class "+ org.ejbca.ui.web.admin.configuration.EjbcaWebBean.class.getName(), exc);
}
req.getSession().setAttribute("ejbcawebbean", ejbcawebbean);
}
if ( rabean == null ){
try {
rabean = (org.ejbca.ui.web.admin.rainterface.RAInterfaceBean) java.beans.Beans.instantiate(Thread.currentThread().getContextClassLoader(), org.ejbca.ui.web.admin.rainterface.RAInterfaceBean.class.getName());
} catch (ClassNotFoundException exc) {
throw new ServletException(exc.getMessage());
}catch (Exception exc) {
throw new ServletException (" Cannot create bean of class "+ org.ejbca.ui.web.admin.rainterface.RAInterfaceBean.class.getName(), exc);
}
req.getSession().setAttribute("rabean", ejbcawebbean);
}
try{
ejbcawebbean.initialize(req,AccessRulesConstants.REGULAR_VIEWCERTIFICATE);
rabean.initialize(req,ejbcawebbean);
} catch(Exception e){
throw new java.io.IOException("Authorization Denied");
}
RequestHelper.setDefaultCharacterEncoding(req);
String issuerdn = req.getParameter(ISSUER_PROPERTY);
String certificatesn = req.getParameter(CERTIFICATEDN_PROPERTY);
String command;
// Keep this for logging.
log.debug("Got request from "+req.getRemoteAddr());
command = req.getParameter(COMMAND_PROPERTY_NAME);
if (command == null) {
command = "";
}
if ((command.equalsIgnoreCase(COMMAND_NSCERT) || command.equalsIgnoreCase(COMMAND_IECERT) || command.equalsIgnoreCase(COMMAND_CERT))
&& issuerdn != null && certificatesn != null) {
BigInteger certsn = new BigInteger(certificatesn,16);
// Fetch the certificate and at the same time check that the user is authorized to it.
try {
rabean.loadCertificates(certsn, issuerdn);
CertificateView certview = rabean.getCertificate(0);
Certificate cert = certview.getCertificate();
byte[] enccert = cert.getEncoded();
// We must remove cache headers for IE
ServletUtils.removeCacheHeaders(res);