String kstype;
    public void init(ServletConfig config)         throws ServletException {        super.init(config);                try {            String initparam;            String kspath;            String kspwd;            String kstype;            String pkalias;                        InitialContext ctx = new InitialContext();            ICertificateStoreSessionLocalHome certStoreHome =                 (ICertificateStoreSessionLocalHome)PortableRemoteObject.narrow(ctx.lookup("java:comp/env/ejb/CertificateStoreSessionLocal"), ICertificateStoreSessionLocalHome.class);            m_certStore = certStoreHome.create();            m_adm = new Admin(Admin.TYPE_INTERNALUSER);            {                File cwd = new File(".");                m_log.info("OCSPServlet current working directory : '"                            + cwd.getAbsolutePath()                            + "'");            }                        // TODO: get keystore from CA instead, when parsing request and finding out            // who the issuer is            kspath = config.getInitParameter("keyStore").trim();            if (null == kspath || kspath.length() <= 0) {                m_log.error("Path to keystore not defined in initialization parameters.");                throw new ServletException("Missing keystore path.");            }            kspwd = config.getInitParameter("keyStorePass").trim();            if (null == kspwd || kspwd.length() <= 0) {                m_log.error("Keystore password not defined in initialization parameters.");                throw new ServletException("Missing keystore password.");            }            kstype = config.getInitParameter("keyStoreType").trim();            if (null == kstype || kstype.length() <= 0) {                m_log.warn("Keystore format not defined. Assuming PKCS12 as default.");                kstype = "PKCS12";            }            if (m_log.isDebugEnabled()) {                m_log.debug("Keystore type     : '" + kstype + "'\n"                            + "Keystore path     : '" + kspath + "'\n"                            + "Keystore passwd   : '" + kspwd + "'\n");            }            KeyStore ks = KeyStore.getInstance(kstype);            ks.load(new FileInputStream(kspath), kspwd.toCharArray());            if (m_log.isDebugEnabled()) {                StringBuffer sb = new StringBuffer();                Enumeration aliases = ks.aliases();                while (aliases.hasMoreElements()) {                    sb.append(", ");                    sb.append(aliases.nextElement());                }                sb.delete(0, ", ".length());                m_log.debug("Available aliases is keystore : '"                            + sb.toString()                            + "'");                                        }            /*             * load OCSP signing (private) key             */            pkalias = config.getInitParameter("privateKeyAlias").trim();            if (null == pkalias || pkalias.length() <= 0) {                pkalias = "ocspsignkey";            }                        initparam = config.getInitParameter("privateKeyPass").trim();            if (null != initparam && initparam.length() <= 0) {                initparam = null;            }            if (!ks.isKeyEntry(pkalias)) {                m_log.error("The private key alias '"                             + pkalias                             + "' does not denote a private key in the specified keystore.");                throw new ServletException("Unable to find OCSP signing key.");            }            if (m_log.isDebugEnabled()) {                m_log.debug("Private key alias     : '" + pkalias + "'\n"                            + "Private key pass      : '" + (initparam == null ? "null" : initparam) + "'");            }            m_signkey = (PrivateKey)ks.getKey(pkalias                                              , (initparam == null ? null : initparam.toCharArray()));            if (null == m_signkey) {                final String msg = "Unable to load private key from keystore.";                m_log.error(msg);                throw new ServletException(msg);                            }            /*             * load OCSP signing certificate             */            initparam = config.getInitParameter("certificateAlias").trim();            if (null == initparam || initparam.length() <= 0) {                initparam = "ocspsigncert";            }            if (m_log.isDebugEnabled()) {                m_log.debug("Certificate alias : '" + initparam + "'\n");            }            Certificate [] certs = ks.getCertificateChain(initparam);            if (null == certs) {                final String msg = "Unable to load certificate (chain) from keystore.";                m_log.error(msg);                throw new ServletException(msg);            }            m_signcerts = new X509Certificate[certs.length];            for (int i=0; i<certs.length; i++) {                if (!(certs[i] instanceof X509Certificate)) {                    final String msg = "Certificate (chain) from keytsore must be of type 'X509Certificate'.";                    m_log.error(msg);                    throw new ServletException(msg);                }                m_signcerts[i] = (X509Certificate)certs[i];            }            initparam = config.getInitParameter("responderID").trim();            if (null == initparam || initparam.length() <= 0) {                final String msg = "Required parameter 'responderID' not set.";                m_log.error(msg);                throw new ServletException(msg);            }            // Normalize DN in initparam            initparam = CertTools.stringToBCDNString(initparam);            m_responderIdx = findCertificateIndexBySubject(m_signcerts, initparam);            if (m_responderIdx < 0) {                final String msg = "Unable to find certificate for given responderID.";                m_log.error(msg);                throw new ServletException(msg);            }            // TODO: END of private signing key todo                        initparam = config.getInitParameter("enforceRequestSigning").trim();            if (m_log.isDebugEnabled()) {                m_log.debug("Enforce request signing : '"                             + (null == initparam || initparam.length() <= 0 ? "<not set>" : initparam)                            + "'");            }            m_reqMustBeSigned = true;            if (null != initparam && initparam.length() > 0) {                if (initparam.equalsIgnoreCase("false")                     || initparam.equalsIgnoreCase("no")) {                    m_reqMustBeSigned = false;                }            }        } catch(Exception e) {            m_log.error("Unable to initialize OCSPServlet.", e);            throw new ServletException(e);        }    }