directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1198598 - in /directory/apacheds/branches/apacheds-osgi: core-api/src/main/java/org/apache/directory/server/core/api/interceptor/ interceptors/authz/src/main/java/org/apache/directory/server/core/authz/ interceptors/changelog/src/main/java...
Date Mon, 07 Nov 2011 01:03:05 GMT
Author: kayyagari
Date: Mon Nov  7 01:03:04 2011
New Revision: 1198598

URL: http://svn.apache.org/viewvc?rev=1198598&view=rev
Log:
o changed the getPrincipal() method to take the OperationContext as parameter instead of depending
on InvocationStack

Modified:
    directory/apacheds/branches/apacheds-osgi/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/BaseInterceptor.java
    directory/apacheds/branches/apacheds-osgi/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
    directory/apacheds/branches/apacheds-osgi/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
    directory/apacheds/branches/apacheds-osgi/interceptors/changelog/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
    directory/apacheds/branches/apacheds-osgi/interceptors/journal/src/main/java/org/apache/directory/server/core/journal/JournalInterceptor.java
    directory/apacheds/branches/apacheds-osgi/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java

Modified: directory/apacheds/branches/apacheds-osgi/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/BaseInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/BaseInterceptor.java?rev=1198598&r1=1198597&r2=1198598&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/BaseInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/core-api/src/main/java/org/apache/directory/server/core/api/interceptor/BaseInterceptor.java
Mon Nov  7 01:03:04 2011
@@ -129,22 +129,12 @@ public abstract class BaseInterceptor im
     /**
      * TODO delete this since it uses static access
      * Returns {@link LdapPrincipal} of current context.
+     * @param opContext TODO
      * @return the authenticated principal
      */
-    public static LdapPrincipal getPrincipal()
+    public static LdapPrincipal getPrincipal( OperationContext opContext )
     {
-        return getContext().getSession().getEffectivePrincipal();
-    }
-
-
-    /**
-     * TODO delete this since it uses static access
-     * Returns the current JNDI {@link Context}.
-     * @return the context on the invocation stack
-     */
-    public static OperationContext getContext()
-    {
-        return InvocationStack.getInstance().peek();
+        return opContext.getSession().getEffectivePrincipal();
     }
 
 

Modified: directory/apacheds/branches/apacheds-osgi/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java?rev=1198598&r1=1198597&r2=1198598&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
Mon Nov  7 01:03:04 2011
@@ -302,9 +302,9 @@ public class AciAuthorizationInterceptor
     }
 
 
-    private void protectCriticalEntries( Dn dn ) throws LdapException
+    private void protectCriticalEntries( OperationContext opCtx, Dn dn ) throws LdapException
     {
-        Dn principalDn = getPrincipal().getDn();
+        Dn principalDn = getPrincipal( opCtx ).getDn();
 
         if ( dn.isEmpty() )
         {
@@ -615,7 +615,7 @@ public class AciAuthorizationInterceptor
 
         Entry entry = deleteContext.getEntry();
 
-        protectCriticalEntries( dn );
+        protectCriticalEntries( deleteContext, dn );
 
         // bypass authz code but manage caches if operation is performed by the admin
         if ( isPrincipalAnAdministrator( principalDn ) )
@@ -988,7 +988,7 @@ public class AciAuthorizationInterceptor
             return;
         }
 
-        protectCriticalEntries( oldName );
+        protectCriticalEntries( renameContext, oldName );
 
         // bypass authz code but manage caches if operation is performed by the admin
         if ( isPrincipalAnAdministrator( principalDn ) )
@@ -1044,7 +1044,7 @@ public class AciAuthorizationInterceptor
             return;
         }
 
-        protectCriticalEntries( oldDn );
+        protectCriticalEntries( moveAndRenameContext, oldDn );
 
         // bypass authz code but manage caches if operation is performed by the admin
         if ( isPrincipalAnAdministrator( principalDn ) )
@@ -1140,7 +1140,7 @@ public class AciAuthorizationInterceptor
             return;
         }
 
-        protectCriticalEntries( oriChildName );
+        protectCriticalEntries( moveContext, oriChildName );
 
         // bypass authz code but manage caches if operation is performed by the admin
         if ( isPrincipalAnAdministrator( principalDn ) )

