/* get UTF-16 string */
public String getUTFString(String rawString)
throws UnsupportedEncodingException {
byte[] bytes = getEncodeString(String rawString);
return new String(bytes,0,bytes.length(),"UTF-16");
}
/* UTF-16 bytes */
public byte[] getEncodeBytes(String rawString)
throws UnsupportedEncodingException {
Charset cset = Charset.forName("UTF-16");
ByteBuffer buf = cset.encode(rawString);
return buf.array();
}
/* Does LDAP Binding for authentication */
public Context getContext(String ldapurl,
String utf_uid, String utf_pass) throws NamingException {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapurl);
env.put(Context.SECURITY_PRINCIPAL, utf_uid);
env.put(Context.SECURITY_CREDENTIALS, utf_pass);
return new InitialDirContext(env);
}
Please note that Solaris Enterprise System
DS does the Cipher oneway hash, Client does
not do anything else by UTF-8 encoding.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment