directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r412638 - in /directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core: authz/ jndi/ normalization/ partition/impl/btree/
Date Thu, 08 Jun 2006 03:14:17 GMT
Author: akarasulu
Date: Wed Jun  7 20:14:17 2006
New Revision: 412638

URL: http://svn.apache.org/viewvc?rev=412638&view=rev
Log:
changes ...

 o got search working properly again by fixing evaluators to use normalized
   names and using the proper OID based lookups
 o fixed test case for hot adding and removing partitions to the server


Modified:
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationService.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
    directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationService.java?rev=412638&r1=412637&r2=412638&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationService.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationService.java
Wed Jun  7 20:14:17 2006
@@ -343,45 +343,46 @@
     }
 
 
-    private void protectLookUp( Name dn ) throws NamingException
+    private void protectLookUp( Name normalizedDn ) throws NamingException
     {
         LdapContext ctx = ( LdapContext ) InvocationStack.getInstance().peek().getCaller();
-        Name principalDn = ( ( ServerContext ) ctx ).getPrincipal().getJndiName();
+        LdapDN principalDn = new LdapDN( ( ( ServerContext ) ctx ).getPrincipal().getJndiName()
);
+        principalDn.normalize();
 
         if ( !principalDn.equals( ADMIN_DN ) )
         {
-            if ( dn.size() > 2 && dn.startsWith( USER_BASE_DN ) )
+            if ( normalizedDn.size() > 2 && normalizedDn.startsWith( USER_BASE_DN
) )
             {
                 // allow for self reads
-                if ( dn.toString().equals( principalDn.toString() ) )
+                if ( normalizedDn.toString().equals( principalDn.toString() ) )
                 {
                     return;
                 }
 
-                String msg = "Access to user account '" + dn + "' not permitted";
+                String msg = "Access to user account '" + normalizedDn + "' not permitted";
                 msg += " for user '" + principalDn + "'.  Only the admin can";
                 msg += " access user account information";
                 throw new LdapNoPermissionException( msg );
             }
 
-            if ( dn.size() > 2 && dn.startsWith( GROUP_BASE_DN ) )
+            if ( normalizedDn.size() > 2 && normalizedDn.startsWith( GROUP_BASE_DN
) )
             {
                 // allow for self reads
-                if ( dn.toString().equals( principalDn.toString() ) )
+                if ( normalizedDn.toString().equals( principalDn.toString() ) )
                 {
                     return;
                 }
 
-                String msg = "Access to group '" + dn + "' not permitted";
+                String msg = "Access to group '" + normalizedDn + "' not permitted";
                 msg += " for user '" + principalDn + "'.  Only the admin can";
                 msg += " access group information";
                 throw new LdapNoPermissionException( msg );
             }
 
-            if ( dn.equals( ADMIN_DN ) )
+            if ( normalizedDn.equals( ADMIN_DN ) )
             {
                 // allow for self reads
-                if ( dn.toString().equals( principalDn.toString() ) )
+                if ( normalizedDn.toString().equals( principalDn.toString() ) )
                 {
                     return;
                 }

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java?rev=412638&r1=412637&r2=412638&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/AbstractContextFactory.java
Wed Jun  7 20:14:17 2006
@@ -110,8 +110,9 @@
         }
         else if ( cfg instanceof RemoveDirectoryPartitionConfiguration )
         {
-            new DirectoryPartitionNexusProxy( service.getJndiContext( principal, credential,
authentication, "" ),
-                service ).removeContextPartition( ( ( RemoveDirectoryPartitionConfiguration
) cfg ).getSuffix() );
+            Context ctx = service.getJndiContext( principal, credential, authentication,
"" );
+            DirectoryPartitionNexusProxy proxy = new DirectoryPartitionNexusProxy( ctx, service
);
+            proxy.removeContextPartition( ( ( RemoveDirectoryPartitionConfiguration ) cfg
).getSuffix() );
         }
         else if ( service == null )
         {

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=412638&r1=412637&r2=412638&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
Wed Jun  7 20:14:17 2006
@@ -123,7 +123,10 @@
             .getSaslAuthId() );
 
         if ( dn.size() == 0 )
+        {
             return;
+        }
+        
         if ( !nexusProxy.hasEntry( dn ) )
         {
             throw new NameNotFoundException( dn + " does not exist" );

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java?rev=412638&r1=412637&r2=412638&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
Wed Jun  7 20:14:17 2006
@@ -26,6 +26,7 @@
 import javax.naming.directory.SearchControls;
 
 import org.apache.directory.server.core.DirectoryServiceConfiguration;
+import org.apache.directory.server.core.configuration.DirectoryPartitionConfiguration;
 import org.apache.directory.server.core.configuration.InterceptorConfiguration;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
 import org.apache.directory.server.core.interceptor.NextInterceptor;
@@ -236,6 +237,19 @@
     {
         name = LdapDN.normalize( name );
         return next.compare( name, oid, value );
+    }
+
+
+    public void addContextPartition( NextInterceptor next, DirectoryPartitionConfiguration
cfg ) throws NamingException
+    {
+        next.addContextPartition( cfg );
+    }
+
+
+    public void removeContextPartition( NextInterceptor next, LdapDN suffix ) throws NamingException
+    {
+        suffix = LdapDN.normalize( suffix );
+        next.removeContextPartition( suffix );
     }
 
 

Modified: directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java?rev=412638&r1=412637&r2=412638&view=diff
==============================================================================
--- directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
(original)
+++ directory/branches/apacheds/optimization/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/LeafEvaluator.java
Wed Jun  7 20:14:17 2006
@@ -248,10 +248,25 @@
             return false;
         }
 
-        return null != attrs.get( attrId );
+        return null != getAttributeByOid( attrId, attrs );
     }
 
+    
+    private Attribute getAttributeByOid( String attributeOid, Attributes entry ) throws NamingException
+    {
+        for ( NamingEnumeration ii = entry.getIDs(); ii.hasMore(); /**/ )
+        {
+            String id = ( String ) ii.next();
+            String oid = this.oidRegistry.getOid( id );
+            if ( attributeOid.equals( oid ) )
+            {
+                return entry.get( id );
+            }
+        }
+        return null;
+    }
 
+    
     /**
      * Evaluates a simple equality attribute value assertion on a perspective
      * candidate.
@@ -287,7 +302,8 @@
         }
 
         // get the attribute associated with the node 
-        Attribute attr = rec.getAttributes().get( node.getAttribute() );
+        Attributes attrs = rec.getAttributes();
+        Attribute attr = getAttributeByOid( node.getAttribute(), attrs );
 
         // If we do not have the attribute just return false
         if ( null == attr )



Mime
View raw message