directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r664455 - in /directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core: CoreSession.java DefaultCoreSession.java
Date Sun, 08 Jun 2008 06:41:55 GMT
Author: akarasulu
Date: Sat Jun  7 23:41:54 2008
New Revision: 664455

URL: http://svn.apache.org/viewvc?rev=664455&view=rev
Log:
added isAdminstrator() and isAnAdministrator() methods on CoreSession

Modified:
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/CoreSession.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/CoreSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/CoreSession.java?rev=664455&r1=664454&r2=664455&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/CoreSession.java
(original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/CoreSession.java
Sat Jun  7 23:41:54 2008
@@ -26,6 +26,7 @@
 
 import javax.naming.ldap.Control;
 
+import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
@@ -132,6 +133,27 @@
     
     
     /**
+     * Returns true if the effective principal associated with this session is 
+     * the administrator.
+     * 
+     * @see {@link ServerDNConstants#ADMIN_SYSTEM_DN}
+     * @return true if authorized as the administrator, false otherwise
+     */
+    boolean isAdministrator();
+    
+    
+    /**
+     * Returns true if the effective principal associated with this session is 
+     * the administrator or is within the administrators group.
+     *
+     * @see {@link ServerDNConstants#ADMIN_SYSTEM_DN}
+     * @see {@link ServerDNConstants#ADMINISTRATORS_GROUP_DN}
+     * @return true if authorized as an administrator, false otherwise
+     */
+    boolean isAnAdministrator();
+    
+    
+    /**
      * Gets the authentication level associated with this session.
      * 
      * @return the authentication level associated with the session

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java?rev=664455&r1=664454&r2=664455&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java
(original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java
Sat Jun  7 23:41:54 2008
@@ -26,6 +26,7 @@
 
 import javax.naming.ldap.Control;
 
+import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
@@ -41,6 +42,7 @@
 import org.apache.directory.server.core.interceptor.context.OperationContext;
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
+import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -207,6 +209,41 @@
         // TODO Auto-generated method stub
         return true;
     }
+    
+    
+    /**
+     * TODO - perhaps we should just use a flag that is calculated on creation
+     * of this session
+     *  
+     * @see org.apache.directory.server.core.CoreSession#isAdministrator()
+     */
+    public boolean isAdministrator()
+    {
+        String normName = getEffectivePrincipal().getJndiName().toNormName(); 
+        return normName.equals( ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );
+    }
+
+
+    /**
+     * TODO - this method impl does not check to see if the principal is in 
+     * the administrators group - it only returns true of the principal is
+     * the actual admin user.  need to make it check groups.
+     * 
+     * TODO - perhaps we should just use a flag that is calculated on creation
+     * of this session
+     *  
+     * @see org.apache.directory.server.core.CoreSession#isAnAdministrator()
+     */
+    public boolean isAnAdministrator()
+    {
+        if ( isAdministrator() )
+        {
+            return true;
+        }
+        
+        // TODO fix this so it checks groups
+        return false;
+    }
 
 
     /* (non-Javadoc)



Mime
View raw message