Modified: directory/apacheds/branches/apacheds-osgi/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java?rev=1198598&r1=1198597&r2=1198598&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
Mon Nov  7 01:03:04 2011
@@ -176,7 +176,7 @@ public class DefaultAuthorizationInterce
             throw new LdapNoPermissionException( msg );
         }
 
-        Dn principalDn = getPrincipal().getDn();
+        Dn principalDn = getPrincipal( deleteContext ).getDn();
 
         if ( dn.equals( ADMIN_SYSTEM_DN ) )
         {
@@ -234,7 +234,7 @@ public class DefaultAuthorizationInterce
         {
             Dn dn = modifyContext.getDn();
 
-            protectModifyAlterations( dn );
+            protectModifyAlterations( modifyContext, dn );
             nextInterceptor.modify( modifyContext );
 
             // update administrators if we change administrators group
@@ -250,9 +250,9 @@ public class DefaultAuthorizationInterce
     }
 
 
-    private void protectModifyAlterations( Dn dn ) throws LdapException
+    private void protectModifyAlterations( OperationContext opCtx, Dn dn ) throws LdapException
     {
-        Dn principalDn = getPrincipal().getDn();
+        Dn principalDn = getPrincipal( opCtx ).getDn();
 
         if ( dn.isEmpty() )
         {
@@ -264,7 +264,7 @@ public class DefaultAuthorizationInterce
         if ( !isAnAdministrator( principalDn ) )
         {
             // allow self modifications
-            if ( dn.equals( getPrincipal() ) )
+            if ( dn.equals( getPrincipal( opCtx ) ) )
             {
                 return;
             }
@@ -309,7 +309,7 @@ public class DefaultAuthorizationInterce
     {
         if ( !renameContext.getSession().getDirectoryService().isAccessControlEnabled() )
         {
-            protectDnAlterations( renameContext.getDn() );
+            protectDnAlterations( renameContext, renameContext.getDn() );
         }
 
         nextInterceptor.rename( renameContext );
@@ -323,7 +323,7 @@ public class DefaultAuthorizationInterce
     {
         if ( !moveContext.getSession().getDirectoryService().isAccessControlEnabled() )
         {
-            protectDnAlterations( moveContext.getDn() );
+            protectDnAlterations( moveContext, moveContext.getDn() );
         }
 
         nextInterceptor.move( moveContext );
@@ -335,16 +335,16 @@ public class DefaultAuthorizationInterce
     {
         if ( !moveAndRenameContext.getSession().getDirectoryService().isAccessControlEnabled()
)
         {
-            protectDnAlterations( moveAndRenameContext.getDn() );
+            protectDnAlterations( moveAndRenameContext, moveAndRenameContext.getDn() );
         }
 
         nextInterceptor.moveAndRename( moveAndRenameContext );
     }
 
 
-    private void protectDnAlterations( Dn dn ) throws LdapException
+    private void protectDnAlterations( OperationContext opCtx, Dn dn ) throws LdapException
     {
-        Dn principalDn = getPrincipal().getDn();
+        Dn principalDn = getPrincipal( opCtx ).getDn();
 
         if ( dn.isEmpty() )
         {

Modified: directory/apacheds/branches/apacheds-osgi/interceptors/changelog/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/interceptors/changelog/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java?rev=1198598&r1=1198597&r2=1198598&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/interceptors/changelog/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/interceptors/changelog/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
Mon Nov  7 01:03:04 2011
@@ -125,7 +125,7 @@ public class ChangeLogInterceptor extend
         }
         
         LdifEntry reverse = LdifRevertor.reverseAdd( addContext.getDn() );
-        addContext.setChangeLogEvent( changeLog.log( getPrincipal(), forward, reverse ) );
+        addContext.setChangeLogEvent( changeLog.log( getPrincipal( addContext ), forward,
reverse ) );
     }
 
 
@@ -177,7 +177,7 @@ public class ChangeLogInterceptor extend
         }
 
         LdifEntry reverse = LdifRevertor.reverseDel( deleteContext.getDn(), reverseEntry
);
-        deleteContext.setChangeLogEvent( changeLog.log( getPrincipal(), forward, reverse
) );
+        deleteContext.setChangeLogEvent( changeLog.log( getPrincipal( deleteContext ), forward,
reverse ) );
     }
 
 
@@ -282,7 +282,7 @@ public class ChangeLogInterceptor extend
             mods, 
             clientEntry );
         
-        modifyContext.setChangeLogEvent( changeLog.log( getPrincipal(), forward, reverse
) );
+        modifyContext.setChangeLogEvent( changeLog.log( getPrincipal( modifyContext ), forward,
reverse ) );
     }
 
 
@@ -319,7 +319,7 @@ public class ChangeLogInterceptor extend
         List<LdifEntry> reverses = LdifRevertor.reverseRename( 
             serverEntry, renameContext.getNewRdn(), renameContext.getDeleteOldRdn() );
         
-        renameContext.setChangeLogEvent( changeLog.log( getPrincipal(), forward, reverses
) );
+        renameContext.setChangeLogEvent( changeLog.log( getPrincipal( renameContext ), forward,
reverses ) );
     }
 
 
@@ -358,7 +358,7 @@ public class ChangeLogInterceptor extend
             reversedEntry.addControl( new ManageDsaITImpl() );
         }
         
