directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1732068 [1/3] - in /directory/apacheds/trunk: core-annotations/src/main/java/org/apache/directory/server/core/factory/ core-integ/src/main/java/org/apache/directory/server/core/integ/ core-integ/src/test/java/org/apache/directory/server/co...
Date Wed, 24 Feb 2016 10:50:13 GMT
Author: seelmann
Date: Wed Feb 24 10:50:12 2016
New Revision: 1732068

URL: http://svn.apache.org/viewvc?rev=1732068&view=rev
Log:
Use loopback address to avoid DNS lookup

Modified:
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
    directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.java
    directory/apacheds/trunk/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConfig.java
    directory/apacheds/trunk/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConnection.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/KerberosUtilsTest.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncKrbCredPartDecoderTest.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncTicketPartDecoderTest.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbCredInfoDecoderTest.java
    directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
    directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/ldap/client/template/LdapConnectionTemplateTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionPoolTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LightweightLdapConnectionPoolTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ConcurrentSearchAndUnbindTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
    directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/perf/TestClientApiPerf.java
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java
    directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java
    directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/changepwd/service/ChangePasswordService.java
    directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java
    directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java
    directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/DirectoryServiceAnnotationTest.java
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/TransportBean.java
    directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
    directory/apacheds/trunk/server-integ/src/test/java/MultiThreadedReadWriteTest.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddPerfIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthOverSslIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/DelegatedAuthOverTlsIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/AddIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/BindIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/ldapsdk/CompareIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyAddIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PagedSearchIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/PersistentSearchIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SearchPerfIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/SortedSearchIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ppolicy/PasswordPolicyIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/ClientInitialRefreshIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/replication/StaleEventLogDetectionIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsUpdateCertificateIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsConfidentialityIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsUpdateCertificateIT.java
    directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/UberjarMain.java
    directory/apacheds/trunk/service/src/test/java/org/apache/directory/server/UberJarMainTest.java
    directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/CreateLdapConnectionPoolRule.java
    directory/apacheds/trunk/test-framework/src/test/java/org/apache/directory/server/core/integ/TestCreateLdapServerRule.java

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java (original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java Wed Feb 24 10:50:12 2016
@@ -23,7 +23,6 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.lang.reflect.Constructor;
-import java.net.InetAddress;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -35,6 +34,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.ldif.LdifReader;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.server.core.annotations.AnnotationUtils;
 import org.apache.directory.server.core.annotations.ApplyLdifFiles;
@@ -136,7 +136,7 @@ public final class DSAnnotationProcessor
                     
                     if ( Strings.isEmpty( host ) )
                     {
-                        host = InetAddress.getLocalHost().getHostName();
+                        host = Network.LOOPBACK_HOSTNAME;
                     }
                     
                     dauth.setDelegateHost( host );

Modified: directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java (original)
+++ directory/apacheds/trunk/core-integ/src/main/java/org/apache/directory/server/core/integ/IntegrationUtils.java Wed Feb 24 10:50:12 2016
@@ -21,7 +21,6 @@ package org.apache.directory.server.core
 
 import java.io.File;
 import java.io.IOException;
-import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -45,6 +44,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.name.Rdn;
 import org.apache.directory.api.ldap.model.schema.registries.Schema;
 import org.apache.directory.api.util.FileUtils;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.constants.ServerDNConstants;
@@ -442,7 +442,7 @@ public class IntegrationUtils
      */
     public static LdapConnection getAnonymousNetworkConnection( LdapServer ldapServer ) throws Exception
     {
-        LdapConnection connection = getAnonymousNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
+        LdapConnection connection = getAnonymousNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() );
 
         return connection;
     }
