cat.error("Cannot load key with alias '"+privateKeyAlias+"' from keystore '"+keyStoreFile+"'");
log.error("Cannot load key with alias '"+privateKeyAlias+"' from keystore '"+keyStoreFile+"'");
    protected PKCS12SigningDevice(Properties p) throws Exception {        cat.debug(">PKCS12SigningDevice()");        // Get env variables and read in nessecary data        KeyStore keyStore=KeyStore.getInstance("PKCS12", "BC");        String keyStoreFile = p.getProperty("keyStore");        if (keyStoreFile == null)            throw new IllegalArgumentException("Missing keyStore property.");        cat.debug("keystore:" + keyStoreFile);        InputStream is = new FileInputStream(keyStoreFile);        String keyStorePass = p.getProperty("keyStorePass");        if (keyStorePass == null)            throw new IllegalArgumentException("Missing keyStorePass property.");        //char[] keyStorePass = getPassword("java:comp/env/keyStorePass");        cat.debug("keystorepass: " + keyStorePass);        keyStore.load(is, keyStorePass.toCharArray());        String privateKeyAlias= p.getProperty("privateKeyAlias");        if (privateKeyAlias == null)            throw new IllegalArgumentException("Missing privateKeyAlias property.");        cat.debug("privateKeyAlias: " + privateKeyAlias);        String privateKeyPass = p.getProperty("privateKeyPass");        char[] pkPass;        if ((privateKeyPass).equals("null"))            pkPass = null;        else            pkPass = privateKeyPass.toCharArray();        cat.debug("privateKeyPass: " + privateKeyPass);        privateKey = (PrivateKey)keyStore.getKey(privateKeyAlias, pkPass);        if (privateKey == null) {            cat.error("Cannot load key with alias '"+privateKeyAlias+"' from keystore '"+keyStoreFile+"'");            throw new Exception("Cannot load key with alias '"+privateKeyAlias+"' from keystore '"+keyStoreFile+"'");        }        Certificate[] certchain = KeyTools.getCertChain(keyStore, privateKeyAlias);        if (certchain.length < 1) {            cat.error("Cannot load certificate chain with alias '"+privateKeyAlias+"' from keystore '"+keyStoreFile+"'");            throw new Exception("Cannot load certificate chain with alias '"+privateKeyAlias+"' from keystore '"+keyStoreFile+"'");        }        // We only support a ca hierarchy with depth 2.        caCert = (X509Certificate)certchain[0];        cat.debug("cacertIssuer: " + caCert.getIssuerDN().toString());        cat.debug("cacertSubject: " + caCert.getSubjectDN().toString());        // root cert is last cert in chain        rootCert = (X509Certificate)certchain[certchain.length-1];        cat.debug("rootcertIssuer: " + rootCert.getIssuerDN().toString());        cat.debug("rootcertSubject: " + rootCert.getSubjectDN().toString());        // is root cert selfsigned?        if (!CertTools.isSelfSigned(rootCert))            throw new Exception("Root certificate is not self signed!");        cat.debug("<PKCS12SigningDevice()");    }