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:49:04 UTC
[sling-org-apache-sling-jcr-jackrabbit-usermanager] 10/24:
SLING-2072 Add support for disabling users
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.usermanager-2.2.0
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-usermanager.git
commit 58d6a66d8292146320230849d56c464484667878
Author: Eric Norman <en...@apache.org>
AuthorDate: Fri May 6 03:17:47 2011 +0000
SLING-2072 Add support for disabling users
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-usermanager@1100034 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 2 +-
.../impl/AuthorizablePrivilegesInfoImpl.java | 9 --------
.../usermanager/impl/post/UpdateUserServlet.java | 24 +++++++++++++++++-----
3 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/pom.xml b/pom.xml
index cea2e17..9f832c6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -95,7 +95,7 @@
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-api</artifactId>
- <version>2.0.0</version>
+ <version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
diff --git a/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/AuthorizablePrivilegesInfoImpl.java b/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/AuthorizablePrivilegesInfoImpl.java
index f3fc51a..48dfa38 100644
--- a/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/AuthorizablePrivilegesInfoImpl.java
+++ b/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/AuthorizablePrivilegesInfoImpl.java
@@ -243,15 +243,6 @@ public class AuthorizablePrivilegesInfoImpl implements AuthorizablePrivilegesInf
return true;
}
}
-
- //check if the user is a member of the 'User administrator' group
- Authorizable userAdmin = userManager.getAuthorizable(this.userAdminGroupName);
- if (userAdmin instanceof Group) {
- boolean isMember = ((Group)userAdmin).isMember(currentUser);
- if (isMember) {
- return true;
- }
- }
}
} catch (RepositoryException e) {
log.warn("Failed to determine if {} can remove authorizable {}", jcrSession.getUserID(), groupId);
diff --git a/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/UpdateUserServlet.java b/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/UpdateUserServlet.java
index cf908a3..31210b5 100644
--- a/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/UpdateUserServlet.java
+++ b/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/UpdateUserServlet.java
@@ -22,14 +22,14 @@ import java.util.Map;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
-import org.apache.jackrabbit.api.security.user.Authorizable;
+import org.apache.jackrabbit.api.security.user.User;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceNotFoundException;
import org.apache.sling.api.servlets.HtmlResponse;
-import org.apache.sling.servlets.post.impl.helper.RequestProperty;
import org.apache.sling.jackrabbit.usermanager.impl.resource.AuthorizableResourceProvider;
import org.apache.sling.servlets.post.Modification;
+import org.apache.sling.servlets.post.impl.helper.RequestProperty;
/**
* <p>
@@ -91,10 +91,10 @@ public class UpdateUserServlet extends AbstractUserPostServlet {
protected void handleOperation(SlingHttpServletRequest request,
HtmlResponse htmlResponse, List<Modification> changes)
throws RepositoryException {
- Authorizable authorizable = null;
+ User authorizable = null;
Resource resource = request.getResource();
if (resource != null) {
- authorizable = resource.adaptTo(Authorizable.class);
+ authorizable = resource.adaptTo(User.class);
}
// check that the group was located.
@@ -119,7 +119,21 @@ public class UpdateUserServlet extends AbstractUserPostServlet {
// write content from form
writeContent(session, authorizable, reqProperties, changes);
-
+
+ //SLING-2072 set the user as enabled or disabled if the request
+ // has supplied the relev
+ String disabledParam = request.getParameter(":disabled");
+ if ("true".equalsIgnoreCase(disabledParam)) {
+ //set the user as disabled
+ String disabledReason = request.getParameter(":disabledReason");
+ if (disabledReason == null) {
+ disabledReason = "";
+ }
+ authorizable.disable(disabledReason);
+ } else if ("false".equalsIgnoreCase(disabledParam)) {
+ //re-enable a disabled user
+ authorizable.disable(null);
+ }
} catch (RepositoryException re) {
throw new RepositoryException("Failed to update user.", re);
}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.