jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1375614 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/ oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/ oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/...
Date Tue, 21 Aug 2012 15:39:56 GMT
Author: angela
Date: Tue Aug 21 15:39:56 2012
New Revision: 1375614

URL: http://svn.apache.org/viewvc?rev=1375614&view=rev
Log:
OAK-90 : Implement Principal Management (WIP)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/TmpPrincipalProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/PrincipalProvider.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalManagerImpl.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImpl.java?rev=1375614&r1=1375613&r2=1375614&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/PrincipalProviderImpl.java
Tue Aug 21 15:39:56 2012
@@ -112,6 +112,12 @@ public class PrincipalProviderImpl imple
         return principals;
     }
 
+    @Override
+    public Iterator<Principal> findPrincipals(String nameHint, int searchType) {
+        // TODO add implementation
+        throw new UnsupportedOperationException("TODO: PrincipalProvide#findPrincipals");
+    }
+
     //------------------------------------------------------------< private >---
 
     private Set<Group> getGroupMembership(Tree authorizableTree) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/TmpPrincipalProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/TmpPrincipalProvider.java?rev=1375614&r1=1375613&r2=1375614&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/TmpPrincipalProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/principal/TmpPrincipalProvider.java
Tue Aug 21 15:39:56 2012
@@ -20,6 +20,7 @@ import java.security.Principal;
 import java.security.acl.Group;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Set;
 
 import org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal;
@@ -61,4 +62,9 @@ public class TmpPrincipalProvider implem
         return principals;
     }
 
+    @Override
+    public Iterator<Principal> findPrincipals(String nameHint, int searchType) {
+        throw new UnsupportedOperationException("not implemented");
+    }
+
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProvider.java?rev=1375614&r1=1375613&r2=1375614&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/principal/CompositePrincipalProvider.java
Tue Aug 21 15:39:56 2012
@@ -19,9 +19,11 @@ package org.apache.jackrabbit.oak.spi.se
 import java.security.Principal;
 import java.security.acl.Group;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 
+import com.google.common.collect.Iterators;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -68,4 +70,14 @@ public class CompositePrincipalProvider 
         }
         return principals;
     }
+
+    @Override
+    public Iterator<Principal> findPrincipals(String nameHint, int searchType) {
+        Iterator<? extends Principal>[] iterators = new Iterator[providers.size()];
+        int i = 0;
+        for (PrincipalProvider provider : providers) {
+            iterators[i++] = provider.findPrincipals(nameHint, searchType);
+        }
+        return Iterators.concat(iterators);
+    }
 }
\ 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=1375614&r1=1375613&r2=1375614&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
Tue Aug 21 15:39:56 2012
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.spi.se
 
 import java.security.Principal;
 import java.security.acl.Group;
+import java.util.Iterator;
 import java.util.Set;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
@@ -65,4 +66,18 @@ public interface PrincipalProvider {
      */
     @Nonnull
     Set<Principal> getPrincipals(String userID);
+
+    /**
+     * Find the principals that match the specified nameHint and search type.
+     *
+     * @param nameHint A name hint to use for non-exact matching.
+     * @param searchType Limit the search to certain types of principals. Valid
+     * values are any of
+     * <ul><li>{@link org.apache.jackrabbit.api.security.principal.PrincipalManager#SEARCH_TYPE_ALL}</li></ul>
+     * <ul><li>{@link org.apache.jackrabbit.api.security.principal.PrincipalManager#SEARCH_TYPE_NOT_GROUP}</li></ul>
+     * <ul><li>{@link org.apache.jackrabbit.api.security.principal.PrincipalManager#SEARCH_TYPE_GROUP}</li></ul>
+     * @return An iterator of principals.
+     */
+    @Nonnull
+    Iterator<Principal> findPrincipals(String nameHint, int searchType);
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalManagerImpl.java?rev=1375614&r1=1375613&r2=1375614&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalManagerImpl.java
Tue Aug 21 15:39:56 2012
@@ -16,25 +16,18 @@
  */
 package org.apache.jackrabbit.oak.jcr.security.principal;
 
+import java.security.Principal;
+
 import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
 import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.security.Principal;
 
 /**
  * PrincipalManagerImpl...
  */
 public class PrincipalManagerImpl implements PrincipalManager {
 
-    /**
-     * logger instance
-     */
-    private static final Logger log = LoggerFactory.getLogger(PrincipalManagerImpl.class);
-
     private final PrincipalProvider principalProvider;
 
     public PrincipalManagerImpl(PrincipalProvider principalProvider) {
@@ -53,20 +46,17 @@ public class PrincipalManagerImpl implem
 
     @Override
     public PrincipalIterator findPrincipals(String simpleFilter) {
-        // TODO
-        return null;
+        return findPrincipals(simpleFilter, PrincipalManager.SEARCH_TYPE_ALL);
     }
 
     @Override
     public PrincipalIterator findPrincipals(String simpleFilter, int searchType) {
-        // TODO
-        return null;
+        return new PrincipalIteratorAdapter(principalProvider.findPrincipals(simpleFilter,
searchType));
     }
 
     @Override
     public PrincipalIterator getPrincipals(int searchType) {
-        // TODO
-        return null;
+        throw new UnsupportedOperationException("not implemented");
     }
 
     @Override



Mime
View raw message