@@ -475,7 +475,7 @@ public class IntegrationUtils
      */
     public static LdapConnection getAdminNetworkConnection( LdapServer ldapServer ) throws Exception
     {
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() );
 
         connection.setTimeOut( 0 );
         connection.bind( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" );
@@ -499,7 +499,7 @@ public class IntegrationUtils
     public static LdapConnection getNetworkConnectionAs( LdapServer ldapServer, String userDn, String password )
         throws Exception
     {
-        return getNetworkConnectionAs( InetAddress.getLocalHost().getHostName(), ldapServer.getPort(), userDn, password );
+        return getNetworkConnectionAs( Network.LOOPBACK_HOSTNAME, ldapServer.getPort(), userDn, password );
     }
 
 

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/api/LdapCoreSessionConnectionTest.java Wed Feb 24 10:50:12 2016
@@ -22,9 +22,6 @@ package org.apache.directory.server.core
 
 import static org.junit.Assert.assertNotNull;
 
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
 import org.apache.directory.api.ldap.codec.api.LdapApiService;
 import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
 import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy;
@@ -36,6 +33,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.message.BindResponse;
 import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -108,7 +106,7 @@ public class LdapCoreSessionConnectionTe
         LdapNetworkConnection connection = null;
         try
         {
-            connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+            connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
 
             BindRequest bindRequest = new BindRequestImpl();
             bindRequest.setDn( new Dn( "cn=user,ou=system" ) );
@@ -121,10 +119,6 @@ public class LdapCoreSessionConnectionTe
             PasswordPolicy passwordPolicy = ( ( PasswordPolicyDecorator ) responseControl ).getDecorated();
             assertNotNull( passwordPolicy );
         }
-        catch ( UnknownHostException uhe )
-        {
-            // Nothing we can do
-        }
         finally
         {
             safeClose( connection );

Modified: directory/apacheds/trunk/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConfig.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConfig.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConfig.java (original)
+++ directory/apacheds/trunk/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConfig.java Wed Feb 24 10:50:12 2016
@@ -25,11 +25,10 @@ import static org.apache.directory.share
 import static org.apache.directory.shared.kerberos.codec.types.EncryptionType.DES3_CBC_SHA1_KD;
 import static org.apache.directory.shared.kerberos.codec.types.EncryptionType.DES_CBC_MD5;
 
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.util.HashSet;
 import java.util.Set;
 
+import org.apache.directory.api.util.Network;
 import org.apache.directory.shared.kerberos.KerberosUtils;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
 
@@ -79,14 +78,7 @@ public class KdcConfig
         
         encryptionTypes = KerberosUtils.orderEtypesByStrength( encryptionTypes );
         
-        try
-        {
-            hostName = InetAddress.getLocalHost().getHostName();
-        }
-        catch ( UnknownHostException uhe )
-        {
-            hostName = "localhost";
-        }
+        hostName = Network.LOOPBACK_HOSTNAME;
     }
 
 

Modified: directory/apacheds/trunk/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConnection.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConnection.java (original)
+++ directory/apacheds/trunk/kerberos-client/src/main/java/org/apache/directory/kerberos/client/KdcConnection.java Wed Feb 24 10:50:12 2016
@@ -21,7 +21,6 @@ package org.apache.directory.kerberos.cl
 
 
 import java.io.IOException;
-import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.security.SecureRandom;
 import java.text.ParseException;
@@ -31,6 +30,7 @@ import javax.security.auth.kerberos.Kerb
 
 import org.apache.directory.api.asn1.Asn1Object;
 import org.apache.directory.api.asn1.ber.Asn1Decoder;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.server.kerberos.changepwd.exceptions.ChangePasswdErrorType;
 import org.apache.directory.server.kerberos.changepwd.exceptions.ChangePasswordException;
@@ -558,7 +558,7 @@ public class KdcConnection
             KrbPriv privateMessage = new KrbPriv();
             
             EncKrbPrivPart part = new EncKrbPrivPart();
-            part.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
+            part.setSenderAddress( new HostAddress( Network.LOOPBACK ) );
             part.setSeqNumber( authenticator.getSeqNumber() );
             part.setTimestamp( authenticator.getCtime() );
 

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/KerberosUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/KerberosUtilsTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/KerberosUtilsTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/server/kerberos/shared/KerberosUtilsTest.java Wed Feb 24 10:50:12 2016
@@ -22,7 +22,6 @@ package org.apache.directory.server.kerb
 
 import static org.junit.Assert.assertEquals;
 
-import java.net.InetAddress;
 import java.util.List;
 
 import javax.security.auth.kerberos.KerberosPrincipal;
@@ -33,6 +32,7 @@ import com.mycila.junit.concurrent.Concu
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.shared.kerberos.KerberosUtils;
 
 
@@ -50,7 +50,7 @@ public class KerberosUtilsTest
     {
         // First setup a default realm
         System.setProperty( "java.security.krb5.realm", "APACHE.ORG" );
-        System.setProperty( "java.security.krb5.kdc", InetAddress.getLocalHost().getHostName() );
+        System.setProperty( "java.security.krb5.kdc", Network.LOOPBACK_HOSTNAME );
     }
 
 

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncKrbCredPartDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncKrbCredPartDecoderTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncKrbCredPartDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncKrbCredPartDecoderTest.java Wed Feb 24 10:50:12 2016
@@ -24,7 +24,6 @@ package org.apache.directory.shared.kerb
 import static org.junit.Assert.assertTrue;
 
 import java.lang.reflect.Field;
-import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Date;
@@ -34,6 +33,7 @@ import java.util.Map;
 
 import org.apache.directory.api.asn1.DecoderException;
 import org.apache.directory.api.asn1.ber.Asn1Decoder;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.shared.kerberos.KerberosTime;
 import org.apache.directory.shared.kerberos.codec.encKrbCredPart.EncKrbCredPartContainer;
@@ -108,10 +108,10 @@ public class EncKrbCredPartDecoderTest
         usec = 1;
         optionalFieldValueList.add( new FieldValueHolder( "usec", usec ) );
 
-        senderAddress = new HostAddress( InetAddress.getLocalHost() );
+        senderAddress = new HostAddress( Network.LOOPBACK );
         optionalFieldValueList.add( new FieldValueHolder( "senderAddress", senderAddress ) );
 
-        recipientAddress = new HostAddress( InetAddress.getLocalHost() );
+        recipientAddress = new HostAddress( Network.LOOPBACK );
         optionalFieldValueList.add( new FieldValueHolder( "recipientAddress", recipientAddress ) );
     }
 

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncTicketPartDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncTicketPartDecoderTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncTicketPartDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncTicketPartDecoderTest.java Wed Feb 24 10:50:12 2016
@@ -24,13 +24,13 @@ package org.apache.directory.shared.kerb
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
-import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.util.Date;
 
 import org.apache.directory.api.asn1.DecoderException;
 import org.apache.directory.api.asn1.EncoderException;
 import org.apache.directory.api.asn1.ber.Asn1Decoder;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.shared.kerberos.KerberosTime;
 import org.apache.directory.shared.kerberos.codec.encTicketPart.EncTicketPartContainer;
 import org.apache.directory.shared.kerberos.codec.types.AuthorizationType;
@@ -89,7 +89,7 @@ public class EncTicketPartDecoderTest
         KerberosTime renewtill = new KerberosTime( time );
 
         HostAddresses caddr = new HostAddresses( new HostAddress[]
-            { new HostAddress( InetAddress.getLocalHost() ) } );
+            { new HostAddress( Network.LOOPBACK ) } );
 
         AuthorizationData authzData = new AuthorizationData();
         authzData.createNewAD();

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbCredInfoDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbCredInfoDecoderTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbCredInfoDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/KrbCredInfoDecoderTest.java Wed Feb 24 10:50:12 2016
@@ -24,7 +24,6 @@ package org.apache.directory.shared.kerb
 import static org.junit.Assert.assertTrue;
 
 import java.lang.reflect.Field;
-import java.net.InetAddress;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Date;
@@ -34,6 +33,7 @@ import java.util.Map;
 
 import org.apache.directory.api.asn1.DecoderException;
 import org.apache.directory.api.asn1.ber.Asn1Decoder;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.shared.kerberos.KerberosTime;
 import org.apache.directory.shared.kerberos.codec.krbCredInfo.KrbCredInfoContainer;
@@ -133,7 +133,7 @@ public class KrbCredInfoDecoderTest
         optionalFieldValueList.add( new FieldValueHolder( "sName", sName ) );
 
         clientAddresses = new HostAddresses( new HostAddress[]
-            { new HostAddress( InetAddress.getLocalHost() ) } );
+            { new HostAddress( Network.LOOPBACK ) } );
         optionalFieldValueList.add( new FieldValueHolder( "clientAddresses", clientAddresses ) );
     }
 

