if(cert!= null){
if(cert!= null && cert instanceof X509Certificate){
    protected LDAPAttributeSet getAttributeSet(X509Certificate cert, String objectclass, String dn, boolean extra, boolean person) {    	log.debug("ADPublisher : getAttributeSet");        LDAPAttributeSet attributeSet = super.getAttributeSet(objectclass, dn, extra, person);        String cn = CertTools.getPartFromDN(dn, "CN");        // Add AD specific attributes        attributeSet.add(new LDAPAttribute("userAccountControl", Integer.toString(getUserAccountControl())));                if(cert!= null){          String upn = null;		try {			upn = CertTools.getUPNAltName(cert);		} catch (CertificateParsingException e) {}		  catch (IOException e) {}		String samaccountname = upn;		if(upn != null && upn.indexOf('@') != -1){		  // only use name part of UPN.			samaccountname = samaccountname.substring(upn.indexOf('@'));			}				          switch(getSAMAccountName()){        	case DNFieldExtractor.CN:              samaccountname = cn;                 break;            case DNFieldExtractor.UID:                samaccountname = CertTools.getPartFromDN(dn, "UID");                 break;        	          }          if(samaccountname !=null){            attributeSet.add(new LDAPAttribute("samaccountname", samaccountname));          }                    if(upn != null)          	attributeSet.add(new LDAPAttribute("userPrincipalName", upn));              else          	attributeSet.add(new LDAPAttribute("userPrincipalName", cn));        }        attributeSet.add(new LDAPAttribute("displayName", cn));        attributeSet.add(new LDAPAttribute("description", getUserDescription()));                if(getUseSSL() && getUseUserPassword()){        	// TODO fix better        	String password = "foo123";           //Can only set password through SSL connection        	//attributeSet.add(new LDAPAttribute("userPassword", password));	                    //Start out by taking the password and enclosing it in quotes, as in            String newVal = new String("\"" + password + "\"");          //Then, you need to get the octet string of the Unicode representation of          //that.  You need to leave off the extra two bytes Java uses as length:                        byte _bytes[] = null;			try {				_bytes = newVal.getBytes("Unicode");			} catch (UnsupportedEncodingException e) {}			byte bytes[] = new byte[_bytes.length - 2];            System.arraycopy(_bytes, 2, bytes, 0, _bytes.length - 2);          //Take that value and stuff it into the unicodePwd attribute:                      attributeSet.add(new LDAPAttribute("unicodePwd", bytes));                                     }                                  return attributeSet;    } // getAttributeSet