-        moveAndRenameContext.setChangeLogEvent( changeLog.log( getPrincipal(), forward, reverses
) );
+        moveAndRenameContext.setChangeLogEvent( changeLog.log( getPrincipal( moveAndRenameContext
), forward, reverses ) );
     }
 
 
@@ -380,6 +380,6 @@ public class ChangeLogInterceptor extend
         forward.setNewSuperior( moveContext.getNewSuperior().getName() );
 
         LdifEntry reverse = LdifRevertor.reverseMove(moveContext.getNewSuperior(), moveContext.getDn());
-        moveContext.setChangeLogEvent( changeLog.log( getPrincipal(), forward, reverse )
);
+        moveContext.setChangeLogEvent( changeLog.log( getPrincipal( moveContext ), forward,
reverse ) );
     }
 }

Modified: directory/apacheds/branches/apacheds-osgi/interceptors/journal/src/main/java/org/apache/directory/server/core/journal/JournalInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/interceptors/journal/src/main/java/org/apache/directory/server/core/journal/JournalInterceptor.java?rev=1198598&r1=1198597&r2=1198598&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/interceptors/journal/src/main/java/org/apache/directory/server/core/journal/JournalInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/interceptors/journal/src/main/java/org/apache/directory/server/core/journal/JournalInterceptor.java
Mon Nov  7 01:03:04 2011
@@ -19,7 +19,6 @@
 package org.apache.directory.server.core.journal;
 
 
-import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.directory.server.core.api.DirectoryService;
@@ -30,6 +29,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.MoveAndRenameOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.OperationContext;
 import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.api.journal.Journal;
 import org.apache.directory.shared.ldap.model.entry.Attribute;
@@ -89,9 +89,9 @@ public class JournalInterceptor extends 
     /**
      * Log the operation, manage the logs rotations.
      */
-    private void log( long revision, LdifEntry ldif ) throws LdapException
+    private void log( OperationContext opCtx, long revision, LdifEntry ldif ) throws LdapException
     {
-        journal.log( getPrincipal(), revision, ldif );
+        journal.log( getPrincipal( opCtx ), revision, ldif );
     }
     
     
@@ -122,7 +122,7 @@ public class JournalInterceptor extends 
                 ldif.addAttribute( addEntry.get( attributeType).clone() );
             }
             
-            log( opRevision, ldif );
+            log( addContext, opRevision, ldif );
         }
 
         try
@@ -164,7 +164,7 @@ public class JournalInterceptor extends 
             ldif.setChangeType( ChangeType.Delete );
             ldif.setDn( deleteContext.getDn() );
             
-            journal.log( getPrincipal(), opRevision, ldif );
+            journal.log( getPrincipal( deleteContext ), opRevision, ldif );
         }
 
         try
