jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1394495 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/security/authentication/token/ main/java/org/apache/jackrabbit/oak/security/principal/ main/java/org/apache/jackrabbit/oak/security/privilege/ main/java/o...
Date Fri, 05 Oct 2012 13:03:55 GMT
Author: angela
Date: Fri Oct  5 13:03:55 2012
New Revision: 1394495

URL: http://svn.apache.org/viewvc?rev=1394495&view=rev
Log:
OAK-50 : Implement User Management (WIP)

- rename Type to AuthorizableType in order avoid confusions with the property Type object

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/AuthorizableType.java
      - copied, changed from r1394488, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/Type.java
Removed:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/Type.java
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
    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/privilege/PrivilegeValidator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableBaseProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/GroupImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ImpersonationImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/MembershipProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserProvider.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserProviderImplTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/token/TokenProviderImpl.java
Fri Oct  5 13:03:55 2012
@@ -44,7 +44,7 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo;
 import org.apache.jackrabbit.oak.spi.security.authentication.token.TokenProvider;
 import org.apache.jackrabbit.oak.spi.security.user.PasswordUtility;
-import org.apache.jackrabbit.oak.spi.security.user.Type;
+import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.UserContext;
 import org.apache.jackrabbit.oak.spi.security.user.UserProvider;
 import org.apache.jackrabbit.oak.util.NodeUtil;
