dn = constructLDAPDN(CertTools.getSubjectDN((X509Certificate) cert));
certdn = CertTools.getSubjectDN((X509Certificate) cert); dn = constructLDAPDN(certdn);
	public void revokeCertificate(Admin admin, Certificate cert, int reason) throws PublisherException{        log.debug(">revokeCertificate()");        int ldapVersion = LDAPConnection.LDAP_V3;        LDAPConnection lc = null;        if(getUseSSL()){          lc = new LDAPConnection(new LDAPJSSESecureSocketFactory());        }else{          lc = new LDAPConnection();                }        String dn = null;        try {            // Extract the users DN from the cert.            dn = constructLDAPDN(CertTools.getSubjectDN((X509Certificate) cert));        } catch (Exception e) {            log.error("Error decoding input certificate: ", e);                        throw new PublisherException("Error decoding input certificate.");                    }        // Check if the entry is already present, we will update it with the new certificate.        LDAPEntry oldEntry = null;        try {            // connect to the server            lc.connect(getHostname(), Integer.parseInt(getPort()));            // authenticate to the server            lc.bind(ldapVersion, getLoginDN(), getLoginPassword());            // try to read the old object            oldEntry = lc.read(dn);            // disconnect with the server            lc.disconnect();        } catch (LDAPException e) {            if (e.getLDAPResultCode() == LDAPException.NO_SUCH_OBJECT) {                log.debug("No old entry exist for '" + dn + "'.");                            } else {                log.error("Error binding to and reading from LDAP server: ", e);                throw new PublisherException("Error binding to and reading from LDAP server.");                                            }        }                LDAPModificationSet modSet = null;                                        if (((X509Certificate) cert).getBasicConstraints() == -1) {            log.debug("Removing end user certificate from " + getHostname());            if (oldEntry != null) {            	                // TODO: Are we the correct type objectclass?                modSet = getModificationSet(oldEntry, dn, false, true);                modSet.add(LDAPModification.DELETE, new LDAPAttribute(getUserCertAttribute()));            }else{                log.error("Certificate doesn't exist in database");                            throw new PublisherException("Certificate doesn't exist in database");                        }        } else  {            log.debug("Not removing CA certificate from " + getHostname() + "Because of object class restrictions.");            // Currently removal of CA certificate isn't support because of object class restictions            /*            if (oldEntry != null) {                modSet = getModificationSet(oldEntry, dn, false, false);                modSet.add(LDAPModification.DELETE, new LDAPAttribute(getCACertAttribute()));            } else {                log.error("Certificate doesn't exist in database");                            throw new PublisherException("Certificate doesn't exist in database");                        }*/        }        try {                    lc.connect(getHostname(), Integer.parseInt(getPort()));            // authenticate to the server            lc.bind(ldapVersion, getLoginDN(), getLoginPassword());                        // Add or modify the entry            if (oldEntry != null && modSet != null && getModifyExistingUsers()) {                lc.modify(dn, modSet);                log.debug("\nRemoved certificate : " + dn + " successfully.");              }                           // disconnect with the server            lc.disconnect();        } catch (LDAPException e) {            log.error("Error when removing certificate from LDAP (" + dn + "): ", e);              throw new PublisherException("Error when removing certificate from LDAP (" + dn + ")");                    }        log.debug("<revokeCertificate()");	}