jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdue...@apache.org
Subject svn commit: r1325715 - in /jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security: principal/ privileges/ user/
Date Fri, 13 Apr 2012 10:53:47 GMT
Author: mduerig
Date: Fri Apr 13 10:53:47 2012
New Revision: 1325715

URL: http://svn.apache.org/viewvc?rev=1325715&view=rev
Log:
OAK-64 : Privilege Management (WIP)
minor cleanup: 
- typos
- reduced usage of raw types
- removed redundant exceptions from implementation classes
- used @code instead of <code></code>

Modified:
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalIteratorAdapter.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/privileges/PrivilegeManagerImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/privileges/diff.txt
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableNodeCreator.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/ImpersonationImpl.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/PasswordUtility.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerConfig.java
    jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalIteratorAdapter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalIteratorAdapter.java?rev=1325715&r1=1325714&r2=1325715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalIteratorAdapter.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/principal/PrincipalIteratorAdapter.java
Fri Apr 13 10:53:47 2012
@@ -20,6 +20,7 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.commons.iterator.RangeIteratorAdapter;
 import org.apache.jackrabbit.commons.iterator.RangeIteratorDecorator;
 
+import javax.jcr.RangeIterator;
 import java.security.Principal;
 import java.util.Collection;
 import java.util.Iterator;
@@ -38,6 +39,14 @@ public class PrincipalIteratorAdapter ex
      */
     public static final PrincipalIteratorAdapter EMPTY = new PrincipalIteratorAdapter(RangeIteratorAdapter.EMPTY);
 
+    /**
+     * Creates an adapter for the given {@link javax.jcr.RangeIterator}.
+     *
+     * @param iterator iterator of {@link java.security.Principal}s
+     */
+    public PrincipalIteratorAdapter(RangeIterator iterator) {
+        super(iterator);
+    }
 
     /**
      * Creates an adapter for the given {@link java.util.Iterator} of principals.
@@ -49,7 +58,7 @@ public class PrincipalIteratorAdapter ex
     }
 
     /**
-     * Creates an iterator for the given collection of <code>Principal</code>s.
+     * Creates an iterator for the given collection of {@code Principal}s.
      *
      * @param collection collection of {@link Principal} objects.
      */
@@ -64,6 +73,7 @@ public class PrincipalIteratorAdapter ex
      * @return next policy.
      * @throws java.util.NoSuchElementException if there is no next policy.
      */
+    @Override
     public Principal nextPrincipal() throws NoSuchElementException {
         return (Principal) next();
     }

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/privileges/PrivilegeManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/privileges/PrivilegeManagerImpl.java?rev=1325715&r1=1325714&r2=1325715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/privileges/PrivilegeManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/privileges/PrivilegeManagerImpl.java
Fri Apr 13 10:53:47 2012
@@ -19,10 +19,10 @@ package org.apache.jackrabbit.oak.jcr.se
 import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
 import org.apache.jackrabbit.oak.jcr.NodeImpl;
 import org.apache.jackrabbit.oak.jcr.SessionContext;
+import org.apache.jackrabbit.oak.jcr.SessionImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import javax.jcr.AccessDeniedException;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
@@ -55,9 +55,9 @@ public class PrivilegeManagerImpl implem
     private static final String REP_IS_ABSTRACT = "rep:isAbstract";
     private static final String REP_CONTAINS = "rep:contains";
 
-    private final SessionContext sessionContext;
+    private final SessionContext<SessionImpl> sessionContext;
 
-    public PrivilegeManagerImpl(SessionContext sessionContext) throws RepositoryException
{
+    public PrivilegeManagerImpl(SessionContext<SessionImpl> sessionContext) {
         this.sessionContext = sessionContext;
         // TODO: add additional validation ??
     }
@@ -77,7 +77,7 @@ public class PrivilegeManagerImpl implem
     }
 
     @Override
