directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r526230 - in /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core: authn/ authz/ interceptor/context/ jndi/ normalization/ partition/ partition/impl/btree/
Date Fri, 06 Apr 2007 17:28:58 GMT
Author: elecharny
Date: Fri Apr  6 10:28:56 2007
New Revision: 526230

URL: http://svn.apache.org/viewvc?view=rev&rev=526230
Log:
Added an intermediate abstract class to handle the DN, and removed the painfull casts all
over the code
Added a toString() method to the BindContext class

Added:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractServiceContext.java
Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/BindServiceContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/EntryServiceContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/LookupServiceContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/ServiceContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindServiceContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
Fri Apr  6 10:28:56 2007
@@ -265,7 +265,7 @@
     {
         if ( IS_DEBUG )
         {
-            log.debug( "Testing if entry name = '" + ((EntryServiceContext)entryContext).getEntryDn().getUpName()
+ "' exists" );
+            log.debug( "Testing if entry name = '" + entryContext.getDn().getUpName() + "'
exists" );
         }
 
         checkAuthenticated();
@@ -451,11 +451,9 @@
     public void bind( NextInterceptor next, ServiceContext bindContext )
     throws NamingException
     {   
-        BindServiceContext bindCtx = (BindServiceContext)bindContext;
-        
         // The DN is always normalized here
-        LdapDN normBindDn = bindCtx.getBindDn();
-        String bindUpDn = bindCtx.getBindDn().getUpName();
+        LdapDN normBindDn = bindContext.getDn();
+        String bindUpDn = bindContext.getDn().getUpName();
         
         if ( IS_DEBUG )
         {
@@ -484,7 +482,7 @@
         // pick the first matching authenticator type
         Collection<Authenticator> authenticators = null;
         
-        for ( String mechanism:bindCtx.getMechanisms() )
+        for ( String mechanism:((BindServiceContext)bindContext).getMechanisms() )
         {
             authenticators = getAuthenticators( mechanism );
     
@@ -499,7 +497,7 @@
             log.debug( "No authenticators found, delegating bind to the nexus." );
             
             // as a last resort try binding via the nexus
-            next.bind( bindCtx );
+            next.bind( bindContext );
             
             log.debug( "Nexus succeeded on bind operation." );
             

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
Fri Apr  6 10:28:56 2007
@@ -610,7 +610,7 @@
 
     public boolean hasEntry( NextInterceptor next, ServiceContext entryContext ) throws NamingException
     {
-        LdapDN name = ((EntryServiceContext)entryContext).getEntryDn();
+        LdapDN name = entryContext.getDn();
         Invocation invocation = InvocationStack.getInstance().peek();
         PartitionNexusProxy proxy = invocation.getProxy();
         Attributes entry = proxy.lookup( new LookupServiceContext( name ), PartitionNexusProxy.LOOKUP_BYPASS
);

Added: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractServiceContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractServiceContext.java?view=auto&rev=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractServiceContext.java
(added)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractServiceContext.java
Fri Apr  6 10:28:56 2007
@@ -0,0 +1,73 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.interceptor.context;
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+/**
+ * This abstract class stores common context elements, like the DN, which is used
+ * in all the contexts.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AbstractServiceContext implements ServiceContext
+{
+    /** The DN associated with the context */
+    private LdapDN dn;
+    
+    /**
+     * 
+     * Creates a new instance of AbstractServiceContext.
+     *
+     */
+    public AbstractServiceContext()
+    {
+    }
+
+    /**
+     * 
+     * Creates a new instance of AbstractServiceContext.
+     *
+     * @param dn The associated DN
+     */
+    public AbstractServiceContext( LdapDN dn )
+    {
+        this.dn = dn;
+    }
+
+    /**
+     * @return The associated DN
+     */
+    public LdapDN getDn()
+    {
+        return dn;
+    }
+
+    /**
+     * Set the context DN
+     *
+     * @param dn The DN to set
+     */
+    public void setDn( LdapDN dn )
+    {
+        this.dn = dn;
+    }
+}

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/BindServiceContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/BindServiceContext.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/BindServiceContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/BindServiceContext.java
Fri Apr  6 10:28:56 2007
@@ -21,7 +21,7 @@
 
 import java.util.List;
 
-import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.StringTools;
 
 /**
  * A Bind context used for Interceptors. It contains all the informations
@@ -30,11 +30,8 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class BindServiceContext implements ServiceContext
+public class BindServiceContext extends AbstractServiceContext
 {
-    /** The principal DN */
-    private LdapDN bindDn;
-
     /** The list of supported mechanisms */
     private List<String> mechanisms;
     
@@ -45,24 +42,6 @@
     private String saslAuthId;
     
     /**
-     * @return The Principal's DN
-     */
-    public LdapDN getBindDn()
-    {
-        return bindDn;
-    }
-    
-    /**
-     * Set the principal's DN.
-     *
-     * @param bindDn The principal's DN
-     */
-    public void setBindDn( LdapDN bindDn )
-    {
-        this.bindDn = bindDn;
-    }
-
-    /**
      * @return The list of supported mechanisms
      */
     public List<String> getMechanisms()
@@ -99,5 +78,16 @@
     public void setSaslAuthId( String saslAuthId )
     {
         this.saslAuthId = saslAuthId;
+    }
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "BindContext for DN '" + getDn().getUpName() + "', credentials <" +
+            ( credentials != null ? StringTools.dumpBytes( credentials ) : "" ) + ">"
+
+            ( ( mechanisms != null ) ? ", mechanisms : <" + StringTools.listToString(
mechanisms ) + ">" : "" ) +
+            ( saslAuthId != null ? ", saslAuthId <" + saslAuthId + ">" : "" );
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/EntryServiceContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/EntryServiceContext.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/EntryServiceContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/EntryServiceContext.java
Fri Apr  6 10:28:56 2007
@@ -28,11 +28,8 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class EntryServiceContext implements ServiceContext
+public class EntryServiceContext  extends AbstractServiceContext
 {
-    /** The entry DN */
-    private LdapDN entryDn;
-
     /**
      * Creates a new instance of EntryServiceContext.
      */
@@ -47,25 +44,7 @@
      */
     public EntryServiceContext( LdapDN entryDn )
     {
-        this.entryDn = entryDn;
-    }
-    
-    /**
-     * @return The Entry DN
-     */
-    public LdapDN getEntryDn()
-    {
-        return entryDn;
-    }
-    
-    /**
-     * Set the Entry DN.
-     *
-     * @param entryDn The Entry DN
-     */
-    public void setEntryDn( LdapDN entryDn )
-    {
-        this.entryDn = entryDn;
+        super( entryDn );
     }
     
     /**
@@ -73,6 +52,6 @@
      */
     public String toString()
     {
-        return "EntryContext for DN '" + entryDn.getUpName() + "'";
+        return "EntryContext for DN '" + getDn().getUpName() + "'";
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/LookupServiceContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/LookupServiceContext.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/LookupServiceContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/LookupServiceContext.java
Fri Apr  6 10:28:56 2007
@@ -33,7 +33,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class LookupServiceContext implements ServiceContext
+public class LookupServiceContext  extends AbstractServiceContext
 {
     /** The entry DN */
     private LdapDN dn;

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/ServiceContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/ServiceContext.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/ServiceContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/ServiceContext.java
Fri Apr  6 10:28:56 2007
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.server.core.interceptor.context;
 
+import org.apache.directory.shared.ldap.name.LdapDN;
+
 /**
  * This interface represent the context passed as an argument to each interceptor.
  * It will contain data used by all the operations.
@@ -28,5 +30,16 @@
  */
 public interface ServiceContext
 {
+    /**
+     * @return The associated DN
+     */
+    LdapDN getDn();
+    
+    /**
+     * Set the context DN
+     *
+     * @param dn The DN to set
+     */
+    void setDn( LdapDN dn );
 
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindServiceContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindServiceContext.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindServiceContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindServiceContext.java
Fri Apr  6 10:28:56 2007
@@ -28,16 +28,14 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class UnbindServiceContext implements ServiceContext
+public class UnbindServiceContext  extends AbstractServiceContext
 {
-    /** The principal DN */
-    private LdapDN unbindDn;
-
     /**
      * Creates a new instance of UnbindServiceContext.
      */
     public UnbindServiceContext()
     {
+        super();
     }
     
     /**
@@ -47,25 +45,7 @@
      */
     public UnbindServiceContext( LdapDN unbindDn )
     {
-        this.unbindDn = unbindDn;
-    }
-    
-    /**
-     * @return The Principal's DN
-     */
-    public LdapDN getUnbindDn()
-    {
-        return unbindDn;
-    }
-    
-    /**
-     * Set the principal's DN.
-     *
-     * @param unbindDn The principal's DN
-     */
-    public void setUnbindDn( LdapDN unbindDn )
-    {
-        this.unbindDn = unbindDn;
+        super( unbindDn );
     }
     
     /**
@@ -73,6 +53,6 @@
      */
     public String toString()
     {
-        return "UnbindContext for DN '" + unbindDn.getUpName() + "'";
+        return "UnbindContext for DN '" + getDn().getUpName() + "'";
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
Fri Apr  6 10:28:56 2007
@@ -127,7 +127,7 @@
         dn = props.getProviderDn();
         
         BindServiceContext bindContext = new BindServiceContext();
-        bindContext.setBindDn( props.getBindDn() );
+        bindContext.setDn( props.getBindDn() );
         bindContext.setCredentials( props.getCredentials() );
         bindContext.setMechanisms( props.getAuthenticationMechanisms() );
         bindContext.setSaslAuthId( props.getSaslAuthId() );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationService.java
Fri Apr  6 10:28:56 2007
@@ -347,7 +347,7 @@
 
     public boolean hasEntry( NextInterceptor nextInterceptor, ServiceContext entryContext
) throws NamingException
     {
-        LdapDN.normalize( ((EntryServiceContext)entryContext).getEntryDn(), attrNormalizers
);
+        LdapDN.normalize( entryContext.getDn(), attrNormalizers );
         return nextInterceptor.hasEntry( entryContext );
     }
 
@@ -393,7 +393,7 @@
     
     public void bind( NextInterceptor next, ServiceContext ctx )  throws NamingException
     {
-        LdapDN.normalize( ((BindServiceContext)ctx).getBindDn(), attrNormalizers );
+        LdapDN.normalize(ctx.getDn(), attrNormalizers );
         next.bind( ctx );
     }
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
Fri Apr  6 10:28:56 2007
@@ -196,7 +196,7 @@
     {
         try
         {
-            return lookup( new LookupServiceContext( ((EntryServiceContext)entryContext).getEntryDn()
) ) != null;
+            return lookup( new LookupServiceContext( entryContext.getDn() ) ) != null;
         }
         catch ( NameNotFoundException e )
         {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
Fri Apr  6 10:28:56 2007
@@ -667,13 +667,13 @@
     // ------------------------------------------------------------------------
     public void bind( ServiceContext bindContext ) throws NamingException
     {
-        Partition partition = getBackend( ((BindServiceContext)bindContext).getBindDn() );
+        Partition partition = getBackend( bindContext.getDn() );
         partition.bind( bindContext );
     }
 
     public void unbind( ServiceContext unbindContext ) throws NamingException
     {
-        Partition partition = getBackend( ((UnbindServiceContext)unbindContext).getUnbindDn()
);
+        Partition partition = getBackend( unbindContext.getDn() );
         partition.unbind( unbindContext );
     }
 
@@ -930,7 +930,7 @@
      */
     public boolean hasEntry( ServiceContext entryContext ) throws NamingException
     {
-        LdapDN dn = ((EntryServiceContext)entryContext).getEntryDn();
+        LdapDN dn = entryContext.getDn();
         
         if ( IS_DEBUG )
         {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?view=diff&rev=526230&r1=526229&r2=526230
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
Fri Apr  6 10:28:56 2007
@@ -464,7 +464,7 @@
 
     public boolean hasEntry( ServiceContext entryContext ) throws NamingException
     {
-        return null != getEntryId( ((EntryServiceContext)entryContext).getEntryDn().getNormName()
);
+        return null != getEntryId( entryContext.getDn().getNormName() );
     }
 
 



Mime
View raw message