directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: rev 47379 - in incubator/directory/janus/trunk/sandbox/src: java/org/apache/janus/authorization java/org/apache/janus/authorization/effect test/org/apache/janus/authorization
Date Tue, 28 Sep 2004 03:31:54 GMT
Author: vtence
Date: Mon Sep 27 20:31:53 2004
New Revision: 47379

Removed:
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/BasicRule.java
   incubator/directory/janus/trunk/sandbox/src/test/org/apache/janus/authorization/DefaultPolicyTest.java
Modified:
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/Effect.java
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/Policy.java
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/DenyEffect.java
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/DenyOverridesEffect.java
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/FirstApplicableEffect.java
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/GrantEffect.java
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/IndeterminateEffect.java
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/LastApplicableEffect.java
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/NotApplicableEffect.java
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/PermitOverridesEffect.java
   incubator/directory/janus/trunk/sandbox/src/test/org/apache/janus/authorization/DefaultRuleTest.java
Log:
Refactored rule system

Modified: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/Effect.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/Effect.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/Effect.java
Mon Sep 27 20:31:53 2004
@@ -21,7 +21,9 @@
  */
 public interface Effect
 {
-    Effect combineWith( Effect effect );
+    Effect and( Effect effect );
+
+    Effect applyTo( Effect effect );
 
     Effect permit();
 
@@ -29,5 +31,5 @@
 
     Effect indeterminate();
 
-    boolean resolve( EffectResolver effectResolver );
+    boolean resolve( EffectResolver resolver );
 }

Modified: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/Policy.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/Policy.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/Policy.java
Mon Sep 27 20:31:53 2004
@@ -42,15 +42,15 @@
 
     public Effect evaluate( Subject s, Permission p )
     {
-        Effect effect = m_effect;
+        Effect netEffect = m_effect;
 
         for ( Iterator it = m_rules.iterator(); it.hasNext(); )
         {
             Rule rule = ( Rule ) it.next();
             Effect e = rule.evaluate( s, p );
-            effect = e.combineWith( effect );
+            netEffect = netEffect.and( e );
         }
 
-        return effect;
+        return netEffect;
     }
 }

Modified: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/DenyEffect.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/DenyEffect.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/DenyEffect.java
Mon Sep 27 20:31:53 2004
@@ -24,7 +24,12 @@
  */
 public final class DenyEffect implements Effect
 {
-    public Effect combineWith( Effect effect )
+    public Effect and( Effect effect )
+    {
+        return this;
+    }
+
+    public Effect applyTo( Effect effect )
     {
         return effect.deny();
     }
@@ -44,7 +49,7 @@
         return this;
     }
 
-    public boolean resolve( EffectResolver effectResolver )
+    public boolean resolve( EffectResolver resolver )
     {
         return false;
     }

Modified: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/DenyOverridesEffect.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/DenyOverridesEffect.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/DenyOverridesEffect.java
Mon Sep 27 20:31:53 2004
@@ -36,9 +36,14 @@
         m_effect = effect;
     }
 
-    public Effect combineWith( Effect effect )
+    public Effect applyTo( Effect effect )
     {
-        return m_effect.combineWith( effect );
+        return effect.and( m_effect );
+    }
+
+    public Effect and( Effect effect )
+    {
+        return effect.applyTo( this );
     }
 
     public Effect permit()
@@ -56,8 +61,8 @@
         return new DenyOverridesEffect( new IndeterminateEffect() );
     }
 
-    public boolean resolve( EffectResolver effectResolver )
+    public boolean resolve( EffectResolver resolver )
     {
-        return m_effect.resolve( effectResolver );
+        return m_effect.resolve( resolver );
     }
 }

Modified: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/FirstApplicableEffect.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/FirstApplicableEffect.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/FirstApplicableEffect.java
Mon Sep 27 20:31:53 2004
@@ -36,9 +36,14 @@
         m_effect = effect;
     }
 
-    public Effect combineWith( Effect effect )
+    public Effect applyTo( Effect effect )
     {
-        return m_effect.combineWith( effect );
+        return effect.and( m_effect );
+    }
+
+    public Effect and( Effect effect )
+    {
+        return effect.applyTo( this );
     }
 
     public Effect permit()
@@ -56,8 +61,8 @@
         return new IndeterminateEffect();
     }
 
-    public boolean resolve( EffectResolver effectResolver )
+    public boolean resolve( EffectResolver resolver )
     {
-        return m_effect.resolve( effectResolver );
+        return m_effect.resolve( resolver );
     }
 }

