/** * Creates a ReferralAuthHandler object to handle authentication when * following referrals in a LDAP connection, using the provided dn and * password. */ public ReferralAuthHandler(String dn, String password) { byte[] passwordBytes; try { // Convert password into corresponding byte array if (password != null) passwordBytes = password.getBytes("UTF-8"); else passwordBytes = null; } catch (UnsupportedEncodingException e) { logger.error("Unexpected lack of support for UTF-8: {}", e.getMessage()); logger.debug("Support for UTF-8 (as required by Java spec) not found.", e); throw new UnsupportedOperationException("Unexpected lack of UTF-8 support.", e); } ldapAuth = new LDAPAuthProvider(dn, passwordBytes); }
/** * Constructs information that is used by the client for authentication * when following referrals automatically. * * @see <a href="../../../../api/com/novell/ldap/LDAPAuthProvider.html#LDAPAuthProvider(java.lang.String, java.lang.String)"> com.novell.ldap.LDAPAuthProvider.LDAPAuthProvider( String, String)</a> */ public LDAPAuthProvider ( String dn, byte[] password ) { auth = new com.novell.ldap.LDAPAuthProvider( dn, password); return; }
@Override public LDAPAuthProvider getAuthProvider(String host, int port) { try { LOGGER.debug(MessageFormat.format("Looking for auth for referral to {0}:{1}", host, port)); return new LDAPAuthProvider(this.bindDN, this.bindPassword.getBytes("UTF8")); } catch (Exception e) { LOGGER.error(MessageFormat.format("Failed to create LDAPAuthProvider for referral {0}:{1}", host, port)); return null; } } }
/** * {@inheritDoc} * * @see com.novell.ldap.LDAPAuthHandler#getAuthProvider(java.lang.String, int) */ public LDAPAuthProvider getAuthProvider(String host, int port) { try { LOG.debug(MessageFormat.format("Looking for auth for referral to {0}:{1}", host, port)); return new LDAPAuthProvider(this.bindDN, this.bindPassword.getBytes("UTF8")); } catch (Exception e) { LOG.error(MessageFormat.format("Failed to create LDAPAuthProvider for referral {0}:{1}", host, port)); return null; } } }