}
private String bindUserObject(DirContext context, String cn)
throws Exception
{
Attributes attributes = new BasicAttributes(true);
BasicAttribute objectClass = new BasicAttribute("objectClass");
objectClass.add("top");
objectClass.add("inetOrgPerson");
objectClass.add("person");
objectClass.add("organizationalperson");
attributes.put(objectClass);
attributes.put("cn", cn);
attributes.put("sn", "foo");
attributes.put("mail", "foo");
//System.out.println("setting password to : " + LdapLoginModule.convertCredentialJettyToLdap( Credential.MD5.digest( "foo" ) ));
String pwd = Credential.MD5.digest( "foo" );
pwd = pwd.substring("MD5:".length(), pwd.length() );
//System.out.println(Credential.MD5.digest( "foo" ));
//System.out.println(pwd);
//System.out.println(Base64.encode( pwd.getBytes("ISO-8859-1") ));
//System.out.println(Base64.encode( pwd.getBytes("UTF-8") ));
attributes.put("userPassword", "{MD5}" + doStuff(pwd) );
//attributes.put( "userPassword", "foo");
attributes.put("givenName", "foo");
String dn = createDn(cn);
context.createSubcontext(dn, attributes );
return dn;
}