config.setLdapPort( ldapServer.getPort() );
config.setName( ServerDNConstants.ADMIN_SYSTEM_DN );
config.setCredentials( "secret" );
config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() );
LdapConnection myConnection = new LdapNetworkConnection( config );
// Remove the UserPassword from the list
( ( ConfigurableBinaryAttributeDetector ) config.getBinaryAttributeDetector() ).
removeBinaryAttribute( "userPassword" );
myConnection.bind( "uid=admin,ou=system", "secret" );
Entry entry = myConnection.lookup( "uid=admin,ou=system" );
assertTrue( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
// Now, load a new binary Attribute
( ( ConfigurableBinaryAttributeDetector ) config.getBinaryAttributeDetector() ).
addBinaryAttribute( "userPassword" );
entry = myConnection.lookup( "uid=admin,ou=system" );
assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
// Now, test using the scerver's schema
( ( LdapNetworkConnection ) connection ).loadSchema();
connection.bind( "uid=admin,ou=system", "secret" );
// Use the default list of binary Attributes
entry = connection.lookup( "uid=admin,ou=system" );
assertFalse( entry.get( SchemaConstants.USER_PASSWORD_AT ).get().isHumanReadable() );
myConnection.close();
}