Modified: directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java (original)
+++ directory/apacheds/trunk/kerberos-test/src/test/java/org/apache/directory/server/kerberos/kdc/KerberosTestUtils.java Wed Feb 24 10:50:12 2016
@@ -26,8 +26,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.security.PrivilegedAction;
 
 import javax.security.auth.Subject;
@@ -45,6 +43,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.message.ModifyRequest;
 import org.apache.directory.api.ldap.model.message.ModifyRequestImpl;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.ldap.client.api.Krb5LoginConfiguration;
 import org.apache.directory.server.i18n.I18n;
@@ -252,18 +251,7 @@ public class KerberosTestUtils
      */
     public static String getHostName()
     {
-        String hostName;
-        try
-        {
-            InetAddress loopback = InetAddress.getLocalHost();
-            hostName = loopback.getCanonicalHostName();
-        }
-        catch ( UnknownHostException e )
-        {
-            System.err.println( "Can't find loopback address '127.0.0.1', using hostname 'localhost'" );
-            hostName = "localhost";
-        }
-        return hostName;
+        return Network.LOOPBACK_HOSTNAME;
     }
 
 

Modified: directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/main/java/org/apache/directory/shared/client/api/LdapApiIntegrationUtils.java Wed Feb 24 10:50:12 2016
@@ -20,13 +20,12 @@ package org.apache.directory.shared.clie
 
 
 import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.directory.api.ldap.codec.api.SchemaBinaryAttributeDetector;
 import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.DefaultPoolableLdapConnectionFactory;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapConnectionConfig;
@@ -71,7 +70,7 @@ public final class LdapApiIntegrationUti
     public static LdapNetworkConnection createAdminConnection( LdapServer ldapServer ) throws LdapException,
         IOException
     {
-        LdapNetworkConnection conn = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
+        LdapNetworkConnection conn = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() );
         conn.bind( DEFAULT_ADMIN, DEFAULT_PASSWORD );
         return conn;
     }
