jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1409767 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: spi/security/user/AuthorizableType.java spi/security/user/UserConstants.java spi/security/user/util/UserUtility.java util/NodeUtil.java
Date Thu, 15 Nov 2012 13:13:24 GMT
Author: angela
Date: Thu Nov 15 13:13:23 2012
New Revision: 1409767

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

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/AuthorizableType.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConstants.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtility.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/AuthorizableType.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/AuthorizableType.java?rev=1409767&r1=1409766&r2=1409767&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/AuthorizableType.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/AuthorizableType.java
Thu Nov 15 13:13:23 2012
@@ -18,6 +18,8 @@
  */
 package org.apache.jackrabbit.oak.spi.security.user;
 
+import javax.annotation.Nonnull;
+
 import org.apache.jackrabbit.api.security.user.Authorizable;
 import org.apache.jackrabbit.api.security.user.UserManager;
 
@@ -36,6 +38,7 @@ public enum AuthorizableType {
         this.userType = jcrUserType;
     }
 
+    @Nonnull
     public static AuthorizableType getType(int jcrUserType) {
         switch (jcrUserType) {
             case UserManager.SEARCH_TYPE_AUTHORIZABLE:

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConstants.java?rev=1409767&r1=1409766&r2=1409767&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConstants.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/UserConstants.java
Thu Nov 15 13:13:23 2012
@@ -16,9 +16,9 @@
  */
 package org.apache.jackrabbit.oak.spi.security.user;
 
-import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
+
+import com.google.common.collect.ImmutableSet;
 
 /**
  * UserConstants...
@@ -38,19 +38,19 @@ public interface UserConstants {
     String REP_MEMBERS = "rep:members";
     String REP_IMPERSONATORS = "rep:impersonators";
 
-    Collection<String> GROUP_PROPERTY_NAMES = Collections.unmodifiableList(Arrays.asList(
+    Collection<String> GROUP_PROPERTY_NAMES = ImmutableSet.of(
             REP_PRINCIPAL_NAME,
             REP_AUTHORIZABLE_ID,
             REP_MEMBERS
-    ));
+    );
 
-    Collection<String> USER_PROPERTY_NAMES = Collections.unmodifiableList(Arrays.asList(
+    Collection<String> USER_PROPERTY_NAMES = ImmutableSet.of(
             REP_PRINCIPAL_NAME,
             REP_AUTHORIZABLE_ID,
             REP_PASSWORD,
             REP_DISABLED,
             REP_IMPERSONATORS
-    ));
+    );
 
     /**
      * Configuration option defining the ID of the administrator user.
@@ -135,4 +135,4 @@ public interface UserConstants {
      * password hash generation.
      */
     String PARAM_PASSWORD_SALT_SIZE = "passwordSaltSize";
-}
\ No newline at end of file
+}

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtility.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtility.java?rev=1409767&r1=1409766&r2=1409767&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtility.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/user/util/UserUtility.java
Thu Nov 15 13:13:23 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak.spi.security.user.util;
 
+import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.JcrConstants;
@@ -23,6 +24,7 @@ import org.apache.jackrabbit.oak.api.Tre
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
 import org.apache.jackrabbit.oak.spi.security.user.AuthorizableType;
 import org.apache.jackrabbit.oak.spi.security.user.UserConstants;
+import org.apache.jackrabbit.oak.util.NodeUtil;
 
 import static org.apache.jackrabbit.oak.api.Type.STRING;
 
@@ -56,4 +58,17 @@ public final class UserUtility implement
         }
         return false;
     }
+
+    @CheckForNull
+    public static AuthorizableType getType(NodeUtil authorizableNode) {
+        String ntName = authorizableNode.getPrimaryNodeTypeName();
+        if (ntName != null) {
+            if (UserConstants.NT_REP_GROUP.equals(ntName)) {
+                return AuthorizableType.GROUP;
+            } else if (UserConstants.NT_REP_USER.equals(ntName)) {
+                return AuthorizableType.USER;
+            }
+        }
+        return null;
+    }
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java?rev=1409767&r1=1409766&r2=1409767&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/util/NodeUtil.java
Thu Nov 15 13:13:23 2012
@@ -144,7 +144,12 @@ public class NodeUtil {
     }
 
     public boolean hasPrimaryNodeTypeName(String ntName) {
-        return ntName.equals(getString(JcrConstants.JCR_PRIMARYTYPE, null));
+        return ntName.equals(getPrimaryNodeTypeName());
+    }
+
+    @CheckForNull
+    public String getPrimaryNodeTypeName() {
+        return getString(JcrConstants.JCR_PRIMARYTYPE, null);
     }
 
     public void removeProperty(String name) {



Mime
View raw message