log.error("Error authenticating: ",e);
    public void authenticate(X509Certificate certificate)        throws AuthenticationFailedException {        // Check Validity        try {            certificate.checkValidity();        } catch (Exception e) {            throw new AuthenticationFailedException("Your certificates vality has expired.");        }        // Vertify Signature        boolean verified = false;        for (int i = 0; i < this.cacertificatechain.length; i++) {            try {//            System.out.println("EjbcaAuthorization: authenticate : Comparing : "  + CertTools.getIssuerDN(certificate) + " With " + CertTools.getSubjectDN((X509Certificate) cacertificatechain[i]));//            if(LDAPDN.equals(CertTools.getIssuerDN(certificate), CertTools.getSubjectDN((X509Certificate) cacertificatechain[i]))){                certificate.verify(cacertificatechain[i].getPublicKey());                verified = true;//            }            } catch (Exception e) {            }        }        if (!verified) {            throw new AuthenticationFailedException(                "Your certificate cannot be verified by CA certificate chain.");        }        // Check if certificate is revoked.        try {            if (certificatesession.isRevoked(admin, CertTools.getIssuerDN(certificate),                        certificate.getSerialNumber()) != null) {                // Certificate revoked                throw new AuthenticationFailedException("Your certificate have been revoked.");            }        } catch (RemoteException e) {            throw new AuthenticationFailedException("Your certificate cannot be found in database.");        }    }