@@ -141,16 +140,7 @@ public final class LdapApiIntegrationUti
         if ( !POOLS.containsKey( port ) )
         {
             LdapConnectionConfig config = new LdapConnectionConfig();
-            
-            try
-            {
-                config.setLdapHost( InetAddress.getLocalHost().getHostName() );
-            }
-            catch ( UnknownHostException uhe )
-            {
-                config.setLdapHost( DEFAULT_HOST );
-            }
-            
+            config.setLdapHost( Network.LOOPBACK_HOSTNAME );
             config.setLdapPort( port );
             config.setName( DEFAULT_ADMIN );
             config.setCredentials( DEFAULT_PASSWORD );
@@ -189,7 +179,7 @@ public final class LdapApiIntegrationUti
      */
     public static LdapConnection getAnonymousNetworkConnection( LdapServer ldapServer ) throws Exception
     {
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() );
         connection.setTimeOut( 0L );
         connection.bind();
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/ldap/client/template/LdapConnectionTemplateTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/ldap/client/template/LdapConnectionTemplateTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/ldap/client/template/LdapConnectionTemplateTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/ldap/client/template/LdapConnectionTemplateTest.java Wed Feb 24 10:50:12 2016
@@ -30,13 +30,8 @@ import static org.apache.directory.ldap.
 import static org.apache.directory.ldap.client.api.search.FilterBuilder.endsWith;
 import static org.apache.directory.ldap.client.api.search.FilterBuilder.startsWith;
 
-
-
-import java.net.InetAddress;
 import java.util.List;
 
-
-
 import org.apache.commons.pool.impl.GenericObjectPool;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.exception.LdapException;
@@ -47,6 +42,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.ldap.model.message.SearchScope;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.DefaultLdapConnectionFactory;
 import org.apache.directory.ldap.client.api.LdapConnectionConfig;
 import org.apache.directory.ldap.client.api.LdapConnectionPool;
@@ -366,7 +362,7 @@ public class LdapConnectionTemplateTest
     {
         // test requested by https://issues.apache.org/jira/browse/DIRAPI-202
         LdapConnectionConfig config = new LdapConnectionConfig();
-        config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        config.setLdapHost( Network.LOOPBACK_HOSTNAME );
         config.setLdapPort( createLdapConnectionPoolRule.getLdapServer().getPort() );
         config.setName( "uid=admin,ou=system" );
         config.setCredentials( "secret" );

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionPoolTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionPoolTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionPoolTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionPoolTest.java Wed Feb 24 10:50:12 2016
@@ -22,13 +22,13 @@ package org.apache.directory.shared.clie
 
 import static org.junit.Assert.assertNotNull;
 
-import java.net.InetAddress;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.pool.PoolableObjectFactory;
 import org.apache.commons.pool.impl.GenericObjectPool;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapConnectionConfig;
 import org.apache.directory.ldap.client.api.LdapConnectionPool;
@@ -110,7 +110,7 @@ public class LdapConnectionPoolTest exte
         int port = getLdapServer().getPort();
 
         LdapConnectionConfig config = new LdapConnectionConfig();
-        config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        config.setLdapHost( Network.LOOPBACK_HOSTNAME );
         config.setLdapPort( port );
         config.setName( DEFAULT_ADMIN );
         config.setCredentials( DEFAULT_PASSWORD );
@@ -232,7 +232,7 @@ public class LdapConnectionPoolTest exte
     public void testSmallPool() throws Exception
     {
         LdapConnectionConfig config = new LdapConnectionConfig();
-        config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        config.setLdapHost( Network.LOOPBACK_HOSTNAME );
         config.setLdapPort( getLdapServer().getPort() );
         config.setName( DEFAULT_ADMIN );
         config.setCredentials( DEFAULT_PASSWORD );

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapConnectionTest.java Wed Feb 24 10:50:12 2016
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
-import java.net.InetAddress;
 import java.util.HashMap;
 import java.util.List;
 
@@ -41,6 +40,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.filter.EqualityNode;
 import org.apache.directory.api.ldap.model.message.SearchScope;
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapConnectionConfig;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
@@ -95,7 +95,7 @@ public class LdapConnectionTest extends
     @Test
     public void testBindRequest() throws Exception
     {
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
         try
         {
             connection.bind( ADMIN_DN, "secret" );
@@ -116,7 +116,7 @@ public class LdapConnectionTest extends
     @Ignore
     public void testRebindNoPool() throws Exception
     {
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
         connection.bind( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" );
 
         for ( int i = 0; i < 10000; i++ )
@@ -224,7 +224,7 @@ public void testLookup() throws Exceptio
     {
         // test with a local connection using a local BinaryAttributeDetector
         LdapConnectionConfig config = new LdapConnectionConfig();
-        config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        config.setLdapHost( Network.LOOPBACK_HOSTNAME );
         config.setLdapPort( ldapServer.getPort() );
         config.setName( ServerDNConstants.ADMIN_SYSTEM_DN );
         config.setCredentials( "secret" );
@@ -297,7 +297,7 @@ public void testLookup() throws Exceptio
     public void testAnonBind() throws Exception
     {
         getLdapServer().getDirectoryService().setAllowAnonymousAccess( true );
-        LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        LdapNetworkConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
 
         connection.bind();
         assertTrue( connection.isAuthenticated() );
@@ -313,7 +313,7 @@ public void testLookup() throws Exceptio
     public void testNoSchemaConnectionWithBinaryDetector() throws Exception
     {
         LdapConnectionConfig config = new LdapConnectionConfig();
-        config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        config.setLdapHost( Network.LOOPBACK_HOSTNAME );
         config.setLdapPort( ldapServer.getPort() );
         config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() );
 
@@ -342,7 +342,7 @@ public void testLookup() throws Exceptio
     @Test(expected = InvalidConnectionException.class)
     public void testConnectionWrongPort() throws LdapException, IOException
     {
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), 123 );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, 123 );
         connection.connect();
 
         connection.close();

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LdapSSLConnectionTest.java Wed Feb 24 10:50:12 2016
@@ -25,13 +25,13 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
-import java.net.InetAddress;
 import java.util.List;
 
 import org.apache.directory.api.ldap.codec.api.SchemaBinaryAttributeDetector;
 import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms;
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapConnectionConfig;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
@@ -92,7 +92,7 @@ public class LdapSSLConnectionTest exten
     public void setup() throws Exception
     {
         sslConfig = new LdapConnectionConfig();
-        sslConfig.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        sslConfig.setLdapHost( Network.LOOPBACK_HOSTNAME );
         sslConfig.setUseSsl( true );
         sslConfig.setLdapPort( getLdapServer().getPortSSL() );
         sslConfig.setTrustManagers( new NoVerificationTrustManager() );
@@ -100,7 +100,7 @@ public class LdapSSLConnectionTest exten
                 ldapServer.getDirectoryService().getSchemaManager() ) );
 
         tlsConfig = new LdapConnectionConfig();
-        tlsConfig.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        tlsConfig.setLdapHost( Network.LOOPBACK_HOSTNAME );
         tlsConfig.setLdapPort( getLdapServer().getPort() );
         tlsConfig.setTrustManagers( new NoVerificationTrustManager() );
         tlsConfig.setBinaryAttributeDetector( new SchemaBinaryAttributeDetector(
@@ -221,7 +221,7 @@ public class LdapSSLConnectionTest exten
     public void testStallingSsl() throws Exception
     {
         LdapConnectionConfig sslConfig = new LdapConnectionConfig();
-        sslConfig.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        sslConfig.setLdapHost( Network.LOOPBACK_HOSTNAME );
         sslConfig.setUseSsl( true );
         sslConfig.setLdapPort( getLdapServer().getPortSSL() );
         //sslConfig.setTrustManagers( new NoVerificationTrustManager() );

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LightweightLdapConnectionPoolTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LightweightLdapConnectionPoolTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LightweightLdapConnectionPoolTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/LightweightLdapConnectionPoolTest.java Wed Feb 24 10:50:12 2016
@@ -32,6 +32,7 @@ import org.apache.commons.pool.PoolableO
 import org.apache.commons.pool.impl.GenericObjectPool;
 import org.apache.directory.api.ldap.model.entry.Entry;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.DefaultPoolableLdapConnectionFactory;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapConnectionConfig;
@@ -153,16 +154,7 @@ public class LightweightLdapConnectionPo
         {
             int i = 0;
             LdapConnectionConfig config = new LdapConnectionConfig();
-            
-            try
-            {
-                config.setLdapHost( InetAddress.getLocalHost().getHostName() );
-            }
-            catch ( UnknownHostException e1 )
-            {
-                e1.printStackTrace();
-            }
-            
+            config.setLdapHost( Network.LOOPBACK_HOSTNAME );
             config.setLdapPort( 10389 );
             config.setName( DEFAULT_ADMIN );
             config.setCredentials( DEFAULT_PASSWORD );
@@ -220,7 +212,7 @@ public class LightweightLdapConnectionPo
         int port = getLdapServer().getPort();
 
         LdapConnectionConfig config = new LdapConnectionConfig();
-        config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        config.setLdapHost( Network.LOOPBACK_HOSTNAME );
         config.setLdapPort( port );
         config.setName( DEFAULT_ADMIN );
         config.setCredentials( DEFAULT_PASSWORD );
@@ -253,7 +245,7 @@ public class LightweightLdapConnectionPo
         int port = getLdapServer().getPort();
 
         LdapConnectionConfig config = new LdapConnectionConfig();
-        config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        config.setLdapHost( Network.LOOPBACK_HOSTNAME );
         config.setLdapPort( port );
         config.setName( DEFAULT_ADMIN );
         config.setCredentials( DEFAULT_PASSWORD );
@@ -304,7 +296,7 @@ public class LightweightLdapConnectionPo
         int port = getLdapServer().getPort();
 
         LdapConnectionConfig config = new LdapConnectionConfig();
-        config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        config.setLdapHost( Network.LOOPBACK_HOSTNAME );
         config.setLdapPort( port );
         config.setName( DEFAULT_ADMIN );
         config.setCredentials( DEFAULT_PASSWORD );
@@ -468,7 +460,7 @@ public class LightweightLdapConnectionPo
     @Ignore
     public void testRebindNoPool() throws Exception
     {
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
         connection.bind( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" );
 
         long t0 = System.currentTimeMillis();
@@ -528,7 +520,7 @@ public class LightweightLdapConnectionPo
     public void testSmallPool() throws Exception
     {
         LdapConnectionConfig config = new LdapConnectionConfig();
-        config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        config.setLdapHost( Network.LOOPBACK_HOSTNAME );
         config.setLdapPort( getLdapServer().getPort() );
         config.setName( DEFAULT_ADMIN );
         config.setCredentials( DEFAULT_PASSWORD );

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyRequestTest.java Wed Feb 24 10:50:12 2016
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-import java.net.InetAddress;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
@@ -41,6 +40,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.util.DateUtils;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.ModifyFuture;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -222,7 +222,7 @@ public void testModifyEntryUUIDAndEntryC
     modResp = connection.modify( modifyRequest );
     assertEquals( ResultCodeEnum.SUCCESS, modResp.getLdapResult().getResultCode() );
 
-    LdapNetworkConnection nonAdminConnection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+    LdapNetworkConnection nonAdminConnection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
 
     Dn bindDn = new Dn( "uid=billyd,ou=users,ou=system" );
     nonAdminConnection.bind( bindDn.getName(), "secret" );

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ConcurrentSearchAndUnbindTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ConcurrentSearchAndUnbindTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ConcurrentSearchAndUnbindTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ConcurrentSearchAndUnbindTest.java Wed Feb 24 10:50:12 2016
@@ -24,7 +24,6 @@ package org.apache.directory.shared.clie
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import java.net.InetAddress;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -35,6 +34,7 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
 import org.apache.directory.api.ldap.model.message.SearchScope;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -65,7 +65,7 @@ public class ConcurrentSearchAndUnbindTe
     @Ignore
     public void testConcurrentSearchAndUnbind() throws Exception
     {
-        final LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        final LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
 
         ExecutorService pool = Executors.newFixedThreadPool( 2 );
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/bind/SimpleBindRequestTest.java Wed Feb 24 10:50:12 2016
@@ -40,6 +40,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.api.ldap.model.message.SearchScope;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.ldap.client.api.LdapAsyncConnection;
 import org.apache.directory.ldap.client.api.LdapConnection;
@@ -105,7 +106,7 @@ public class SimpleBindRequestTest exten
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
         connection.setTimeOut( 0L );
     }
 
@@ -260,7 +261,7 @@ public class SimpleBindRequestTest exten
         getLdapServer().getDirectoryService().setAllowAnonymousAccess( true );
 
         //System.out.println( "------------------Create connection" + i + "-------------" );
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
         //System.out.println( "------------------Bind" + i + "-------------" );
 
         // Try with no parameters
@@ -274,7 +275,7 @@ public class SimpleBindRequestTest exten
         connection.close();
 
         // Try with empty strings
-        connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
         connection.bind( "", "" );
 
         assertTrue( connection.isAuthenticated() );
@@ -284,7 +285,7 @@ public class SimpleBindRequestTest exten
         connection.close();
 
         // Try with null parameters
-        connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
         connection.bind( ( String ) null, ( String ) null );
 
         assertTrue( connection.isAuthenticated() );
@@ -294,7 +295,7 @@ public class SimpleBindRequestTest exten
         assertFalse( connection.isConnected() );
         connection.close();
 
-        connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
 
         //System.out.println( "----------------Unbind done" + i + "-------------" );
         assertFalse( connection.isConnected() );
@@ -311,7 +312,7 @@ public class SimpleBindRequestTest exten
     public void testDIRAPI47() throws Exception
     {
         LdapConnectionConfig config = new LdapConnectionConfig();
-        config.setLdapHost( InetAddress.getLocalHost().getHostName() );
+        config.setLdapHost( Network.LOOPBACK_HOSTNAME );
         config.setLdapPort( getLdapServer().getPort() );
         config.setName( "uid=nonexisting,dc=example,dc=com" );
 

Modified: directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/perf/TestClientApiPerf.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/perf/TestClientApiPerf.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/perf/TestClientApiPerf.java (original)
+++ directory/apacheds/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/perf/TestClientApiPerf.java Wed Feb 24 10:50:12 2016
@@ -20,7 +20,6 @@
 package org.apache.directory.shared.client.api.perf;
 
 
-import java.net.InetAddress;
 import java.util.Hashtable;
 
 import javax.naming.Context;
@@ -33,6 +32,7 @@ import javax.naming.directory.SearchResu
 
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
 import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -88,7 +88,7 @@ public class TestClientApiPerf extends A
         long t1 = System.currentTimeMillis();
 
         // Create connection
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort() );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort() );
         connection.bind( "uid=admin,ou=system", "secret" );
 
         long t2 = System.currentTimeMillis();
@@ -123,7 +123,7 @@ public class TestClientApiPerf extends A
         long t1 = System.currentTimeMillis();
 
         // Getting the connection
-        DirContext ctx = jndiEnv( InetAddress.getLocalHost().getHostName(), getLdapServer().getPort(), "", "uid=admin,ou=system", "secret", false );
+        DirContext ctx = jndiEnv( Network.LOOPBACK_HOSTNAME, getLdapServer().getPort(), "", "uid=admin,ou=system", "secret", false );
 
         long t2 = System.currentTimeMillis();
 

Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java (original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/decoder/AddressRecordDecoderTest.java Wed Feb 24 10:50:12 2016
@@ -24,6 +24,7 @@ package org.apache.directory.server.dns.
 import java.net.InetAddress;
 import java.util.Map;
 
+import org.apache.directory.api.util.Network;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.server.dns.store.DnsAttribute;
 import org.apache.mina.core.buffer.IoBuffer;
@@ -49,7 +50,7 @@ public class AddressRecordDecoderTest
     @Before
     public void setUp() throws Exception
     {
-        address = InetAddress.getLocalHost();
+        address = Network.LOOPBACK;
         inputBuffer = IoBuffer.allocate( address.getAddress().length );
         inputBuffer.put( address.getAddress() );
         inputBuffer.flip();

Modified: directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java (original)
+++ directory/apacheds/trunk/protocol-dns/src/test/java/org/apache/directory/server/dns/io/encoder/AddressRecordEncoderTest.java Wed Feb 24 10:50:12 2016
@@ -22,10 +22,10 @@ package org.apache.directory.server.dns.
 
 
 import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.directory.api.util.Network;
 import org.apache.directory.server.dns.store.DnsAttribute;
 import org.apache.mina.core.buffer.IoBuffer;
 
@@ -43,14 +43,7 @@ public class AddressRecordEncoderTest ex
     @Override
     protected void setUpResourceData()
     {
-        try
-        {
-            address = InetAddress.getLocalHost();
-        }
-        catch ( UnknownHostException e )
-        {
-            // should never happen
-        }
+        address = Network.LOOPBACK;
     }
 
 

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/changepwd/service/ChangePasswordService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/changepwd/service/ChangePasswordService.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/changepwd/service/ChangePasswordService.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/changepwd/service/ChangePasswordService.java Wed Feb 24 10:50:12 2016
@@ -26,6 +26,7 @@ import java.nio.ByteBuffer;
 import javax.security.auth.kerberos.KerberosPrincipal;
 
 import org.apache.directory.api.asn1.ber.Asn1Decoder;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.kerberos.ChangePasswordConfig;
@@ -361,7 +362,7 @@ public final class ChangePasswordService
                 ( byte ) 0x61, ( byte ) 0x6E, ( byte ) 0x67, ( byte ) 0x65, ( byte ) 0x64, ( byte ) 0x00 };
         privPart.setUserData( resultCode );
 
-        privPart.setSenderAddress( new HostAddress( InetAddress.getLocalHost() ) );
+        privPart.setSenderAddress( new HostAddress( Network.LOOPBACK ) );
 
         // get the subsession key from the Authenticator
         EncryptionKey subSessionKey = authenticator.getSubKey();

Modified: directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/test/java/org/apache/directory/server/kerberos/protocol/TicketGrantingPolicyTest.java Wed Feb 24 10:50:12 2016
@@ -27,6 +27,7 @@ import java.net.InetAddress;
 
 import javax.security.auth.kerberos.KerberosPrincipal;
 
+import org.apache.directory.api.util.Network;
 import org.apache.directory.server.kerberos.KerberosConfig;
 import org.apache.directory.server.kerberos.kdc.KdcServer;
 import org.apache.directory.server.kerberos.protocol.AbstractAuthenticationServiceTest.KrbDummySession;
@@ -345,7 +346,7 @@ public class TicketGrantingPolicyTest ex
         kdcReqBody.setTill( requestedEndTime );
 
         HostAddress[] address =
-            { new HostAddress( InetAddress.getLocalHost() ) };
+            { new HostAddress( Network.LOOPBACK ) };
         HostAddresses addresses = new HostAddresses( address );
         kdcReqBody.setAddresses( addresses );
 

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java Wed Feb 24 10:50:12 2016
@@ -20,8 +20,6 @@
 package org.apache.directory.server.ldap.replication;
 
 
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -32,6 +30,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.message.AliasDerefMode;
 import org.apache.directory.api.ldap.model.message.SearchScope;
 import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.NoVerificationTrustManager;
 
 
@@ -144,15 +143,7 @@ public class SyncReplConfiguration imple
         // the default list of attributes
         attributes.add( SchemaConstants.ALL_USER_ATTRIBUTES );
         
-        try
-        {
-            remoteHost = InetAddress.getLocalHost().getHostName();
-        }
-        catch ( UnknownHostException uhe )
-        {
-            // Default to localhost
-            remoteHost = "localhost";
-        }
+        remoteHost = Network.LOOPBACK_HOSTNAME;
         
         remotePort = 10389;
         

Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java Wed Feb 24 10:50:12 2016
@@ -19,9 +19,7 @@
 package org.apache.directory.server.protocol.shared.transport;
 
 
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
+import org.apache.directory.api.util.Network;
 import org.apache.mina.core.service.IoAcceptor;
 
 
@@ -75,15 +73,7 @@ public abstract class AbstractTransport
      */
     public AbstractTransport( int port )
     {
-        try
-        {
-            this.address = InetAddress.getLocalHost().getHostAddress();
-        }
-        catch ( UnknownHostException e )
-        {
-            this.address = "localhost";
-        }
-        
+        this.address = Network.LOOPBACK.getHostAddress();
         this.port = port;
     }
 
@@ -97,15 +87,7 @@ public abstract class AbstractTransport
      */
     public AbstractTransport( int port, int nbThreads )
     {
-        try
-        {
-            this.address = InetAddress.getLocalHost().getHostAddress();
-        }
-        catch ( UnknownHostException e )
-        {
-            this.address = "localhost";
-        }
-        
+        this.address = Network.LOOPBACK.getHostAddress();
         this.port = port;
         this.nbThreads = nbThreads;
     }

Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java Wed Feb 24 10:50:12 2016
@@ -19,11 +19,10 @@
 package org.apache.directory.server.protocol.shared.transport;
 
 
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
 import java.util.List;
 
+import org.apache.directory.api.util.Network;
 import org.apache.mina.core.service.IoAcceptor;
 import org.apache.mina.transport.socket.SocketAcceptor;
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
@@ -114,9 +113,9 @@ public class TcpTransport extends Abstra
      * acceptor to be ready
      * @throws UnknownHostException 
      */
-    public TcpTransport( int tcpPort, int nbThreads, int backLog ) throws UnknownHostException
+    public TcpTransport( int tcpPort, int nbThreads, int backLog )
     {
-        super( InetAddress.getLocalHost().getHostAddress(), tcpPort, nbThreads, backLog );
+        super( Network.LOOPBACK.getHostAddress(), tcpPort, nbThreads, backLog );
         this.acceptor = createAcceptor( null, tcpPort, nbThreads, backLog );
 
         LOG.debug( "TCP Transport created : <*:{},>", tcpPort );

Modified: directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java (original)
+++ directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/factory/ServerAnnotationProcessor.java Wed Feb 24 10:50:12 2016
@@ -22,14 +22,13 @@ package org.apache.directory.server.fact
 import java.io.IOException;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
-import java.net.InetAddress;
 import java.net.ServerSocket;
-import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
 import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.server.annotations.CreateChngPwdServer;
 import org.apache.directory.server.annotations.CreateConsumer;
@@ -245,15 +244,7 @@ public final class ServerAnnotationProce
         
         if ( Strings.isEmpty( remoteHost ) )
         {
-            try
-            { 
-                remoteHost = InetAddress.getLocalHost().getHostName();
-            }
-            catch ( UnknownHostException uhe )
-            {
-                // Just in case...
-                remoteHost = "localhost";
-            }
+            remoteHost = Network.LOOPBACK_HOSTNAME;
         }
         
         config.setRemoteHost( remoteHost );
@@ -481,15 +472,7 @@ public final class ServerAnnotationProce
         
         if ( Strings.isEmpty( address ) )
         {
-            try
-            {
-                address = InetAddress.getLocalHost().getHostName();
-            }
-            catch ( UnknownHostException uhe )
-            {
-                // Default to "localhost"...
-                address = "localhost";
-            }
+            address = Network.LOOPBACK_HOSTNAME;
         }
 
         if ( port <= 0 )

Modified: directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/DirectoryServiceAnnotationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/DirectoryServiceAnnotationTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/DirectoryServiceAnnotationTest.java (original)
+++ directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/DirectoryServiceAnnotationTest.java Wed Feb 24 10:50:12 2016
@@ -40,6 +40,7 @@ import org.apache.directory.api.ldap.cod
 import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.model.name.Dn;
 import org.apache.directory.api.ldap.util.JndiUtils;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.constants.ServerDNConstants;
@@ -77,7 +78,7 @@ public class DirectoryServiceAnnotationT
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
         env.put( Context.PROVIDER_URL,
-            "ldap://" + InetAddress.getLocalHost().getHostName() + ":" + ldapServer.getPort() );
+            "ldap://" + Network.LOOPBACK_HOSTNAME + ":" + ldapServer.getPort() );
         env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );

Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/TransportBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/TransportBean.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/TransportBean.java (original)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/beans/TransportBean.java Wed Feb 24 10:50:12 2016
@@ -20,11 +20,10 @@
 package org.apache.directory.server.config.beans;
 
 
-import java.net.InetAddress;
-import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.directory.api.util.Network;
 import org.apache.directory.server.config.ConfigurationElement;
 
 
@@ -322,15 +321,7 @@ public class TransportBean extends AdsBa
 
         if ( transportAddress == null )
         {
-            try
-            {
-                sb.append( InetAddress.getLocalHost().getHostName() ).append( '\n' );
-            }
-            catch ( UnknownHostException uhe )
-            {
-                // Just in case
-                sb.append( "localhost" ).append( '\n' );
-            }
+            sb.append( Network.LOOPBACK_HOSTNAME ).append( '\n' );
         }
         else
         {

Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java Wed Feb 24 10:50:12 2016
@@ -19,7 +19,6 @@
 package org.apache.directory.server.integ;
 
 
-import java.net.InetAddress;
 import java.util.Hashtable;
 
 import javax.naming.Context;
@@ -30,6 +29,7 @@ import netscape.ldap.LDAPConnection;
 
 import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.util.JndiUtils;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.constants.ServerDNConstants;
@@ -80,8 +80,7 @@ public class ServerIntegrationUtils exte
         LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapServer.getPort() );
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
-        env.put( Context.PROVIDER_URL,
-            "ldap://" + InetAddress.getLocalHost().getHostName() + ":" + ldapServer.getPort() );
+        env.put( Context.PROVIDER_URL, Network.ldapLoopbackUrl( ldapServer.getPort() ) );
         env.put( Context.SECURITY_PRINCIPAL, principalDn );
         env.put( Context.SECURITY_CREDENTIALS, password );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -104,8 +103,7 @@ public class ServerIntegrationUtils exte
         LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapServer.getPort() );
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
-        env.put( Context.PROVIDER_URL,
-            "ldap://" + InetAddress.getLocalHost().getHostName() + ":" + ldapServer.getPort() );
+        env.put( Context.PROVIDER_URL, Network.ldapLoopbackUrl( ldapServer.getPort() ) );
         env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -128,8 +126,7 @@ public class ServerIntegrationUtils exte
         LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapServer.getPort() );
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
-        env.put( Context.PROVIDER_URL,
-            "ldap://" + InetAddress.getLocalHost().getHostName() + ":" + ldapServer.getPort() );
+        env.put( Context.PROVIDER_URL, Network.ldapLoopbackUrl( ldapServer.getPort() ) );
         env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -152,8 +149,7 @@ public class ServerIntegrationUtils exte
         LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapServer.getPort() );
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
-        env.put( Context.PROVIDER_URL,
-            "ldap://" + InetAddress.getLocalHost().getHostName() + ":" + ldapServer.getPort() );
+        env.put( Context.PROVIDER_URL, Network.ldapLoopbackUrl( ldapServer.getPort() ) );
         env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -176,8 +172,7 @@ public class ServerIntegrationUtils exte
         LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapServer.getPort() );
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
-        env.put( Context.PROVIDER_URL,
-            "ldap://" + InetAddress.getLocalHost().getHostName() + ":" + ldapServer.getPort() );
+        env.put( Context.PROVIDER_URL, Network.ldapLoopbackUrl( ldapServer.getPort() ) );
         env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -203,7 +198,7 @@ public class ServerIntegrationUtils exte
         String password = System.getProperty( testServer + ".password", DEFAULT_PASSWORD );
         LOG.debug( testServer + ".password = " + password );
 
-        String host = System.getProperty( testServer + ".host", InetAddress.getLocalHost().getHostName() );
+        String host = System.getProperty( testServer + ".host", Network.LOOPBACK_HOSTNAME );
         LOG.debug( testServer + ".host = " + host );
 
         int port = Integer.parseInt( System.getProperty( testServer + ".port", Integer.toString( DEFAULT_PORT ) ) );
@@ -233,7 +228,7 @@ public class ServerIntegrationUtils exte
         String password = System.getProperty( testServer + ".password", DEFAULT_PASSWORD );
         LOG.debug( testServer + ".password = " + password );
 
-        String host = System.getProperty( testServer + ".host", InetAddress.getLocalHost().getHostName() );
+        String host = System.getProperty( testServer + ".host", Network.LOOPBACK_HOSTNAME );
         LOG.debug( testServer + ".host = " + host );
 
         int port = Integer.parseInt( System.getProperty( testServer + ".port", Integer.toString( DEFAULT_PORT ) ) );
@@ -258,7 +253,7 @@ public class ServerIntegrationUtils exte
     public static LdapConnection getWiredConnection( LdapServer ldapServer, String principalDn, String password )
         throws Exception
     {
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() );
         connection.bind( principalDn, password );
 
         return connection;
@@ -274,7 +269,7 @@ public class ServerIntegrationUtils exte
      */
     public static LdapConnection getLdapConnection( LdapServer ldapServer ) throws Exception
     {
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() );
 
         return connection;
     }
@@ -293,7 +288,7 @@ public class ServerIntegrationUtils exte
         throws Exception
     {
         LDAPConnection connection = new LDAPConnection();
-        connection.connect( 3, InetAddress.getLocalHost().getHostName(), ldapServer.getPort(), principalDn, password );
+        connection.connect( 3, Network.LOOPBACK_HOSTNAME, ldapServer.getPort(), principalDn, password );
 
         return connection;
     }
@@ -308,7 +303,7 @@ public class ServerIntegrationUtils exte
      */
     public static LdapConnection getAdminConnection( LdapServer ldapServer ) throws Exception
     {
-        LdapConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
+        LdapConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() );
         connection.bind( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" );
 
         return connection;

Modified: directory/apacheds/trunk/server-integ/src/test/java/MultiThreadedReadWriteTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/MultiThreadedReadWriteTest.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/MultiThreadedReadWriteTest.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/MultiThreadedReadWriteTest.java Wed Feb 24 10:50:12 2016
@@ -17,13 +17,14 @@
  *   under the License.
  *
  */
+
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.net.InetAddress;
 
 import org.apache.directory.api.ldap.model.cursor.EntryCursor;
 import org.apache.directory.api.ldap.model.entry.DefaultEntry;
 import org.apache.directory.api.ldap.model.message.SearchScope;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 
 /**
@@ -149,7 +150,7 @@ public class MultiThreadedReadWriteTest
 
     private LdapNetworkConnection getConnection() throws Exception
     {
-        LdapNetworkConnection connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), 10389 );
+        LdapNetworkConnection connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, 10389 );
         connection.bind( "uid=admin,ou=system", "secret" );
         connection.setTimeOut( Long.MAX_VALUE );
         

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineIT.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/dsml/engine/Dsmlv2EngineIT.java Wed Feb 24 10:50:12 2016
@@ -26,13 +26,13 @@ import static org.junit.Assert.assertNot
 
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
-import java.net.InetAddress;
 
 import org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser;
 import org.apache.directory.api.dsmlv2.engine.Dsmlv2Engine;
 import org.apache.directory.api.dsmlv2.response.BatchResponseDsml;
 import org.apache.directory.api.dsmlv2.response.SearchResponse;
 import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.server.annotations.CreateLdapServer;
@@ -65,7 +65,7 @@ public class Dsmlv2EngineIT extends Abst
     @Before
     public void setup() throws Exception
     {
-        connection = new LdapNetworkConnection( InetAddress.getLocalHost().getHostName(), ldapServer.getPort() );
+        connection = new LdapNetworkConnection( Network.LOOPBACK_HOSTNAME, ldapServer.getPort() );
         engine = new Dsmlv2Engine( connection, "uid=admin,ou=system", "secret" );
     }
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java?rev=1732068&r1=1732067&r2=1732068&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java Wed Feb 24 10:50:12 2016
@@ -27,7 +27,6 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.io.IOException;
-import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.security.InvalidKeyException;
 import java.util.Arrays;
@@ -47,6 +46,7 @@ import javax.naming.directory.InitialDir
 import javax.naming.directory.ModificationItem;
 
 import org.apache.directory.api.ldap.model.constants.SupportedSaslMechanisms;
+import org.apache.directory.api.util.Network;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.annotations.SaslMechanism;
@@ -228,8 +228,7 @@ public class KeyDerivationServiceIT exte
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://" + InetAddress.getLocalHost().getHostName() + ":"
-            + getLdapServer().getPort() );
+        env.put( Context.PROVIDER_URL, Network.ldapLoopbackUrl( getLdapServer().getPort() )  );
 
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson,ou=users,dc=example,dc=com" );
@@ -302,8 +301,7 @@ public class KeyDerivationServiceIT exte
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://" + InetAddress.getLocalHost().getHostName() + ":"
-            + getLdapServer().getPort() );
+        env.put( Context.PROVIDER_URL, Network.ldapLoopbackUrl( getLdapServer().getPort() ) );
 
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson,ou=users,dc=example,dc=com" );
@@ -445,8 +443,7 @@ public class KeyDerivationServiceIT exte
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://" + InetAddress.getLocalHost().getHostName() + ":"
-            + getLdapServer().getPort() );
+        env.put( Context.PROVIDER_URL, Network.ldapLoopbackUrl( getLdapServer().getPort() ) );
 
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson,ou=users,dc=example,dc=com" );
@@ -580,8 +577,8 @@ public class KeyDerivationServiceIT exte
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( "java.naming.provider.url", "ldap://" + InetAddress.getLocalHost().getHostName() + ":"
-            + getLdapServer().getPort() + "/ou=users,dc=example,dc=com" );
+        env.put( "java.naming.provider.url",
+            Network.ldapLoopbackUrl( getLdapServer().getPort() ) + "/ou=users,dc=example,dc=com" );
         env.put( "java.naming.security.principal", "uid=admin,ou=system" );
         env.put( "java.naming.security.credentials", "secret" );
         env.put( "java.naming.security.authentication", "simple" );




Mime
View raw message