You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:48:12 UTC

[sling-org-apache-sling-jcr-jackrabbit-accessmanager] 08/24: Removed the 'authorizable' related privilege helpers since they don't work after the upgrade to JR2. To check the authorizable privileges use the 'AuthorizablePrivilegesInfo' service from the jackrabbit.usermanager bundle.

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.accessmanager-2.1.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-accessmanager.git

commit d59aaea2f3a429c7f328da40e0987ace2eae2d5a
Author: Eric Norman <en...@apache.org>
AuthorDate: Fri Mar 19 19:34:24 2010 +0000

    Removed the 'authorizable' related privilege helpers since they don't work after the upgrade to JR2.  To check the authorizable privileges use the 'AuthorizablePrivilegesInfo' service from the jackrabbit.usermanager bundle.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-accessmanager@925395 13f79535-47bb-0310-9956-ffa450edef68
---
 .../jackrabbit/accessmanager/PrivilegesInfo.java   | 60 ----------------------
 1 file changed, 60 deletions(-)

diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
index a895130..171c81e 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/accessmanager/PrivilegesInfo.java
@@ -16,8 +16,6 @@
  */
 package org.apache.sling.jcr.jackrabbit.accessmanager;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.security.Principal;
 import java.util.Arrays;
 import java.util.HashSet;
@@ -37,7 +35,6 @@ import javax.jcr.security.AccessControlManager;
 import javax.jcr.security.AccessControlPolicy;
 import javax.jcr.security.Privilege;
 
-import org.apache.jackrabbit.api.security.principal.PrincipalManager;
 import org.apache.sling.jcr.base.util.AccessControlUtil;
 
 /**
@@ -564,61 +561,4 @@ public class PrivilegesInfo {
 		}
 	}
 
-
-	/**
-	 * Checks whether the current user has been granted privileges
-	 * to update the properties of the specified principal.
-	 *  
-	 * @param session the JCR session for the current user
-	 * @param principalID the id of the principal to check
-	 * @return true if the current user has the privileges, false otherwise
-	 */
-	public boolean canUpdateAuthorizable(Session session, String principalID) {
-		try {
-			PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
-			Principal principal = principalManager.getPrincipal(principalID);
-			if (principal == null) {
-				return false;
-			}
-
-			String path = getAuthorizableItemPath(principal);
-			return canModifyProperties(session, path);
-		} catch (Exception e) {
-			//just eat it.
-			return false;
-		}
-	}
-	private String getAuthorizableItemPath(Principal principal)
-			throws NoSuchMethodException, IllegalAccessException,
-			InvocationTargetException {
-		//should check if principal implements ItemBasedPrincipal, but it is not visible here so use reflection instead
-		Method method = principal.getClass().getMethod("getPath");
-		String path = (String)method.invoke(principal);
-		return path;
-	}
-	
-	/**
-	 * Checks whether the current user has been granted privileges
-	 * to delete the specified principal.
-	 *  
-	 * @param session the JCR session for the current user
-	 * @param principalID the id of the principal to check
-	 * @return true if the current user has the privileges, false otherwise
-	 */
-	public boolean canDeleteAuthorizable(Session session, String principalID) {
-		try {
-			PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
-			Principal principal = principalManager.getPrincipal(principalID);
-			if (principal == null) {
-				return false;
-			}
-			
-			//should check if principal implements ItemBasedPrincipal, but it is not visible here so use reflection instead
-			String path = getAuthorizableItemPath(principal);
-			return canDelete(session, path);
-		} catch (Exception e) {
-			//just eat it.
-			return false;
-		}
-	}
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.