directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vte...@apache.org
Subject svn commit: rev 57047 - incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization
Date Tue, 09 Nov 2004 14:55:49 GMT
Author: vtence
Date: Tue Nov  9 06:55:48 2004
New Revision: 57047

Added:
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/AuthorizationController.java
   incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/DefaultAuthorizationController.java
Log:
Authorization service frontend (temporary naming)

Added: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/AuthorizationController.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/AuthorizationController.java
Tue Nov  9 06:55:48 2004
@@ -0,0 +1,24 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authorization;
+
+import javax.security.auth.Subject;
+
+public interface AuthorizationController
+{
+    boolean authorize( Subject s, Permission p );
+}

Added: incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/DefaultAuthorizationController.java
==============================================================================
--- (empty file)
+++ incubator/directory/janus/trunk/sandbox/src/java/org/apache/janus/authorization/DefaultAuthorizationController.java
Tue Nov  9 06:55:48 2004
@@ -0,0 +1,63 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.janus.authorization;
+
+import org.apache.janus.authorization.effect.Effects;
+
+import javax.security.auth.Subject;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Warning: to be renamed to DefaultAuthorizer when moved out of sandbox
+ */
+public class DefaultAuthorizationController implements AuthorizationController
+{
+    private final Map m_decisions;
+    private Rule m_rule;
+
+    public DefaultAuthorizationController()
+    {
+        m_decisions = new HashMap();
+        m_decisions.put( Effects.GRANT, Boolean.TRUE );
+        m_decisions.put( Effects.NOT_APPLICABLE, Boolean.TRUE );
+        m_decisions.put( Effects.DENY, Boolean.FALSE );
+    }
+
+    public boolean authorize( Subject s, Permission p )
+    {
+        Effect effect = m_rule.evaluate( s, p );
+        Boolean decision = ( Boolean ) m_decisions.get( effect );
+
+        return decision.booleanValue();
+    }
+
+    public void setRuleBase( Rule rule )
+    {
+        m_rule = rule;
+    }
+
+    public void grantOn( Effect effect )
+    {
+        m_decisions.put( effect, Boolean.TRUE );
+    }
+
+    public void denyOn( Effect effect )
+    {
+        m_decisions.put( effect, Boolean.FALSE );
+    }
+}

Mime
View raw message