@@ -125,7 +125,7 @@ public class TokenProviderImpl implement
             String userId = sc.getUserID();
             CoreValueFactory valueFactory = root.getValueFactory();
             try {
-                Tree userTree = userProvider.getAuthorizable(userId, Type.USER);
+                Tree userTree = userProvider.getAuthorizable(userId, AuthorizableType.USER);
                 if (userTree != null) {
                     NodeUtil userNode = new NodeUtil(userTree, valueFactory);
                     NodeUtil tokenParent = userNode.getChild(TOKENS_NODE_NAME);

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=1394495&r1=1394494&r2=1394495&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
Fri Oct  5 13:03:55 2012
@@ -30,13 +30,14 @@ import com.google.common.base.Predicates
 import com.google.common.collect.Iterators;
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.namepath.PathMapper;
 import org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal;
 import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
 import org.apache.jackrabbit.oak.spi.security.principal.TreeBasedPrincipal;
+import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.MembershipProvider;
-import org.apache.jackrabbit.oak.spi.security.user.Type;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.oak.spi.security.user.UserProvider;
 import org.slf4j.Logger;
@@ -44,7 +45,6 @@ import org.slf4j.LoggerFactory;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
-import static org.apache.jackrabbit.oak.api.Type.*;
 
 /**
  * The {@code PrincipalProviderImpl} is a principal provider implementation
@@ -100,7 +100,7 @@ public class PrincipalProviderImpl imple
     @Override
     public Set<? extends Principal> getPrincipals(String userID) {
         Set<Principal> principals;
-        Tree userTree = userProvider.getAuthorizable(userID, Type.USER);
+        Tree userTree = userProvider.getAuthorizable(userID, AuthorizableType.USER);
         if (userTree != null) {
             principals = new HashSet<Principal>();
             Principal userPrincipal = new TreeBasedPrincipal(userTree, pathMapper);
@@ -119,7 +119,7 @@ public class PrincipalProviderImpl imple
     public Iterator<? extends Principal> findPrincipals(String nameHint, int searchType)
{
         String[] propNames = new String[] {UserConstants.REP_PRINCIPAL_NAME};
         String[] ntNames = new String[] {UserConstants.NT_REP_AUTHORIZABLE};
-        Iterator<Tree> authorizables = userProvider.findAuthorizables(propNames, nameHint,
ntNames, false, Long.MAX_VALUE, Type.AUTHORIZABLE);
+        Iterator<Tree> authorizables = userProvider.findAuthorizables(propNames, nameHint,
ntNames, false, Long.MAX_VALUE, AuthorizableType.AUTHORIZABLE);
 
         return Iterators.transform(authorizables, new AuthorizableToPrincipal());
     }
@@ -145,7 +145,7 @@ public class PrincipalProviderImpl imple
         checkNotNull(authorizableTree);
         checkState(authorizableTree.hasProperty(JcrConstants.JCR_PRIMARYTYPE));
 
-        String ntName = authorizableTree.getProperty(JcrConstants.JCR_PRIMARYTYPE).getValue(STRING);
+        String ntName = authorizableTree.getProperty(JcrConstants.JCR_PRIMARYTYPE).getValue(Type.STRING);
         return UserConstants.NT_REP_GROUP.equals(ntName);
     }
 
@@ -159,7 +159,7 @@ public class PrincipalProviderImpl imple
             if (tree == null) {
                 throw new IllegalArgumentException("null tree.");
             }
-            if (userProvider.isAuthorizableType(tree, Type.GROUP)) {
+            if (userProvider.isAuthorizableType(tree, AuthorizableType.GROUP)) {
                 return new TreeBasedGroup(tree);
             } else {
                 return new TreeBasedPrincipal(tree, pathMapper);
@@ -193,7 +193,7 @@ public class PrincipalProviderImpl imple
 
         @Override
         public Enumeration<? extends Principal> members() {
-            Iterator<String> declaredMemberPaths = membershipProvider.getMembers(getTree(),
Type.AUTHORIZABLE, false);
+            Iterator<String> declaredMemberPaths = membershipProvider.getMembers(getTree(),
AuthorizableType.AUTHORIZABLE, false);
             Iterator<? extends Principal> members = Iterators.transform(declaredMemberPaths,
new Function<String, Principal>() {
                 @Override
                 public Principal apply(@Nullable String oakPath) {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/PrivilegeValidator.java
Fri Oct  5 13:03:55 2012
@@ -19,13 +19,13 @@ package org.apache.jackrabbit.oak.securi
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-
 import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.core.ReadOnlyTree;
 import org.apache.jackrabbit.oak.plugins.name.NamespaceConstants;
 import org.apache.jackrabbit.oak.spi.commit.Validator;
@@ -33,8 +33,6 @@ import org.apache.jackrabbit.oak.spi.sec
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.util.Text;
 
-import static org.apache.jackrabbit.oak.api.Type.STRING;
-
 /**
  * PrivilegeValidator... TODO
  */
@@ -93,7 +91,7 @@ class PrivilegeValidator implements Priv
         // primary node type name must be rep:privilege
         Tree tree = new ReadOnlyTree(null, name, after);
         PropertyState primaryType = tree.getProperty(JcrConstants.JCR_PRIMARYTYPE);
-        if (primaryType == null || !NT_REP_PRIVILEGE.equals(primaryType.getValue(STRING)))
{
+        if (primaryType == null || !NT_REP_PRIVILEGE.equals(primaryType.getValue(Type.STRING)))
{
             throw new CommitFailedException("Privilege definition must have primary node
type set to rep:privilege");
         }
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableBaseProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableBaseProvider.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableBaseProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/AuthorizableBaseProvider.java
Fri Oct  5 13:03:55 2012
@@ -21,7 +21,7 @@ import org.apache.jackrabbit.oak.api.Cor
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.plugins.identifier.IdentifierManager;
-import org.apache.jackrabbit.oak.spi.security.user.Type;
+import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfig;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.slf4j.Logger;
@@ -51,7 +51,7 @@ abstract class AuthorizableBaseProvider 
         this.identifierManager = new IdentifierManager(root);
     }
 
-    Tree getByID(String authorizableId, Type authorizableType) {
+    Tree getByID(String authorizableId, AuthorizableType authorizableType) {
         Tree tree = identifierManager.getTree(getContentID(authorizableId));
         if (isAuthorizableTree(tree, authorizableType)) {
             return tree;
@@ -62,7 +62,7 @@ abstract class AuthorizableBaseProvider 
 
     Tree getByPath(String authorizableOakPath) {
         Tree tree = root.getTree(authorizableOakPath);
-        if (isAuthorizableTree(tree, Type.AUTHORIZABLE)) {
+        if (isAuthorizableTree(tree, AuthorizableType.AUTHORIZABLE)) {
             return tree;
         } else {
             return null;
@@ -77,7 +77,7 @@ abstract class AuthorizableBaseProvider 
         return identifierManager.getIdentifier(authorizableTree);
     }
 
-    boolean isAuthorizableTree(Tree tree, Type authorizableType) {
+    boolean isAuthorizableTree(Tree tree, AuthorizableType authorizableType) {
         // FIXME: check for node type according to the specified type constraint
         if (tree != null && tree.hasProperty(JcrConstants.JCR_PRIMARYTYPE)) {
             String ntName = tree.getProperty(JcrConstants.JCR_PRIMARYTYPE).getValue(STRING);

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/GroupImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/GroupImpl.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/GroupImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/GroupImpl.java
Fri Oct  5 13:03:55 2012
@@ -32,7 +32,7 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
 import org.apache.jackrabbit.oak.spi.security.principal.TreeBasedPrincipal;
 import org.apache.jackrabbit.oak.spi.security.user.MembershipProvider;
-import org.apache.jackrabbit.oak.spi.security.user.Type;
+import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,7 +52,7 @@ class GroupImpl extends AuthorizableImpl
 
     @Override
     void checkValidTree(Tree tree) throws RepositoryException {
-        if (tree == null || !getUserProvider().isAuthorizableType(tree, Type.GROUP)) {
+        if (tree == null || !getUserProvider().isAuthorizableType(tree, AuthorizableType.GROUP))
{
             throw new IllegalArgumentException("Invalid group node: node type rep:Group expected.");
         }
     }
@@ -177,7 +177,7 @@ class GroupImpl extends AuthorizableImpl
             return uMgr.findAuthorizables(propName, null, UserManager.SEARCH_TYPE_AUTHORIZABLE);
         } else {
             MembershipProvider mMgr = uMgr.getMembershipProvider();
-            Iterator oakPaths = mMgr.getMembers(getTree(), Type.AUTHORIZABLE, includeInherited);
+            Iterator oakPaths = mMgr.getMembers(getTree(), AuthorizableType.AUTHORIZABLE,
includeInherited);
             if (!oakPaths.hasNext()) {
                 AuthorizableIterator iterator = AuthorizableIterator.create(oakPaths, uMgr,
UserManager.SEARCH_TYPE_AUTHORIZABLE);
                 return new RangeIteratorAdapter(iterator, iterator.getSize());

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ImpersonationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ImpersonationImpl.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ImpersonationImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/ImpersonationImpl.java
Fri Oct  5 13:03:55 2012
@@ -28,10 +28,11 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.api.security.user.Impersonation;
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalIteratorAdapter;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
-import org.apache.jackrabbit.oak.spi.security.user.Type;
+import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.oak.spi.security.user.UserProvider;
 import org.slf4j.Logger;
@@ -107,7 +108,7 @@ class ImpersonationImpl implements Imper
         // make sure user does not impersonate himself
         Tree userTree = getUserTree();
         PropertyState prop = userTree.getProperty(REP_PRINCIPAL_NAME);
-        if (prop != null && prop.getValue(org.apache.jackrabbit.oak.api.Type.STRING).equals(principalName))
{
+        if (prop != null && prop.getValue(Type.STRING).equals(principalName)) {
             log.warn("Cannot grant impersonation to oneself.");
             return false;
         }
@@ -196,7 +197,7 @@ class ImpersonationImpl implements Imper
     }
 
     private Tree getUserTree() throws RepositoryException {
-        Tree userTree = userProvider.getAuthorizable(userId, Type.USER);
+        Tree userTree = userProvider.getAuthorizable(userId, AuthorizableType.USER);
         if (userTree == null) {
             throw new RepositoryException("UserId " + userId + " cannot be resolved to user.");
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProviderImpl.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/MembershipProviderImpl.java
Fri Oct  5 13:03:55 2012
@@ -38,7 +38,7 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.plugins.memory.CoreValues;
 import org.apache.jackrabbit.oak.plugins.memory.MultiPropertyState;
 import org.apache.jackrabbit.oak.spi.security.user.MembershipProvider;
-import org.apache.jackrabbit.oak.spi.security.user.Type;
+import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfig;
 import org.apache.jackrabbit.oak.util.NodeUtil;
 import org.slf4j.Logger;
@@ -101,7 +101,7 @@ public class MembershipProviderImpl exte
     //--------------------------------------------------< MembershipProvider>---
     @Override
     public Iterator<String> getMembership(String authorizableId, boolean includeInherited)
{
-        return getMembership(getByID(authorizableId, Type.AUTHORIZABLE), includeInherited);
+        return getMembership(getByID(authorizableId, AuthorizableType.AUTHORIZABLE), includeInherited);
     }
 
     @Override
@@ -126,8 +126,8 @@ public class MembershipProviderImpl exte
     }
 
     @Override
-    public Iterator<String> getMembers(String groupId, Type authorizableType, boolean
includeInherited) {
-        Tree groupTree = getByID(groupId, Type.GROUP);
+    public Iterator<String> getMembers(String groupId, AuthorizableType authorizableType,
boolean includeInherited) {
+        Tree groupTree = getByID(groupId, AuthorizableType.GROUP);
         if (groupTree == null) {
             return Iterators.emptyIterator();
         } else {
@@ -136,7 +136,7 @@ public class MembershipProviderImpl exte
     }
 
     @Override
-    public Iterator<String> getMembers(Tree groupTree, Type authorizableType, boolean
includeInherited) {
+    public Iterator<String> getMembers(Tree groupTree, AuthorizableType authorizableType,
boolean includeInherited) {
         Iterable memberPaths = Collections.emptySet();
         if (useMemberNode(groupTree)) {
             Tree membersTree = groupTree.getChild(REP_MEMBERS);
@@ -275,7 +275,7 @@ public class MembershipProviderImpl exte
      * @return Iterator of Authorizable objects
      */
     private Iterator<String> getAllMembers(final Iterator<String> declaredMembers,
-                                           final Type authorizableType) {
+                                           final AuthorizableType authorizableType) {
         Iterator<Iterator<String>> inheritedMembers = new Iterator<Iterator<String>>()
{
             @Override
             public boolean hasNext() {
@@ -299,7 +299,7 @@ public class MembershipProviderImpl exte
 
             private Iterator<String> inherited(String authorizablePath) {
                 Tree group = getByPath(authorizablePath);
-                if (isAuthorizableTree(group, Type.GROUP)) {
+                if (isAuthorizableTree(group, AuthorizableType.GROUP)) {
                     return getMembers(group, authorizableType, true);
                 } else {
                     return Iterators.emptyIterator();
@@ -329,7 +329,7 @@ public class MembershipProviderImpl exte
 
             private Iterator<String> inherited(String authorizablePath) {
                 Tree group = getByPath(authorizablePath);
-                if (isAuthorizableTree(group, Type.GROUP)) {
+                if (isAuthorizableTree(group, AuthorizableType.GROUP)) {
                     return getMembership(group, true);
                 } else {
                     return Iterators.emptyIterator();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserImpl.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserImpl.java
Fri Oct  5 13:03:55 2012
@@ -28,7 +28,7 @@ import org.apache.jackrabbit.oak.api.Pro
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.spi.security.principal.TreeBasedPrincipal;
 import org.apache.jackrabbit.oak.spi.security.user.PasswordUtility;
-import org.apache.jackrabbit.oak.spi.security.user.Type;
+import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,7 +49,7 @@ class UserImpl extends AuthorizableImpl 
     }
 
     void checkValidTree(Tree tree) throws RepositoryException {
-        if (tree == null || !getUserProvider().isAuthorizableType(tree, Type.USER)) {
+        if (tree == null || !getUserProvider().isAuthorizableType(tree, AuthorizableType.USER))
{
             throw new IllegalArgumentException("Invalid user node: node type rep:User expected.");
         }
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserManagerImpl.java
Fri Oct  5 13:03:55 2012
@@ -39,7 +39,7 @@ import org.apache.jackrabbit.oak.securit
 import org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal;
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
 import org.apache.jackrabbit.oak.spi.security.user.MembershipProvider;
-import org.apache.jackrabbit.oak.spi.security.user.Type;
+import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfig;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.oak.spi.security.user.UserProvider;
@@ -113,7 +113,7 @@ public class UserManagerImpl implements 
     @Override
     public Iterator<Authorizable> findAuthorizables(String relPath, String value, int
searchType) throws RepositoryException {
         String[] oakPaths =  new String[] {namePathMapper.getOakPath(relPath)};
-        Type authorizableType = getAuthorizableType(searchType);
+        AuthorizableType authorizableType = getAuthorizableType(searchType);
         Iterator<Tree> result = userProvider.findAuthorizables(oakPaths, value, null,
true, Long.MAX_VALUE, authorizableType);
 
         return AuthorizableIterator.create(result, this);
@@ -321,9 +321,9 @@ public class UserManagerImpl implements 
         if (id == null || tree == null) {
             return null;
         }
-        if (userProvider.isAuthorizableType(tree, Type.USER)) {
+        if (userProvider.isAuthorizableType(tree, AuthorizableType.USER)) {
             return new UserImpl(userProvider.getAuthorizableId(tree), tree, this);
-        } else if (userProvider.isAuthorizableType(tree, Type.GROUP)) {
+        } else if (userProvider.isAuthorizableType(tree, AuthorizableType.GROUP)) {
             return new GroupImpl(userProvider.getAuthorizableId(tree), tree, this);
         } else {
             throw new RepositoryException("Not a user or group tree " + tree.getPath() +
'.');
@@ -351,14 +351,14 @@ public class UserManagerImpl implements 
         getUserProvider().setProtectedProperty(userTree, UserConstants.REP_PRINCIPAL_NAME,
principal.getName(), PropertyType.STRING);
     }
 
-    private static Type getAuthorizableType(int searchType) {
+    private static AuthorizableType getAuthorizableType(int searchType) {
         switch (searchType) {
             case UserManager.SEARCH_TYPE_USER:
-                return Type.USER;
+                return AuthorizableType.USER;
             case UserManager.SEARCH_TYPE_GROUP:
-                return Type.GROUP;
+                return AuthorizableType.GROUP;
             case UserManager.SEARCH_TYPE_AUTHORIZABLE:
-                return Type.AUTHORIZABLE;
+                return AuthorizableType.AUTHORIZABLE;
             default:
                 throw new IllegalArgumentException("Invalid search type " + searchType);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/user/UserProviderImpl.java
Fri Oct  5 13:03:55 2012
@@ -40,7 +40,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.spi.security.principal.PrincipalProvider;
 import org.apache.jackrabbit.oak.spi.security.principal.TreeBasedPrincipal;
 import org.apache.jackrabbit.oak.spi.security.user.PasswordUtility;
-import org.apache.jackrabbit.oak.spi.security.user.Type;
+import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfig;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.oak.spi.security.user.UserProvider;
@@ -182,11 +182,11 @@ class UserProviderImpl extends Authoriza
 
     @Override
     public Tree getAuthorizable(String authorizableId) {
-        return getByID(authorizableId, Type.AUTHORIZABLE);
+        return getByID(authorizableId, AuthorizableType.AUTHORIZABLE);
     }
 
     @Override
-    public Tree getAuthorizable(String authorizableId, Type authorizableType) {
+    public Tree getAuthorizable(String authorizableId, AuthorizableType authorizableType)
{
         return getByID(authorizableId, authorizableType);
     }
 
@@ -230,7 +230,7 @@ class UserProviderImpl extends Authoriza
     @Override
     public String getAuthorizableId(Tree authorizableTree) {
         checkNotNull(authorizableTree);
-        if (isAuthorizableTree(authorizableTree, Type.AUTHORIZABLE)) {
+        if (isAuthorizableTree(authorizableTree, AuthorizableType.AUTHORIZABLE)) {
             PropertyState idProp = authorizableTree.getProperty(UserConstants.REP_AUTHORIZABLE_ID);
             if (idProp != null) {
                 return idProp.getValue(STRING);
@@ -242,25 +242,25 @@ class UserProviderImpl extends Authoriza
     }
 
     @Override
-    public Iterator<Tree> findAuthorizables(String[] propertyRelPaths, String value,
String[] ntNames, boolean exact, long maxSize, Type authorizableType) {
+    public Iterator<Tree> findAuthorizables(String[] propertyRelPaths, String value,
String[] ntNames, boolean exact, long maxSize, AuthorizableType authorizableType) {
         // TODO
         throw new UnsupportedOperationException("not yet implemented");
     }
 
     @Override
-    public boolean isAuthorizableType(Tree authorizableTree, Type authorizableType) {
+    public boolean isAuthorizableType(Tree authorizableTree, AuthorizableType authorizableType)
{
         return isAuthorizableTree(authorizableTree, authorizableType);
     }
 
     @Override
     public boolean isAdminUser(Tree userTree) {
         checkNotNull(userTree);
-        return isAuthorizableType(userTree, Type.USER) && config.getAdminId().equals(getAuthorizableId(userTree));
+        return isAuthorizableType(userTree, AuthorizableType.USER) && config.getAdminId().equals(getAuthorizableId(userTree));
     }
 
     @Override
     public String getPassword(String userID) {
-        Tree userTree = getAuthorizable(userID, Type.USER);
+        Tree userTree = getAuthorizable(userID, AuthorizableType.USER);
         if (userTree != null) {
             NodeUtil n = new NodeUtil(userTree, valueFactory);
             return n.getString(UserConstants.REP_PASSWORD, null);

Copied: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/AuthorizableType.java
(from r1394488, jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/Type.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/AuthorizableType.java?p2=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/AuthorizableType.java&p1=jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/Type.java&r1=1394488&r2=1394495&rev=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/Type.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/AuthorizableType.java
Fri Oct  5 13:03:55 2012
@@ -23,7 +23,7 @@ import org.apache.jackrabbit.api.securit
 /**
  * The different authorizable types.
  */
-public enum Type {
+public enum AuthorizableType {
 
     USER(UserManager.SEARCH_TYPE_USER),
     GROUP(UserManager.SEARCH_TYPE_GROUP),
@@ -31,7 +31,7 @@ public enum Type {
 
     private final int userType;
 
-    private Type(int userType) {
+    private AuthorizableType(int userType) {
         this.userType = userType;
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/MembershipProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/MembershipProvider.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/MembershipProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/MembershipProvider.java
Fri Oct  5 13:03:55 2012
@@ -34,10 +34,10 @@ public interface MembershipProvider {
     Iterator<String> getMembership(Tree authorizableTree, boolean includeInherited);
 
     @Nonnull
-    Iterator<String> getMembers(String groupId, Type authorizableType, boolean includeInherited);
+    Iterator<String> getMembers(String groupId, AuthorizableType authorizableType,
boolean includeInherited);
 
     @Nonnull
-    Iterator<String> getMembers(Tree groupTree, Type authorizableType, boolean includeInherited);
+    Iterator<String> getMembers(Tree groupTree, AuthorizableType authorizableType,
boolean includeInherited);
 
     boolean isMember(Tree groupTree, Tree authorizableTree, boolean includeInherited);
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserProvider.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserProvider.java
Fri Oct  5 13:03:55 2012
@@ -42,7 +42,7 @@ public interface UserProvider {
     Tree getAuthorizable(String authorizableId);
 
     @CheckForNull
-    Tree getAuthorizable(String authorizableId, Type authorizableType);
+    Tree getAuthorizable(String authorizableId, AuthorizableType authorizableType);
 
     @CheckForNull
     Tree getAuthorizableByPath(String authorizableOakPath);
@@ -70,7 +70,7 @@ public interface UserProvider {
      * @param exact A boolean flag indicating if the value must match exactly or not.s
      * @param maxSize The maximal number of search results to look for.
      * @param authorizableType Filter the search results to only return authorizable
-     * trees of a given type. Passing {@link Type#AUTHORIZABLE} indicates that
+     * trees of a given type. Passing {@link AuthorizableType#AUTHORIZABLE} indicates that
      * no filtering for a specific authorizable type is desired. However, properties
      * might still be search in the complete sub-tree of authorizables depending
      * on the other query parameters.
@@ -79,9 +79,9 @@ public interface UserProvider {
      * found.
      */
     @Nonnull
-    Iterator<Tree> findAuthorizables(String[] propertyRelPaths, String value, String[]
ntNames, boolean exact, long maxSize, Type authorizableType);
+    Iterator<Tree> findAuthorizables(String[] propertyRelPaths, String value, String[]
ntNames, boolean exact, long maxSize, AuthorizableType authorizableType);
 
-    boolean isAuthorizableType(Tree authorizableTree, Type authorizableType);
+    boolean isAuthorizableType(Tree authorizableTree, AuthorizableType authorizableType);
 
     boolean isAdminUser(Tree userTree);
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserProviderImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserProviderImplTest.java?rev=1394495&r1=1394494&r2=1394495&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserProviderImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/user/UserProviderImplTest.java
Fri Oct  5 13:03:55 2012
@@ -32,7 +32,7 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexHook;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
-import org.apache.jackrabbit.oak.spi.security.user.Type;
+import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.UserConfig;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
 import org.apache.jackrabbit.oak.spi.security.user.UserProvider;
@@ -291,23 +291,23 @@ public class UserProviderImplTest extend
         Tree user = up.createUser(userID, null);
         root.commit();
 
-        Tree a = up.getAuthorizable(userID, Type.USER);
+        Tree a = up.getAuthorizable(userID, AuthorizableType.USER);
         assertNotNull(a);
         assertEquals(user.getPath(), a.getPath());
 
-        assertNotNull(up.getAuthorizable(userID, Type.AUTHORIZABLE));
-        assertNull(up.getAuthorizable(userID, Type.GROUP));
+        assertNotNull(up.getAuthorizable(userID, AuthorizableType.AUTHORIZABLE));
+        assertNull(up.getAuthorizable(userID, AuthorizableType.GROUP));
 
         String groupID = "hr";
         Tree group = up.createGroup(groupID, null);
         root.commit();
 
-        Tree g = up.getAuthorizable(groupID, Type.GROUP);
+        Tree g = up.getAuthorizable(groupID, AuthorizableType.GROUP);
         assertNotNull(a);
         assertEquals(user.getPath(), a.getPath());
 
-        assertNotNull(up.getAuthorizable(groupID, Type.AUTHORIZABLE));
-        assertNull(up.getAuthorizable(groupID, Type.USER));
+        assertNotNull(up.getAuthorizable(groupID, AuthorizableType.AUTHORIZABLE));
+        assertNull(up.getAuthorizable(groupID, AuthorizableType.USER));
     }
 
     @Test



Mime
View raw message