directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r367150 - in /directory/trunk/apacheds/src/main/java/org/apache/ldap/server: DefaultDirectoryService.java jndi/ServerDirContext.java partition/DirectoryPartitionNexusProxy.java
Date Mon, 09 Jan 2006 01:03:49 GMT
Author: elecharny
Date: Sun Jan  8 17:03:44 2006
New Revision: 367150

URL: http://svn.apache.org/viewcvs?rev=367150&view=rev
Log:
Big DN-refactoring commit. Many things has changed :
- Twix Message now transform LdapDN and attributes to avoid OIDs
and other aliases
- Renammed some class to avoid W$ case-insensitivity problem (DNParser 
is now name LdapDnParser)
- Fixed some bugs in SearchRequest (ToString())
- Added some methods in LdapDN to stick with Jdk15 LdapName

Modified:
    directory/trunk/apacheds/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
    directory/trunk/apacheds/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java
    directory/trunk/apacheds/src/main/java/org/apache/ldap/server/partition/DirectoryPartitionNexusProxy.java

Modified: directory/trunk/apacheds/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
URL: http://svn.apache.org/viewcvs/directory/trunk/apacheds/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java?rev=367150&r1=367149&r2=367150&view=diff
==============================================================================
--- directory/trunk/apacheds/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
(original)
+++ directory/trunk/apacheds/src/main/java/org/apache/ldap/server/DefaultDirectoryService.java
Sun Jan  8 17:03:44 2006
@@ -16,8 +16,10 @@
  */
 package org.apache.ldap.server;
 
+import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Set;
 import java.util.HashSet;
 
@@ -27,18 +29,22 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 
+import org.apache.asn1.primitives.OID;
 import org.apache.ldap.common.exception.LdapAuthenticationNotSupportedException;
 import org.apache.ldap.common.exception.LdapConfigurationException;
 import org.apache.ldap.common.exception.LdapNoPermissionException;
 import org.apache.ldap.common.message.LockableAttributeImpl;
 import org.apache.ldap.common.message.LockableAttributesImpl;
 import org.apache.ldap.common.message.ResultCodeEnum;
+import org.apache.ldap.common.name.DnOidContainer;
 import org.apache.ldap.common.name.DnParser;
 import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.common.name.NameComponentNormalizer;
 import org.apache.ldap.common.util.DateUtils;
 import org.apache.ldap.common.util.StringTools;
 import org.apache.ldap.common.schema.AttributeType;
+import org.apache.ldap.common.schema.NoOpNormalizer;
+import org.apache.ldap.common.schema.OidNormalizer;
 import org.apache.ldap.server.authz.AuthorizationService;
 import org.apache.ldap.server.configuration.Configuration;
 import org.apache.ldap.server.configuration.ConfigurationException;
@@ -648,6 +654,69 @@
         }
     }
 
+    private void setupOidsMap( BootstrapRegistries bootstrapRegistries ) throws NamingException
+    {
+        Iterator keys = bootstrapRegistries.getOidRegistry().getOidByName().keySet().iterator();
+        
+        Map oidsMap = new HashMap();
+        Map oidName = new HashMap();
+        
+        while ( keys.hasNext() )
+        {
+        	String name = StringTools.deepTrimToLower( (String)keys.next() );
+        	String principal = null;
+        	
+        	if ( OID.isOID( name ) )
+        	{
+        		continue;
+        	}
+        	
+        	String oid =  bootstrapRegistries.getOidRegistry().getOid( name );
+        	
+        	OidNormalizer oidNormalizer = null;
+        	
+        	if ( oidName.containsKey( oid ) )
+        	{
+        		principal = StringTools.deepTrimToLower( (String)oidName.get( oid ) );
+        		
+        		if ( principal.length() > name.length() )
+        		{
+        			OidNormalizer oldOidNormalizer = (OidNormalizer)oidsMap.get( principal );
+
+        			
+        			oidNormalizer = new OidNormalizer( name, oldOidNormalizer.getNormalizer() );
+
+        			oidName.remove( oid );
+        			oidName.put( oid, name );
+        			oidsMap.remove( principal );
+        			oidsMap.remove( oid );
+        			oidsMap.put( principal, oidNormalizer );
+        			oidsMap.put( name, oidNormalizer );
+        			oidsMap.put( oid, oidNormalizer );
+        	        continue;
+        		}
+        	}
+        	else
+        	{
+        		principal = name;
+            	oidName.put( oid, principal );
+
+            	if ( bootstrapRegistries.getNormalizerRegistry().hasNormalizer( oid ) )
+	        	{
+	        		oidNormalizer = new OidNormalizer( principal, bootstrapRegistries.getNormalizerRegistry().lookup(
oid ) );
+	        	}
+	        	else
+	        	{
+	        		oidNormalizer = new OidNormalizer( principal, new NoOpNormalizer() );
+	        	}
+	        	
+	        	oidsMap.put( name, oidNormalizer );
+	        	oidsMap.put( oid, oidNormalizer );
+        	}
+        }
+        
+        DnOidContainer.setOids( oidsMap );
+    }
 
     /**
      * Kicks off the initialization of the entire system.
@@ -670,6 +739,8 @@
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
         
         loader.load( startupConfiguration.getBootstrapSchemas(), bootstrapRegistries );
+        
+        setupOidsMap( bootstrapRegistries );
 
         java.util.List errors = bootstrapRegistries.checkRefInteg();
         if ( !errors.isEmpty() )

Modified: directory/trunk/apacheds/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java
URL: http://svn.apache.org/viewcvs/directory/trunk/apacheds/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java?rev=367150&r1=367149&r2=367150&view=diff
==============================================================================
--- directory/trunk/apacheds/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java
(original)
+++ directory/trunk/apacheds/src/main/java/org/apache/ldap/server/jndi/ServerDirContext.java
Sun Jan  8 17:03:44 2006
@@ -44,6 +44,8 @@
 import org.apache.ldap.common.filter.FilterParserImpl;
 import org.apache.ldap.common.filter.PresenceNode;
 import org.apache.ldap.common.filter.SimpleNode;
+import org.apache.ldap.common.name.DnOidContainer;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.common.util.NamespaceTools;
 import org.apache.ldap.server.DirectoryService;
@@ -359,7 +361,7 @@
             return ( DirContext ) super.createSubcontext( name );
         }
 
-        LdapName target = buildTarget( name );
+        Name target = buildTarget( name );
 
         String rdn = name.get( name.size() - 1 );
 
@@ -485,7 +487,7 @@
     {
         SearchControls ctls = new SearchControls();
 
-        LdapName target = buildTarget( name );
+        Name target = buildTarget( name );
 
         // If we need to return specific attributes add em to the SearchControls
         if ( null != attributesToReturn )
@@ -571,7 +573,13 @@
      */
     public NamingEnumeration search( Name name, ExprNode filter, SearchControls cons ) throws
NamingException
     {
-        LdapName target = buildTarget( name );
+    	/*Name newName = new LdapDN( name.toString() );
+    	newName = LdapDN.oidToName( newName, DnOidContainer.getOids() );
+    	
+    	
+        Name target = buildTarget( ((LdapDN)newName).toLdapName() );*/
+        
+        Name target = buildTarget( name );
         return getNexusProxy().search( target, getEnvironment(), filter, cons );
     }
 
@@ -585,7 +593,7 @@
     {
         ExprNode filterNode;
 
-        LdapName target = buildTarget( name );
+        Name target = buildTarget( name );
 
         try
         {

Modified: directory/trunk/apacheds/src/main/java/org/apache/ldap/server/partition/DirectoryPartitionNexusProxy.java
URL: http://svn.apache.org/viewcvs/directory/trunk/apacheds/src/main/java/org/apache/ldap/server/partition/DirectoryPartitionNexusProxy.java?rev=367150&r1=367149&r2=367150&view=diff
==============================================================================
--- directory/trunk/apacheds/src/main/java/org/apache/ldap/server/partition/DirectoryPartitionNexusProxy.java
(original)
+++ directory/trunk/apacheds/src/main/java/org/apache/ldap/server/partition/DirectoryPartitionNexusProxy.java
Sun Jan  8 17:03:44 2006
@@ -36,6 +36,7 @@
 import org.apache.ldap.common.exception.LdapSizeLimitExceededException;
 import org.apache.ldap.common.exception.LdapTimeLimitExceededException;
 import org.apache.ldap.common.filter.ExprNode;
+import org.apache.ldap.common.name.LdapDN;
 import org.apache.ldap.server.DirectoryServiceConfiguration;
 import org.apache.ldap.server.DirectoryService;
 import org.apache.ldap.server.configuration.DirectoryPartitionConfiguration;
@@ -45,6 +46,7 @@
 import org.apache.ldap.server.interceptor.InterceptorChain;
 import org.apache.ldap.server.invocation.Invocation;
 import org.apache.ldap.server.invocation.InvocationStack;
+import org.apache.ldap.server.schema.OidRegistry;
 
 
 /**
@@ -457,6 +459,10 @@
         stack.push( new Invocation( this, caller, "lookup", new Object[] { name }, bypass
) );
         try
         {
+        	OidRegistry registry = (OidRegistry)this.service.getConfiguration().getGlobalRegistries().getOidRegistry();
+        	
+        	LdapDN.normalize( name, registry.getNameByOid() );
+
             return this.configuration.getInterceptorChain().lookup( name );
         }
         finally



Mime
View raw message