@@ -212,7 +212,7 @@ public class JournalInterceptor extends 
                 ldif.addModification( modification );
             }
             
-            journal.log( getPrincipal(), opRevision, ldif );
+            journal.log( getPrincipal( modifyContext ), opRevision, ldif );
         }
         
         try
@@ -255,7 +255,7 @@ public class JournalInterceptor extends 
             ldif.setNewRdn( renameContext.getNewRdn().getNormName() );
             ldif.setDeleteOldRdn( renameContext.getDeleteOldRdn() );
             
-            journal.log( getPrincipal(), opRevision, ldif );
+            journal.log( getPrincipal( renameContext ), opRevision, ldif );
         }
         
         try
@@ -301,7 +301,7 @@ public class JournalInterceptor extends 
             ldif.setDeleteOldRdn( moveAndRenameContext.getDeleteOldRdn() );
             ldif.setNewSuperior( moveAndRenameContext.getNewDn().getNormName() );
             
-            journal.log( getPrincipal(), opRevision, ldif );
+            journal.log( getPrincipal( moveAndRenameContext ), opRevision, ldif );
         }
         
         try
@@ -344,7 +344,7 @@ public class JournalInterceptor extends 
             ldif.setDn( moveContext.getDn() );
             ldif.setNewSuperior( moveContext.getNewSuperior().getNormName() );
             
-            journal.log( getPrincipal(), opRevision, ldif );
+            journal.log( getPrincipal( moveContext ), opRevision, ldif );
         }
         
         try

Modified: directory/apacheds/branches/apacheds-osgi/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-osgi/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java?rev=1198598&r1=1198597&r2=1198598&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-osgi/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-osgi/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
Mon Nov  7 01:03:04 2011
@@ -182,7 +182,7 @@ public class OperationalAttributeInterce
      */
     public void add( NextInterceptor nextInterceptor, AddOperationContext addContext ) throws
LdapException
     {
-        String principal = getPrincipal().getName();
+        String principal = getPrincipal( addContext ).getName();
 
         Entry entry = addContext.getEntry();
 
@@ -307,7 +307,7 @@ public class OperationalAttributeInterce
         if ( !modifierAtPresent )
         {
             // Inject the ModifiersName AT if it's not present
-            Attribute attribute = new DefaultAttribute( MODIFIERS_NAME_AT, getPrincipal()
+            Attribute attribute = new DefaultAttribute( MODIFIERS_NAME_AT, getPrincipal(
modifyContext )
                 .getName() );
 
             Modification modifiersName = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
attribute );
@@ -342,11 +342,11 @@ public class OperationalAttributeInterce
     public void rename( NextInterceptor nextInterceptor, RenameOperationContext renameContext
) throws LdapException
     {
         Entry entry = ( ( ClonedServerEntry ) renameContext.getEntry() ).getClonedEntry();
-        entry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
+        entry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal( renameContext ).getName()
);
         entry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
 
         Entry modifiedEntry = renameContext.getOriginalEntry().clone();
-        modifiedEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
+        modifiedEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal( renameContext
).getName() );
         modifiedEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()
);
         //modifiedEntry.setDn( renameContext.getNewDn() );
         renameContext.setModifiedEntry( modifiedEntry );
@@ -361,7 +361,7 @@ public class OperationalAttributeInterce
     public void move( NextInterceptor nextInterceptor, MoveOperationContext moveContext )
throws LdapException
     {
         Entry modifiedEntry = moveContext.getOriginalEntry().clone();
-        modifiedEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
+        modifiedEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal( moveContext ).getName()
);
         modifiedEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()
);
         modifiedEntry.setDn( moveContext.getNewDn() );
         moveContext.setModifiedEntry( modifiedEntry );
@@ -374,7 +374,7 @@ public class OperationalAttributeInterce
         throws LdapException
     {
         Entry modifiedEntry = moveAndRenameContext.getOriginalEntry().clone();
-        modifiedEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
+        modifiedEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal( moveAndRenameContext
).getName() );
         modifiedEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime()
);
         modifiedEntry.setDn( moveAndRenameContext.getNewDn() );
         moveAndRenameContext.setModifiedEntry( modifiedEntry );



Mime
View raw message