directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r201848 - in /directory/apacheds/trunk: core/src/main/java/org/apache/ldap/server/jndi/ main/src/main/java/org/apache/ldap/server/jndi/
Date Sun, 26 Jun 2005 12:49:46 GMT
Author: akarasulu
Date: Sun Jun 26 05:49:45 2005
New Revision: 201848

URL: http://svn.apache.org/viewcvs?rev=201848&view=rev
Log:
changes ...

 o Fixed bug where JNDI environment property for the provider URL was being 
   changed.  This is a big no no for JNDI providers which must preserve the
   original objects they are handed by the user.
 o Fixed bug where the proper JNDI context was not being given to the Kerberos
   protocol provider in the context factory implementation.
 o Formatting changes 


Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
    directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
    directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java?rev=201848&r1=201847&r2=201848&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/AbstractContextFactory.java
Sun Jun 26 05:49:45 2005
@@ -78,8 +78,6 @@
     public final synchronized Context getInitialContext( Hashtable env ) throws NamingException
     {
         Configuration cfg = Configuration.toConfiguration( env );
-        env = ( Hashtable ) env.clone();
-        
         String principal = getPrincipal( env );
         byte[] credential = getCredential( env );
         String authentication = getAuthentication( env );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java?rev=201848&r1=201847&r2=201848&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/DefaultContextFactoryService.java
Sun Jun 26 05:49:45 2005
@@ -155,14 +155,15 @@
 
     public synchronized void startup( ContextFactoryServiceListener listener, Hashtable env
) throws NamingException
     {
+        Hashtable envCopy = ( Hashtable ) env.clone();
+
         if( started )
         {
             return;
         }
 
         StartupConfiguration cfg = ( StartupConfiguration ) Configuration.toConfiguration(
env );
-
-        env.put( Context.PROVIDER_URL, "" );
+        envCopy.put( Context.PROVIDER_URL, "" );
         
         try
         {
@@ -175,7 +176,7 @@
             throw ne;
         }
 
-        this.environment = env;
+        this.environment = envCopy;
         this.startupConfiguration = cfg;
         
         listener.beforeStartup( this );

Modified: directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
URL: http://svn.apache.org/viewcvs/directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java?rev=201848&r1=201847&r2=201848&view=diff
==============================================================================
--- directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
(original)
+++ directory/apacheds/trunk/main/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java
Sun Jun 26 05:49:45 2005
@@ -24,8 +24,10 @@
 import java.util.Properties;
 
 import javax.naming.NamingException;
+import javax.naming.Context;
 import javax.naming.ldap.Control;
 import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.LdapContext;
 
 import org.apache.kerberos.protocol.KerberosProtocolProvider;
 import org.apache.kerberos.service.KdcConfiguration;
@@ -34,6 +36,7 @@
 import org.apache.ldap.common.exception.LdapConfigurationException;
 import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.common.util.PropertiesUtils;
+import org.apache.ldap.common.util.NamespaceTools;
 import org.apache.ldap.server.configuration.ServerStartupConfiguration;
 import org.apache.ldap.server.protocol.LdapProtocolProvider;
 import org.apache.mina.common.TransportType;
@@ -132,25 +135,38 @@
         }
 
         KdcConfiguration config = new KdcConfiguration( props );
-
         int port = PropertiesUtils.get( env, KdcConfiguration.KERBEROS_PORT_KEY, KdcConfiguration.DEFAULT_KERBEROS_PORT
);
-
         Service service= new Service( "kerberos", TransportType.DATAGRAM, new InetSocketAddress(
port ) );
-
-        InitialLdapContext ctx = new InitialLdapContext( env, new Control[]{} );
-
+        LdapContext ctx = getBaseRealmContext( config, env );
         PrincipalStore store = new JndiPrincipalStoreImpl( ctx, new LdapName( "ou=Users"
) );
 
         try
         {
             minaRegistry.bind( service, new KerberosProtocolProvider( config, store ) );
-
             kerberosService = service;
         }
         catch ( IOException e )
         {
             e.printStackTrace();
         }
+    }
+
+
+    /**
+     * Maps a Kerberos Realm name to a position within the DIT.  The primary realm of
+     * the KDC will use this area for configuration and for storing user entries.
+     *
+     * @param config the KDC's configuration
+     * @param env the JNDI environment properties
+     * @return the base context for the primary realm of the KDC
+     * @throws NamingException
+     */
+    private LdapContext getBaseRealmContext( KdcConfiguration config, Hashtable env ) throws
NamingException
+    {
+        Hashtable cloned = ( Hashtable ) env.clone();
+        String dn = NamespaceTools.inferLdapName( config.getPrimaryRealm() );
+        cloned.put( Context.PROVIDER_URL, dn );
+        return new InitialLdapContext( cloned, new Control[]{} );
     }
 
 



Mime
View raw message