55 private static final String SASL_AUTHZ_ID = 56 "java.naming.security.sasl.authorizationId"; 57 private static final String SASL_REALM = 58 "java.naming.security.sasl.realm"; 59 60 private static final int LDAP_SUCCESS = 0; 61 private static final int LDAP_SASL_BIND_IN_PROGRESS = 14; // LDAPv3 62 63 private LdapSasl() { 64 } 65 66 /** 67 * Performs SASL bind. 68 * Creates a SaslClient by using a default CallbackHandler 69 * that uses the Context.SECURITY_PRINCIPAL and Context.SECURITY_CREDENTIALS 70 * properties to satisfy the callbacks, and by using the 71 * SASL_AUTHZ_ID property as the authorization id. If the SASL_AUTHZ_ID 72 * property has not been set, Context.SECURITY_PRINCIPAL is used. 73 * If SASL_CALLBACK has been set, use that instead of the default 74 * CallbackHandler. 75 *<p> 76 * If bind is successful and the selected SASL mechanism has a security 77 * layer, set inStream and outStream to be filter streams that use 78 * the security layer. These will be used for subsequent communication 79 * with the server. 80 *<p> 81 * @param conn The non-null connection to use for sending an LDAP BIND 82 * @param server Non-null string name of host to connect to 83 * @param dn Non-null DN to bind as; also used as authentication ID 84 * @param pw Possibly null password; can be byte[], char[] or String 85 * @param authMech A non-null space-separated list of SASL authentication 86 * mechanisms. 87 * @param env The possibly null environment of the context, possibly containing 88 * properties for used by SASL mechanisms 89 * @param bindCtls The possibly null controls to accompany the bind 90 * @return LdapResult containing status of the bind 91 */ 92 @SuppressWarnings("unchecked") 93 public static LdapResult saslBind(LdapClient clnt, Connection conn, 94 String server, String dn, Object pw, 95 String authMech, Hashtable<?,?> env, Control[] bindCtls) 96 throws IOException, NamingException { 97 98 SaslClient saslClnt = null; 99 boolean cleanupHandler = false; 100 | 55 private static final String SASL_AUTHZ_ID = 56 "java.naming.security.sasl.authorizationId"; 57 private static final String SASL_REALM = 58 "java.naming.security.sasl.realm"; 59 60 private static final int LDAP_SUCCESS = 0; 61 private static final int LDAP_SASL_BIND_IN_PROGRESS = 14; // LDAPv3 62 63 private LdapSasl() { 64 } 65 66 /** 67 * Performs SASL bind. 68 * Creates a SaslClient by using a default CallbackHandler 69 * that uses the Context.SECURITY_PRINCIPAL and Context.SECURITY_CREDENTIALS 70 * properties to satisfy the callbacks, and by using the 71 * SASL_AUTHZ_ID property as the authorization id. If the SASL_AUTHZ_ID 72 * property has not been set, Context.SECURITY_PRINCIPAL is used. 73 * If SASL_CALLBACK has been set, use that instead of the default 74 * CallbackHandler. 75 * <p> 76 * If bind is successful and the selected SASL mechanism has a security 77 * layer, set inStream and outStream to be filter streams that use 78 * the security layer. These will be used for subsequent communication 79 * with the server. 80 * 81 * @param conn The non-null connection to use for sending an LDAP BIND 82 * @param server Non-null string name of host to connect to 83 * @param dn Non-null DN to bind as; also used as authentication ID 84 * @param pw Possibly null password; can be byte[], char[] or String 85 * @param authMech A non-null space-separated list of SASL authentication 86 * mechanisms. 87 * @param env The possibly null environment of the context, possibly containing 88 * properties for used by SASL mechanisms 89 * @param bindCtls The possibly null controls to accompany the bind 90 * @return LdapResult containing status of the bind 91 */ 92 @SuppressWarnings("unchecked") 93 public static LdapResult saslBind(LdapClient clnt, Connection conn, 94 String server, String dn, Object pw, 95 String authMech, Hashtable<?,?> env, Control[] bindCtls) 96 throws IOException, NamingException { 97 98 SaslClient saslClnt = null; 99 boolean cleanupHandler = false; 100 |