Modified: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/GrantEffect.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/GrantEffect.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/GrantEffect.java
Mon Sep 27 20:31:53 2004
@@ -24,7 +24,12 @@
  */
 public final class GrantEffect implements Effect
 {
-    public Effect combineWith( Effect effect )
+    public Effect and( Effect effect )
+    {
+        return this;
+    }
+
+    public Effect applyTo( Effect effect )
     {
         return effect.permit();
     }
@@ -44,7 +49,7 @@
         return this;
     }
 
-    public boolean resolve( EffectResolver effectResolver )
+    public boolean resolve( EffectResolver resolver )
     {
         return true;
     }

Modified: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/IndeterminateEffect.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/IndeterminateEffect.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/IndeterminateEffect.java
Mon Sep 27 20:31:53 2004
@@ -24,7 +24,12 @@
  */
 public final class IndeterminateEffect implements Effect
 {
-    public Effect combineWith( Effect effect )
+    public Effect and( Effect effect )
+    {
+        return this;
+    }
+
+    public Effect applyTo( Effect effect )
     {
         return effect.indeterminate();
     }
@@ -44,8 +49,8 @@
         return this;
     }
 
-    public boolean resolve( EffectResolver effectResolver )
+    public boolean resolve( EffectResolver resolver )
     {
-        return effectResolver.indeterminate();
+        return resolver.indeterminate();
     }
 }

Modified: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/LastApplicableEffect.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/LastApplicableEffect.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/LastApplicableEffect.java
Mon Sep 27 20:31:53 2004
@@ -36,9 +36,14 @@
         m_effect = effect;
     }
 
-    public Effect combineWith( Effect effect )
+    public Effect applyTo( Effect effect )
     {
-        return m_effect.combineWith( effect );
+        return effect.and( m_effect );
+    }
+
+    public Effect and( Effect effect )
+    {
+        return effect.applyTo( this );
     }
 
     public Effect permit()
@@ -56,8 +61,8 @@
         return new LastApplicableEffect( new IndeterminateEffect() );
     }
 
-    public boolean resolve( EffectResolver effectResolver )
+    public boolean resolve( EffectResolver resolver )
     {
-        return m_effect.resolve( effectResolver );
+        return m_effect.resolve( resolver );
     }
 }

Modified: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/NotApplicableEffect.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/NotApplicableEffect.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/NotApplicableEffect.java
Mon Sep 27 20:31:53 2004
@@ -24,7 +24,12 @@
  */
 public final class NotApplicableEffect implements Effect
 {
-    public Effect combineWith( Effect effect )
+    public Effect and( Effect effect )
+    {
+        return this;
+    }
+
+    public Effect applyTo( Effect effect )
     {
         return effect;
     }
@@ -44,8 +49,8 @@
         return this;
     }
 
-    public boolean resolve( EffectResolver effectResolver )
+    public boolean resolve( EffectResolver resolver )
     {
-        return effectResolver.notApplicable();
+        return resolver.notApplicable();
     }
 }

Modified: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/PermitOverridesEffect.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/PermitOverridesEffect.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/effect/PermitOverridesEffect.java
Mon Sep 27 20:31:53 2004
@@ -36,9 +36,14 @@
         m_effect = effect;
     }
 
-    public Effect combineWith( Effect effect )
+    public Effect applyTo( Effect effect )
     {
-        return m_effect.combineWith( effect );
+        return effect.and( m_effect );
+    }
+
+    public Effect and( Effect effect )
+    {
+        return effect.applyTo( this );
     }
 
     public Effect permit()
@@ -56,8 +61,8 @@
         return new PermitOverridesEffect( new IndeterminateEffect() );
     }
 
-    public boolean resolve( EffectResolver effectResolver )
+    public boolean resolve( EffectResolver resolver )
     {
-        return m_effect.resolve( effectResolver );
+        return m_effect.resolve( resolver );
     }
 }

Modified: incubator/directory/janus/trunk/sandbox/src/test/org/apache/janus/authorization/DefaultRuleTest.java
==============================================================================
--- incubator/directory/janus/trunk/sandbox/src/test/org/apache/janus/authorization/DefaultRuleTest.java
(original)
+++ incubator/directory/janus/trunk/sandbox/src/test/org/apache/janus/authorization/DefaultRuleTest.java
Mon Sep 27 20:31:53 2004
@@ -59,7 +59,7 @@
         assertTrue( m_rule.evaluate( john() ) instanceof GrantEffect );
     }
 
-    public void testIsNotApplicableIsSubjectConditionNotVerified()
+    public void testIsNotApplicableIfSubjectConditionIsNotVerified()
     {
         m_rule = new DefaultRule( new GrantEffect() );
         m_rule.setSubjectCondition( new FalsePredicate() );

Mime
View raw message