-    public Privilege getPrivilege(String privilegeName) throws AccessControlException, RepositoryException
{
+    public Privilege getPrivilege(String privilegeName) throws RepositoryException {
         NodeImpl privilegeRoot = getPrivilegeRoot();
         if (privilegeRoot.hasNode(privilegeName)) {
             return getPrivilege(privilegeRoot.getNode(privilegeName), new HashMap<String,
Privilege>(1));
@@ -89,7 +89,7 @@ public class PrivilegeManagerImpl implem
     @Override
     public Privilege registerPrivilege(String privilegeName, boolean isAbstract,
                                        String[] declaredAggregateNames)
-            throws AccessDeniedException, RepositoryException {
+            throws RepositoryException {
 
         // TODO
         return null;
@@ -153,7 +153,7 @@ public class PrivilegeManagerImpl implem
 
         @Override
         public boolean isAggregate() {
-            return declaredAggregateNames.size() > 0;
+            return !declaredAggregateNames.isEmpty();
         }
 
         @Override

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/privileges/diff.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/privileges/diff.txt?rev=1325715&r1=1325714&r2=1325715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/privileges/diff.txt
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/privileges/diff.txt
Fri Apr 13 10:53:47 2012
@@ -10,7 +10,7 @@ TODO:
 ================================================================================
 
 - PrivilegeManager#registerPrivilege
-  missing implementataion (still struggling with oak-api. what we need here
+  missing implementation (still struggling with oak-api. what we need here
   was the ability to add multiple items at once without the jcr-layer being able
   to retrieve those items before they are being persisted)....
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java?rev=1325715&r1=1325714&r2=1325715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableImpl.java
Fri Apr 13 10:53:47 2012
@@ -30,7 +30,6 @@ import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.UnsupportedRepositoryOperationException;
 import javax.jcr.Value;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.nodetype.PropertyDefinition;
@@ -193,7 +192,7 @@ abstract class AuthorizableImpl implemen
     }
 
     @Override
-    public String getPath() throws UnsupportedRepositoryOperationException, RepositoryException
{
+    public String getPath() throws RepositoryException {
         return node.getPath();
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableNodeCreator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableNodeCreator.java?rev=1325715&r1=1325714&r2=1325715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableNodeCreator.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/AuthorizableNodeCreator.java
Fri Apr 13 10:53:47 2012
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.jcr.se
 
 import org.apache.jackrabbit.oak.jcr.NodeImpl;
 import org.apache.jackrabbit.oak.jcr.SessionContext;
+import org.apache.jackrabbit.oak.jcr.SessionImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -31,7 +32,7 @@ class AuthorizableNodeCreator {
      */
     private static final Logger log = LoggerFactory.getLogger(AuthorizableNodeCreator.class);
 
-    AuthorizableNodeCreator(SessionContext sessionContext) {
+    AuthorizableNodeCreator(SessionContext<SessionImpl> sessionContext) {
         // TODO
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/ImpersonationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/ImpersonationImpl.java?rev=1325715&r1=1325714&r2=1325715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/ImpersonationImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/ImpersonationImpl.java
Fri Apr 13 10:53:47 2012
@@ -50,7 +50,7 @@ public class ImpersonationImpl implement
 
     private final UserImpl user;
 
-    ImpersonationImpl(UserImpl user) throws RepositoryException {
+    ImpersonationImpl(UserImpl user) {
         this.user = user;
     }
 

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/PasswordUtility.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/PasswordUtility.java?rev=1325715&r1=1325714&r2=1325715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/PasswordUtility.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/PasswordUtility.java
Fri Apr 13 10:53:47 2012
@@ -37,9 +37,9 @@ public class PasswordUtility {
     public static final int DEFAULT_ITERATIONS = 10000;
 
     /**
-     * Avoid instanciation
+     * Avoid instantiation
      */
-    private PasswordUtility() {};
+    private PasswordUtility() {}
 
     public static boolean isSame(String passwordHash, String toTest) {
         // TODO

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerConfig.java?rev=1325715&r1=1325714&r2=1325715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerConfig.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerConfig.java
Fri Apr 13 10:53:47 2012
@@ -91,7 +91,7 @@ public class UserManagerConfig {
         } else {
             str = configProperty.getString();
         }
-        Class targetClass = (defaultValue == null) ? String.class : defaultValue.getClass();
+        Class<?> targetClass = (defaultValue == null) ? String.class : defaultValue.getClass();
         try {
             if (targetClass == String.class) {
                 value = (T) str;

Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java?rev=1325715&r1=1325714&r2=1325715&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/security/user/UserManagerImpl.java
Fri Apr 13 10:53:47 2012
@@ -18,7 +18,6 @@ package org.apache.jackrabbit.oak.jcr.se
 
 import org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal;
 import org.apache.jackrabbit.api.security.user.Authorizable;
-import org.apache.jackrabbit.api.security.user.AuthorizableExistsException;
 import org.apache.jackrabbit.api.security.user.Group;
 import org.apache.jackrabbit.api.security.user.Query;
 import org.apache.jackrabbit.api.security.user.User;
@@ -26,6 +25,7 @@ import org.apache.jackrabbit.api.securit
 import org.apache.jackrabbit.oak.api.Scalar;
 import org.apache.jackrabbit.oak.jcr.NodeImpl;
 import org.apache.jackrabbit.oak.jcr.SessionContext;
+import org.apache.jackrabbit.oak.jcr.SessionImpl;
 import org.apache.jackrabbit.oak.jcr.util.ValueConverter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -52,11 +52,11 @@ public class UserManagerImpl implements 
      */
     private static final Logger log = LoggerFactory.getLogger(UserManagerImpl.class);
 
-    private final SessionContext sessionContext;
+    private final SessionContext<SessionImpl> sessionContext;
     private final UserManagerConfig config;
     private final AuthorizableNodeCreator nodeCreator;
 
-    public UserManagerImpl(SessionContext sessionContext, UserManagerConfig config) {
+    public UserManagerImpl(SessionContext<SessionImpl> sessionContext, UserManagerConfig
config) {
         this.sessionContext = sessionContext;
         this.config = config;
         nodeCreator = new AuthorizableNodeCreator(sessionContext);
@@ -109,7 +109,7 @@ public class UserManagerImpl implements 
     }
 
     @Override
-    public Authorizable getAuthorizableByPath(String path) throws UnsupportedRepositoryOperationException,
RepositoryException {
+    public Authorizable getAuthorizableByPath(String path) throws RepositoryException {
         // TODO
         return null;
     }
@@ -133,7 +133,7 @@ public class UserManagerImpl implements 
     }
 
     @Override
-    public User createUser(final String userID, String password) throws AuthorizableExistsException,
RepositoryException {
+    public User createUser(final String userID, String password) throws RepositoryException
{
         Principal principal = new Principal() {
             @Override
             public String getName() {
@@ -144,10 +144,10 @@ public class UserManagerImpl implements 
     }
 
     @Override
-    public User createUser(String userID, String password, Principal principal, String intermediatePath)
throws AuthorizableExistsException, RepositoryException {
+    public User createUser(String userID, String password, Principal principal, String intermediatePath)
throws RepositoryException {
         checkValidID(userID);
 
-        NodeImpl userNode = (NodeImpl) nodeCreator.createUserNode(userID, intermediatePath);
+        NodeImpl userNode = nodeCreator.createUserNode(userID, intermediatePath);
         setPrincipal(userNode, principal);
         setPassword(userNode, password, true);
 
@@ -159,7 +159,7 @@ public class UserManagerImpl implements 
     }
 
     @Override
-    public Group createGroup(final String groupID) throws AuthorizableExistsException, RepositoryException
{
+    public Group createGroup(final String groupID) throws RepositoryException {
         Principal principal = new Principal() {
             @Override
             public String getName() {
@@ -170,21 +170,21 @@ public class UserManagerImpl implements 
     }
 
     @Override
-    public Group createGroup(Principal principal) throws AuthorizableExistsException, RepositoryException
{
+    public Group createGroup(Principal principal) throws RepositoryException {
         return createGroup(principal, null);
     }
 
     @Override
-    public Group createGroup(Principal principal, String intermediatePath) throws AuthorizableExistsException,
RepositoryException {
+    public Group createGroup(Principal principal, String intermediatePath) throws RepositoryException
{
         String groupID = buildGroupID(principal.getName());
         return createGroup(groupID, principal, intermediatePath);
     }
 
     @Override
-    public Group createGroup(String groupID, Principal principal, String intermediatePath)
throws AuthorizableExistsException, RepositoryException {
+    public Group createGroup(String groupID, Principal principal, String intermediatePath)
throws RepositoryException {
         checkValidID(groupID);
 
-        NodeImpl groupNode = (NodeImpl) nodeCreator.createGroupNode(groupID, intermediatePath);
+        NodeImpl groupNode = nodeCreator.createGroupNode(groupID, intermediatePath);
         setPrincipal(groupNode, principal);
 
         Group group = new GroupImpl(groupNode, this);
@@ -213,14 +213,14 @@ public class UserManagerImpl implements 
      * @see UserManager#autoSave(boolean)
      */
     @Override
-    public void autoSave(boolean enable) throws UnsupportedRepositoryOperationException,
RepositoryException {
+    public void autoSave(boolean enable) throws RepositoryException {
         throw new UnsupportedRepositoryOperationException("Session#save() is always required.");
     }
 
 
     //--------------------------------------------------------------------------
     /**
-     * Let the configured <code>AuthorizableAction</code>s perform additional
+     * Let the configured {@code AuthorizableAction}s perform additional
      * tasks associated with the creation of the new user before the
      * corresponding new node is persisted.
      *
@@ -233,7 +233,7 @@ public class UserManagerImpl implements 
     }
 
     /**
-     * Let the configured <code>AuthorizableAction</code>s perform additional
+     * Let the configured {@code AuthorizableAction}s perform additional
      * tasks associated with the creation of the new group before the
      * corresponding new node is persisted.
      *
@@ -245,7 +245,7 @@ public class UserManagerImpl implements 
     }
 
     /**
-     * Let the configured <code>AuthorizableAction</code>s perform any clean
+     * Let the configured {@code AuthorizableAction}s perform any clean
      * up tasks related to the authorizable removal (before the corresponding
      * node gets removed).
      *
@@ -257,7 +257,7 @@ public class UserManagerImpl implements 
     }
 
     /**
-     * Let the configured <code>AuthorizableAction</code>s perform additional
+     * Let the configured {@code AuthorizableAction}s perform additional
      * tasks associated with password changing of a given user before the
      * corresponding property is being changed.
      *
@@ -328,8 +328,8 @@ public class UserManagerImpl implements 
     void setInternalProperty(NodeImpl userNode, String name, String[] values, int type) throws
RepositoryException {
         // TODO: check again if this really makes a transient modification with marking the
property modified/new
         List<Scalar> scalarList = new ArrayList<Scalar>(values.length);
-        for (int i = 0; i < values.length; i++) {
-            scalarList.add(ValueConverter.toScalar(values[i], PropertyType.STRING));
+        for (String value : values) {
+            scalarList.add(ValueConverter.toScalar(value, PropertyType.STRING));
         }
         userNode.getEditor().setProperty(name, scalarList);
     }



Mime
View raw message