@Override
public Boolean checkLdapConnection( LdapConfiguration ldapConfiguration )
throws ArchivaRestServiceException
{
LdapConnection ldapConnection = null;
try
{
LdapConnectionConfiguration ldapConnectionConfiguration =
new LdapConnectionConfiguration( ldapConfiguration.getHostName(), ldapConfiguration.getPort(),
ldapConfiguration.getBaseDn(), ldapConfiguration.getContextFactory(),
ldapConfiguration.getBindDn(), ldapConfiguration.getPassword(),
ldapConfiguration.getAuthenticationMethod(),
toProperties( ldapConfiguration.getExtraProperties() ) );
ldapConnectionConfiguration.setSsl( ldapConfiguration.isSsl() );
ldapConnection = ldapConnectionFactory.getConnection( ldapConnectionConfiguration );
ldapConnection.close();
// verify groups dn value too
ldapConnectionConfiguration =
new LdapConnectionConfiguration( ldapConfiguration.getHostName(), ldapConfiguration.getPort(),
ldapConfiguration.getBaseGroupsDn(),
ldapConfiguration.getContextFactory(), ldapConfiguration.getBindDn(),
ldapConfiguration.getPassword(),
ldapConfiguration.getAuthenticationMethod(),
toProperties( ldapConfiguration.getExtraProperties() ) );
ldapConnectionConfiguration.setSsl( ldapConfiguration.isSsl() );
ldapConnection = ldapConnectionFactory.getConnection( ldapConnectionConfiguration );
}
catch ( InvalidNameException e )
{
log.warn( "fail to get ldapConnection: {}", e.getMessage(), e );
throw new ArchivaRestServiceException( e.getMessage(), e );
}
catch ( LdapException e )
{
log.warn( "fail to get ldapConnection: {}", e.getMessage(), e );
throw new ArchivaRestServiceException( e.getMessage(), e );
}
finally
{
if ( ldapConnection != null )
{
ldapConnection.close();
}
}
return Boolean.TRUE;
}