directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erodrig...@apache.org
Subject svn commit: r519702 - /directory/apacheds/branches/apacheds-sasl-branch/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java
Date Sun, 18 Mar 2007 21:28:33 GMT
Author: erodriguez
Date: Sun Mar 18 14:28:32 2007
New Revision: 519702

URL: http://svn.apache.org/viewvc?view=rev&rev=519702
Log:
Updated Kerberos protocol provider to lazy-load initial context, fixing issue requiring search
base DN to exist at protocol provider startup.

Modified:
    directory/apacheds/branches/apacheds-sasl-branch/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java

Modified: directory/apacheds/branches/apacheds-sasl-branch/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-sasl-branch/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java?view=diff&rev=519702&r1=519701&r2=519702
==============================================================================
--- directory/apacheds/branches/apacheds-sasl-branch/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java
(original)
+++ directory/apacheds/branches/apacheds-sasl-branch/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/store/SingleBaseSearch.java
Sun Mar 18 14:28:32 2007
@@ -50,23 +50,17 @@
 class SingleBaseSearch implements PrincipalStore
 {
     private DirContext ctx;
+    private Hashtable<String, String> env;
+    private InitialContextFactory factory;
 
 
-    SingleBaseSearch(ServiceConfiguration config, InitialContextFactory factory)
+    SingleBaseSearch( ServiceConfiguration config, InitialContextFactory factory )
     {
-        Hashtable env = new Hashtable( config.toJndiEnvironment() );
+        env = new Hashtable<String, String>( config.toJndiEnvironment() );
         env.put( Context.INITIAL_CONTEXT_FACTORY, config.getInitialContextFactory() );
         env.put( Context.PROVIDER_URL, config.getEntryBaseDn() );
 
-        try
-        {
-            ctx = ( DirContext ) factory.getInitialContext( env );
-        }
-        catch ( NamingException ne )
-        {
-            String message = "Failed to get initial context " + ( String ) env.get( Context.PROVIDER_URL
);
-            throw new ConfigurationException( message, ne );
-        }
+        this.factory = factory;
     }
 
 
@@ -102,6 +96,20 @@
 
     private Object execute( ContextOperation operation ) throws Exception
     {
+        if ( ctx == null )
+        {
+            try
+            {
+                ctx = ( DirContext ) factory.getInitialContext( env );
+            }
+            catch ( NamingException ne )
+            {
+                ne.printStackTrace();
+                String message = "Failed to get initial context " + ( String ) env.get( Context.PROVIDER_URL
);
+                throw new ConfigurationException( message, ne );
+            }
+        }
+
         return operation.execute( ctx, null );
     }
 }



Mime
View raw message