jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1373921 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: security/principal/KernelPrincipalProvider.java spi/security/principal/PrincipalProvider.java spi/security/privilege/CompositePrincipalProvider.java
Date Thu, 16 Aug 2012 17:01:58 GMT
Author: angela
Date: Thu Aug 16 17:01:58 2012
New Revision: 1373921

URL: http://svn.apache.org/viewvc?rev=1373921&view=rev
Log:
OAK-90 : Implement Principal Management  (work in progress)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/KernelPrincipalProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/KernelPrincipalProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/KernelPrincipalProvider.java?rev=1373921&r1=1373920&r2=1373921&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/KernelPrincipalProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/KernelPrincipalProvider.java
Thu Aug 16 17:01:58 2012
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.securi
 import java.security.Principal;
 import java.security.acl.Group;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
@@ -29,7 +30,7 @@ import org.slf4j.LoggerFactory;
 /**
  * The {@code KernelPrincipalProvider} is a principal provider implementation
  * that operates on principal information read from user information stored
- * in the{@code MicroKernel}.
+ * in the {@code MicroKernel}.
  */
 public class KernelPrincipalProvider implements PrincipalProvider {
 
@@ -56,4 +57,14 @@ public class KernelPrincipalProvider imp
         // TODO
         return Collections.<Group>singleton(EveryonePrincipal.getInstance());
     }
+
+    @Override
+    public Set<Principal> getPrincipals(String userID) {
+        // TODO
+        Set<Principal> principals = new HashSet<Principal>();
+        Principal p = getPrincipal(userID);
+        principals.add(p);
+        principals.addAll(getGroupMembership(p));
+        return principals;
+    }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalProvider.java?rev=1373921&r1=1373920&r2=1373921&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalProvider.java
Thu Aug 16 17:01:58 2012
@@ -19,6 +19,8 @@ package org.apache.jackrabbit.oak.spi.se
 import java.security.Principal;
 import java.security.acl.Group;
 import java.util.Set;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
 
 /**
  * PrincipalProvider... TODO
@@ -32,6 +34,7 @@ public interface PrincipalProvider {
      * @param principalName the name of the principal to retrieve
      * @return return the requested principal or {@code null}
      */
+    @CheckForNull
     Principal getPrincipal(String principalName);
 
     /**
@@ -48,5 +51,18 @@ public interface PrincipalProvider {
      * @return an iterator returning all groups the given principal is member of.
      * @see java.security.acl.Group#isMember(java.security.Principal)
      */
+    @Nonnull
     Set<Group> getGroupMembership(Principal principal);
+
+    /**
+     * Tries to resolve the specified {@code userID} to a valid principal and
+     * it's group membership. This method returns an empty set if the
+     * specified ID cannot be resolved.
+     *
+     * @param userID A userID.
+     * @return The set of principals associated with the specified {@code userID}
+     * or an empty set if it cannot be resolved.
+     */
+    @Nonnull
+    Set<Principal> getPrincipals(String userID);
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java?rev=1373921&r1=1373920&r2=1373921&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/CompositePrincipalProvider.java
Thu Aug 16 17:01:58 2012
@@ -37,6 +37,7 @@ public class CompositePrincipalProvider 
     private final List<PrincipalProvider> providers;
 
     public CompositePrincipalProvider(List<PrincipalProvider> providers) {
+        assert providers != null;
         this.providers = providers;
     }
 
@@ -59,4 +60,13 @@ public class CompositePrincipalProvider 
         }
         return groups;
     }
+
+    @Override
+    public Set<Principal> getPrincipals(String userID) {
+        Set<Principal> principals = new HashSet<Principal>();
+        for (PrincipalProvider provider : providers) {
+            principals.addAll(provider.getPrincipals(userID));
+        }
+        return principals;
+    }
 }
\ No newline at end of file



Mime
View raw message