directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: r123106 - /incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java /incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java
Date Wed, 22 Dec 2004 15:05:24 GMT
Author: vtence
Date: Wed Dec 22 07:05:18 2004
New Revision: 123106

URL: http://svn.apache.org/viewcvs?view=rev&rev=123106
Log:
Simplified DefaultAuthorizer to work with a root RuleSet
Modified:
   incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java
   incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java

Modified: incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java?view=diff&rev=123106&p1=incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java&r1=123105&p2=incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java&r2=123106
==============================================================================
--- incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java
(original)
+++ incubator/directory/janus/trunk/core/impl/src/java/org/apache/janus/authorization/DefaultAuthorizer.java
Wed Dec 22 07:05:18 2004
@@ -17,7 +17,6 @@
 package org.apache.janus.authorization;
 
 import org.apache.janus.authorization.effect.Effects;
-import org.apache.janus.authorization.effect.PermitOverridesEffect;
 
 import javax.security.auth.Subject;
 import java.util.HashMap;
@@ -28,14 +27,9 @@
  */
 public class DefaultAuthorizer implements Authorizer
 {
-    private boolean m_defaultDecision;
     private final Map m_decisions;
-    private RuleSet m_ruleSet;
-
-    public DefaultAuthorizer()
-    {
-        this( new Policy( new PermitOverridesEffect() ) );
-    }
+    private final RuleSet m_ruleSet;
+    private boolean m_defaultDecision;
 
     public DefaultAuthorizer( RuleSet ruleSet )
     {
@@ -55,11 +49,6 @@
         return decision != null ? decision.booleanValue() : m_defaultDecision;
     }
 
-    public void setRuleSet( RuleSet ruleSet )
-    {
-        m_ruleSet = ruleSet;
-    }
-
     public void grantOn( Effect effect )
     {
         m_decisions.put( effect, Boolean.TRUE );
@@ -68,11 +57,6 @@
     public void denyOn( Effect effect )
     {
         m_decisions.put( effect, Boolean.FALSE );
-    }
-
-    public void addRule( Rule rule )
-    {
-        m_ruleSet.addRule( rule );
     }
 
     public void grantIfUnsure()

Modified: incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java
Url: http://svn.apache.org/viewcvs/incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java?view=diff&rev=123106&p1=incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java&r1=123105&p2=incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java&r2=123106
==============================================================================
--- incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java
(original)
+++ incubator/directory/janus/trunk/core/impl/src/test/org/apache/janus/authorization/DefaultAuthorizerTest.java
Wed Dec 22 07:05:18 2004
@@ -31,65 +31,46 @@
         junit.textui.TestRunner.run( DefaultAuthorizerTest.class );
     }
 
-    protected void setUp() throws Exception
-    {
-        m_authorizer = new DefaultAuthorizer();
-    }
-
     public void testTakesPositiveDecisionIfRuleSuggestsPermission()
     {
-        m_authorizer.setRuleSet( new Policy( Effects.GRANT ) );
+        m_authorizer = new DefaultAuthorizer( new Policy( Effects.GRANT ) );
         m_authorizer.denyIfUnsure();
         assertTrue( m_authorizer.authorize( new Subject(), new SomePermission() ) );
     }
 
     public void testTakesPositiveDecisionIfRuleIsNotApplicable()
     {
-        m_authorizer.setRuleSet( new Policy( Effects.NOT_APPLICABLE ) );
+        m_authorizer = new DefaultAuthorizer( new Policy( Effects.NOT_APPLICABLE ) );
         m_authorizer.denyIfUnsure();
         assertTrue( m_authorizer.authorize( new Subject(), new SomePermission() ) );
     }
 
     public void testTakesNegativeDecisionIfRuleSuggestDenial()
     {
-        m_authorizer.setRuleSet( new Policy( Effects.DENY ) );
+        m_authorizer = new DefaultAuthorizer( new Policy( Effects.DENY ) );
         m_authorizer.grantIfUnsure();
         assertFalse( m_authorizer.authorize( new Subject(), new SomePermission() ) );
     }
 
-    public void testTakesPositiveDecisionByDefault()
-    {
-        assertTrue( m_authorizer.authorize( new Subject(), new SomePermission() ) );
-    }
-
     public void testCanForceEffectToGrantDecision()
     {
-        m_authorizer.setRuleSet( new Policy( Effects.DENY ) );
+        m_authorizer = new DefaultAuthorizer( new Policy( Effects.DENY ) );
         m_authorizer.grantOn( Effects.DENY );
         assertTrue( m_authorizer.authorize( new Subject(), new SomePermission() ) );
     }
 
     public void testCanForceEffectToDenyDecision()
     {
-        m_authorizer.setRuleSet( new Policy( Effects.NOT_APPLICABLE ) );
+        m_authorizer = new DefaultAuthorizer( new Policy( Effects.NOT_APPLICABLE ) );
         m_authorizer.denyOn( Effects.NOT_APPLICABLE );
         assertFalse( m_authorizer.authorize( new Subject(), new SomePermission() ) );
     }
 
     public void testEffectsAreReducedBeforeTakingDecision()
     {
-        m_authorizer.setRuleSet( new Policy( new PermitOverridesEffect() ) );
+        m_authorizer = new DefaultAuthorizer( new Policy( new PermitOverridesEffect() ) );
         m_authorizer.grantIfUnsure();
         m_authorizer.denyOn( Effects.NOT_APPLICABLE );
         assertFalse( m_authorizer.authorize( new Subject(), new SomePermission() ) );
-    }
-
-    public void testRulesCanBeAdded()
-    {
-        m_authorizer.setRuleSet( new Policy( new PermitOverridesEffect() ) );
-        m_authorizer.addRule( new PrimitiveRule( Effects.GRANT ) );
-        m_authorizer.denyIfUnsure();
-        m_authorizer.denyOn( Effects.NOT_APPLICABLE );
-        assertTrue( m_authorizer.authorize( new Subject(), new SomePermission() ) );
     }
 }

Mime
View raw message