log.debug("\nAdded object: " + dn + " successfully.");
log.debug("Added object: " + dn + " successfully.");
	public boolean storeCRL(Admin admin, byte[] incrl, String cafp, int number) throws PublisherException{        int ldapVersion = LDAPConnection.LDAP_V3;        LDAPConnection lc = null;        if(getUseSSL()){          lc = new LDAPConnection(new LDAPJSSESecureSocketFactory());        }else{          lc = new LDAPConnection();                }        X509CRL crl = null;        String dn = null;        String crldn = null;        try {            // Extract the users DN from the crl.            crl = CertTools.getCRLfromByteArray(incrl);        	crldn = CertTools.getIssuerDN(crl);            dn = constructLDAPDN(CertTools.getIssuerDN(crl));        } catch (Exception e) {        	log.error("Error decoding input CRL: ", e);        	        	throw new PublisherException("Error decoding input CRL.");                    }        // 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().getBytes("UTF8"));            // try to read the old object            oldEntry = lc.read(dn);        } catch (LDAPException e) {            if (e.getResultCode() == 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.");                            }        } catch (UnsupportedEncodingException e) {            log.error("Can't decode password for LDAP login: "+getLoginPassword(), e);            throw new PublisherException("Can't decode password for LDAP login: "+getLoginPassword());                    } finally {			// disconnect with the server			try {				lc.disconnect();			} catch (LDAPException e) {				log.error("LdapPublisher: LDAP disconnection failed: ", e);			}		}        LDAPEntry newEntry = null;        ArrayList modSet = new ArrayList();        LDAPAttributeSet attributeSet = null;        if (oldEntry != null) {            modSet = getModificationSet(oldEntry, crldn, false, false);        } else {            attributeSet = getAttributeSet(null, this.getCAObjectClass(), crldn, true, false, null,null);        }        try {            LDAPAttribute crlAttr = new LDAPAttribute(getCRLAttribute(), crl.getEncoded());            LDAPAttribute arlAttr = new LDAPAttribute(getARLAttribute(), crl.getEncoded());            if (oldEntry != null) {                modSet.add(new LDAPModification(LDAPModification.REPLACE, crlAttr));                modSet.add(new LDAPModification(LDAPModification.REPLACE, arlAttr));            } else {                attributeSet.add(crlAttr);                attributeSet.add(arlAttr);            }        } catch (CRLException e) {            log.error("Error encoding CRL when storing in LDAP: ", e);            throw new PublisherException("Error encoding CRL when storing in LDAP.");                    }        if (oldEntry == null) {            newEntry = new LDAPEntry(dn, attributeSet);        }        try {            // connect to the server            lc.connect(getHostname(), Integer.parseInt(getPort()));            // authenticate to the server            lc.bind(ldapVersion, getLoginDN(), getLoginPassword().getBytes("UTF8"));            // Add or modify the entry            if (oldEntry != null) {                LDAPModification[] mods = new LDAPModification[modSet.size()];                 mods = (LDAPModification[])modSet.toArray(mods);                lc.modify(dn, mods);                log.debug("\nModified object: " + dn + " successfully.");            } else {                lc.add(newEntry);                log.debug("\nAdded object: " + dn + " successfully.");                            }        } catch (LDAPException e) {            log.error("Error storing CRL (" + getCRLAttribute() + ") in LDAP (" + getCAObjectClass() + "): ", e);            throw new PublisherException("Error storing CRL (" + getCRLAttribute() + ") in LDAP (" + getCAObjectClass() + "): ");                                } catch (UnsupportedEncodingException e) {            log.error("Can't decode password for LDAP login: "+getLoginPassword(), e);            throw new PublisherException("Can't decode password when storing (" + getCRLAttribute() + ") in LDAP (" + getCAObjectClass() + ") for DN (" + dn + ").");                    } finally {			// disconnect with the server			try {				lc.disconnect();			} catch (LDAPException e) {				log.error("LdapPublisher: LDAP disconnection failed: ", e);			}		}        return true;    }