You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2011/11/10 22:21:45 UTC
svn commit: r1200559 [1/2] - in
/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager:
./ impl/ impl/post/
Author: justin
Date: Thu Nov 10 21:21:44 2011
New Revision: 1200559
URL: http://svn.apache.org/viewvc?rev=1200559&view=rev
Log:
tabs -> spaces
Modified:
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/AuthorizablePrivilegesInfo.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/ChangeUserPassword.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/CreateGroup.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/CreateUser.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteAuthorizables.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteGroup.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteUser.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/UpdateGroup.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/UpdateUser.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/AuthorizablePrivilegesInfoImpl.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractAuthorizablePostServlet.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractGroupPostServlet.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractPostServlet.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateGroupServlet.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/DeleteAuthorizableServlet.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/UpdateGroupServlet.java
sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/UpdateUserServlet.java
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/AuthorizablePrivilegesInfo.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/AuthorizablePrivilegesInfo.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/AuthorizablePrivilegesInfo.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/AuthorizablePrivilegesInfo.java Thu Nov 10 21:21:44 2011
@@ -20,55 +20,55 @@ import javax.jcr.Session;
public interface AuthorizablePrivilegesInfo {
- /**
- * Checks whether the current user has been granted privileges
- * to add a new user.
- *
- * @param jcrSession the JCR session of the current user
- * @return true if the current user has the privileges, false otherwise
- */
- boolean canAddUser(Session jcrSession);
+ /**
+ * Checks whether the current user has been granted privileges
+ * to add a new user.
+ *
+ * @param jcrSession the JCR session of the current user
+ * @return true if the current user has the privileges, false otherwise
+ */
+ boolean canAddUser(Session jcrSession);
- /**
- * Checks whether the current user has been granted privileges
- * to add a new group.
- *
- * @param jcrSession the JCR session of the current user
- * @return true if the current user has the privileges, false otherwise
- */
- boolean canAddGroup(Session jcrSession);
-
- /**
- * Checks whether the current user has been granted privileges
- * to update the properties of the specified user or group.
- *
- * @param jcrSession the JCR session of the current user
- * @param principalId the user or group id to check
- * @return true if the current user has the privileges, false otherwise
- */
- boolean canUpdateProperties(Session jcrSession,
- String principalId);
+ /**
+ * Checks whether the current user has been granted privileges
+ * to add a new group.
+ *
+ * @param jcrSession the JCR session of the current user
+ * @return true if the current user has the privileges, false otherwise
+ */
+ boolean canAddGroup(Session jcrSession);
+
+ /**
+ * Checks whether the current user has been granted privileges
+ * to update the properties of the specified user or group.
+ *
+ * @param jcrSession the JCR session of the current user
+ * @param principalId the user or group id to check
+ * @return true if the current user has the privileges, false otherwise
+ */
+ boolean canUpdateProperties(Session jcrSession,
+ String principalId);
- /**
- * Checks whether the current user has been granted privileges
- * to remove the specified user or group.
- *
- * @param jcrSession the JCR session of the current user
- * @param principalId the user or group id to check
- * @return true if the current user has the privileges, false otherwise
- */
- boolean canRemove(Session jcrSession,
- String principalId);
-
- /**
- * Checks whether the current user has been granted privileges
- * to update the membership of the specified group.
- *
- * @param jcrSession the JCR session of the current user
- * @param groupId the group id to check
- * @return true if the current user has the privileges, false otherwise
- */
- boolean canUpdateGroupMembers(Session jcrSession,
- String groupId);
+ /**
+ * Checks whether the current user has been granted privileges
+ * to remove the specified user or group.
+ *
+ * @param jcrSession the JCR session of the current user
+ * @param principalId the user or group id to check
+ * @return true if the current user has the privileges, false otherwise
+ */
+ boolean canRemove(Session jcrSession,
+ String principalId);
+
+ /**
+ * Checks whether the current user has been granted privileges
+ * to update the membership of the specified group.
+ *
+ * @param jcrSession the JCR session of the current user
+ * @param groupId the group id to check
+ * @return true if the current user has the privileges, false otherwise
+ */
+ boolean canUpdateGroupMembers(Session jcrSession,
+ String groupId);
}
\ No newline at end of file
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/ChangeUserPassword.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/ChangeUserPassword.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/ChangeUserPassword.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/ChangeUserPassword.java Thu Nov 10 21:21:44 2011
@@ -35,24 +35,24 @@ import org.apache.sling.servlets.post.Mo
*/
public interface ChangeUserPassword {
- /**
- * Update the password of a user in the repository
- *
- * @param jcrSession the JCR session of the user updating the user
- * @param name The name of the user to update (required)
- * @param oldPassword The current password of the user (required for non-admin users)
- * @param newPassword The password value to apply (required)
- * @param newPasswordConfirm The password value to apply again (required)
+ /**
+ * Update the password of a user in the repository
+ *
+ * @param jcrSession the JCR session of the user updating the user
+ * @param name The name of the user to update (required)
+ * @param oldPassword The current password of the user (required for non-admin users)
+ * @param newPassword The password value to apply (required)
+ * @param newPasswordConfirm The password value to apply again (required)
* @param changes The list of changes for this operation (optional)
- * @return the user whose password was changed
- * @throws RepositoryException
- */
- public User changePassword(Session jcrSession,
- String name,
- String oldPassword,
- String newPassword,
- String newPasswordConfirm,
- List<Modification> changes
- ) throws RepositoryException;
-
+ * @return the user whose password was changed
+ * @throws RepositoryException
+ */
+ public User changePassword(Session jcrSession,
+ String name,
+ String oldPassword,
+ String newPassword,
+ String newPasswordConfirm,
+ List<Modification> changes
+ ) throws RepositoryException;
+
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/CreateGroup.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/CreateGroup.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/CreateGroup.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/CreateGroup.java Thu Nov 10 21:21:44 2011
@@ -36,20 +36,20 @@ import org.apache.sling.servlets.post.Mo
*/
public interface CreateGroup {
- /**
- * Create a new group for the repository
- *
- * @param jcrSession the JCR session of the user creating the group
- * @param name The name of the new group (required)
- * @param properties Extra properties to update on the group. The entry values should be either a String or String[] (optional)
+ /**
+ * Create a new group for the repository
+ *
+ * @param jcrSession the JCR session of the user creating the group
+ * @param name The name of the new group (required)
+ * @param properties Extra properties to update on the group. The entry values should be either a String or String[] (optional)
* @param changes The list of changes for this operation (optional)
* @return the group that was created
- * @throws RepositoryException
- */
- public Group createGroup(Session jcrSession,
- String name,
- Map<String, ?> properties,
- List<Modification> changes
- ) throws RepositoryException;
-
+ * @throws RepositoryException
+ */
+ public Group createGroup(Session jcrSession,
+ String name,
+ Map<String, ?> properties,
+ List<Modification> changes
+ ) throws RepositoryException;
+
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/CreateUser.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/CreateUser.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/CreateUser.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/CreateUser.java Thu Nov 10 21:21:44 2011
@@ -36,24 +36,24 @@ import org.apache.sling.servlets.post.Mo
*/
public interface CreateUser {
- /**
- * Create a new user for the repository
- *
- * @param jcrSession the JCR session of the user creating the user
- * @param name The name of the new user (required)
- * @param password The password of the new user (required)
- * @param password The password of the new user again (required)
- * @param properties Extra properties to update on the user. The entry values should be either a String or String[] (optional)
+ /**
+ * Create a new user for the repository
+ *
+ * @param jcrSession the JCR session of the user creating the user
+ * @param name The name of the new user (required)
+ * @param password The password of the new user (required)
+ * @param password The password of the new user again (required)
+ * @param properties Extra properties to update on the user. The entry values should be either a String or String[] (optional)
* @param changes The list of changes for this operation (optional)
- * @return the user that was created
- * @throws RepositoryException
- */
- public User createUser(Session jcrSession,
- String name,
- String password,
- String passwordConfirm,
- Map<String, ?> properties,
- List<Modification> changes
- ) throws RepositoryException;
-
+ * @return the user that was created
+ * @throws RepositoryException
+ */
+ public User createUser(Session jcrSession,
+ String name,
+ String password,
+ String passwordConfirm,
+ Map<String, ?> properties,
+ List<Modification> changes
+ ) throws RepositoryException;
+
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteAuthorizables.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteAuthorizables.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteAuthorizables.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteAuthorizables.java Thu Nov 10 21:21:44 2011
@@ -35,19 +35,19 @@ import org.apache.sling.servlets.post.Mo
*/
public interface DeleteAuthorizables {
- /**
- * Deletes one or more users or groups from the repository
- *
- * @param jcrSession the JCR session of the user creating the user
- * @param baseResource the base resource to calculate the relative paths from (required)
- * @param paths An array of relative resource paths to Authorizables to be deleted (required)
+ /**
+ * Deletes one or more users or groups from the repository
+ *
+ * @param jcrSession the JCR session of the user creating the user
+ * @param baseResource the base resource to calculate the relative paths from (required)
+ * @param paths An array of relative resource paths to Authorizables to be deleted (required)
* @param changes The list of changes for this operation (optional)
- * @throws RepositoryException
- */
- public void deleteAuthorizables(Session jcrSession,
- Resource baseResource,
- String [] paths,
- List<Modification> changes
- ) throws RepositoryException;
-
+ * @throws RepositoryException
+ */
+ public void deleteAuthorizables(Session jcrSession,
+ Resource baseResource,
+ String [] paths,
+ List<Modification> changes
+ ) throws RepositoryException;
+
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteGroup.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteGroup.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteGroup.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteGroup.java Thu Nov 10 21:21:44 2011
@@ -34,17 +34,17 @@ import org.apache.sling.servlets.post.Mo
*/
public interface DeleteGroup {
- /**
- * Deletes a group from the repository
- *
- * @param jcrSession the JCR session of the user creating the user
- * @param name The name of the group to delete (required)
+ /**
+ * Deletes a group from the repository
+ *
+ * @param jcrSession the JCR session of the user creating the user
+ * @param name The name of the group to delete (required)
* @param changes The list of changes for this operation (optional)
- * @throws RepositoryException
- */
- public void deleteGroup(Session jcrSession,
- String name,
- List<Modification> changes
- ) throws RepositoryException;
-
+ * @throws RepositoryException
+ */
+ public void deleteGroup(Session jcrSession,
+ String name,
+ List<Modification> changes
+ ) throws RepositoryException;
+
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteUser.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteUser.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteUser.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/DeleteUser.java Thu Nov 10 21:21:44 2011
@@ -34,17 +34,17 @@ import org.apache.sling.servlets.post.Mo
*/
public interface DeleteUser {
- /**
- * Deletes a user from the repository
- *
- * @param jcrSession the JCR session of the user creating the user
- * @param name The name of the user to delete (required)
+ /**
+ * Deletes a user from the repository
+ *
+ * @param jcrSession the JCR session of the user creating the user
+ * @param name The name of the user to delete (required)
* @param changes The list of changes for this operation (optional)
- * @throws RepositoryException
- */
- public void deleteUser(Session jcrSession,
- String name,
- List<Modification> changes
- ) throws RepositoryException;
-
+ * @throws RepositoryException
+ */
+ public void deleteUser(Session jcrSession,
+ String name,
+ List<Modification> changes
+ ) throws RepositoryException;
+
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/UpdateGroup.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/UpdateGroup.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/UpdateGroup.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/UpdateGroup.java Thu Nov 10 21:21:44 2011
@@ -36,20 +36,20 @@ import org.apache.sling.servlets.post.Mo
*/
public interface UpdateGroup {
- /**
- * Update a group in the repository
- *
- * @param jcrSession the JCR session of the user creating the group
- * @param name The name of the group to update (required)
- * @param properties Extra properties to update on the group. The entry values should be either a String or String[] (optional)
+ /**
+ * Update a group in the repository
+ *
+ * @param jcrSession the JCR session of the user creating the group
+ * @param name The name of the group to update (required)
+ * @param properties Extra properties to update on the group. The entry values should be either a String or String[] (optional)
* @param changes The list of changes for this operation (optional)
- * @return the group that was updated or null if not found
- * @throws RepositoryException
- */
- public Group updateGroup(Session jcrSession,
- String name,
- Map<String, ?> properties,
- List<Modification> changes
- ) throws RepositoryException;
-
+ * @return the group that was updated or null if not found
+ * @throws RepositoryException
+ */
+ public Group updateGroup(Session jcrSession,
+ String name,
+ Map<String, ?> properties,
+ List<Modification> changes
+ ) throws RepositoryException;
+
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/UpdateUser.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/UpdateUser.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/UpdateUser.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/UpdateUser.java Thu Nov 10 21:21:44 2011
@@ -36,20 +36,20 @@ import org.apache.sling.servlets.post.Mo
*/
public interface UpdateUser {
- /**
- * Update a user in the repository
- *
- * @param jcrSession the JCR session of the user updating the user
- * @param name The name of the user to update (required)
- * @param properties Extra properties to update on the user. The entry values should be either a String or String[] (optional)
+ /**
+ * Update a user in the repository
+ *
+ * @param jcrSession the JCR session of the user updating the user
+ * @param name The name of the user to update (required)
+ * @param properties Extra properties to update on the user. The entry values should be either a String or String[] (optional)
* @param changes The list of changes for this operation (optional)
* @return the user that was updated or null if not found
- * @throws RepositoryException
- */
- public User updateUser(Session jcrSession,
- String name,
- Map<String, ?> properties,
- List<Modification> changes
- ) throws RepositoryException;
-
+ * @throws RepositoryException
+ */
+ public User updateUser(Session jcrSession,
+ String name,
+ Map<String, ?> properties,
+ List<Modification> changes
+ ) throws RepositoryException;
+
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/AuthorizablePrivilegesInfoImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/AuthorizablePrivilegesInfoImpl.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/AuthorizablePrivilegesInfoImpl.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/AuthorizablePrivilegesInfoImpl.java Thu Nov 10 21:21:44 2011
@@ -106,207 +106,207 @@ public class AuthorizablePrivilegesInfoI
private String groupAdminGroupName = DEFAULT_GROUP_ADMIN_GROUP_NAME;
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo#canAddGroup(javax.jcr.Session)
- */
- public boolean canAddGroup(Session jcrSession) {
- try {
- UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
- Authorizable currentUser = userManager.getAuthorizable(jcrSession.getUserID());
-
- if (currentUser != null) {
- if (((User)currentUser).isAdmin()) {
- return true; //admin user has full control
- }
-
- //check if the user is a member of the 'Group administrator' group
- Authorizable groupAdmin = userManager.getAuthorizable(this.groupAdminGroupName);
- if (groupAdmin instanceof Group) {
- boolean isMember = ((Group)groupAdmin).isMember(currentUser);
- if (isMember) {
- return true;
- }
- }
- }
- } catch (RepositoryException e) {
- log.warn("Failed to determine if {} can add a new group", jcrSession.getUserID());
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo#canAddUser(javax.jcr.Session)
- */
- public boolean canAddUser(Session jcrSession) {
- try {
- //if self-registration is enabled, then anyone can create a user
- if (componentContext != null) {
- String filter = "(&(sling.servlet.resourceTypes=sling/users)(|(sling.servlet.methods=POST)(sling.servlet.selectors=create)))";
- BundleContext bundleContext = componentContext.getBundleContext();
- ServiceReference[] serviceReferences = bundleContext.getServiceReferences(Servlet.class.getName(), filter);
- if (serviceReferences != null) {
- String propName = "self.registration.enabled";
- for (ServiceReference serviceReference : serviceReferences) {
- Object propValue = serviceReference.getProperty(propName);
- if (propValue != null) {
- boolean selfRegEnabled = Boolean.TRUE.equals(propValue);
- if (selfRegEnabled) {
- return true;
- }
- break;
- }
- }
- }
- }
-
- UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
- Authorizable currentUser = userManager.getAuthorizable(jcrSession.getUserID());
- if (currentUser != null) {
- if (((User)currentUser).isAdmin()) {
- return true; //admin user has full control
- }
-
- //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 add a new user", jcrSession.getUserID());
- } catch (InvalidSyntaxException e) {
- log.warn("Failed to determine if {} can add a new user", jcrSession.getUserID());
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo#canRemove(javax.jcr.Session, java.lang.String)
- */
- public boolean canRemove(Session jcrSession, String principalId) {
- try {
- UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
- Authorizable currentUser = userManager.getAuthorizable(jcrSession.getUserID());
-
- if (((User)currentUser).isAdmin()) {
- return true; //admin user has full control
- }
-
- Authorizable authorizable = userManager.getAuthorizable(principalId);
- if (authorizable instanceof User) {
- //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;
- }
- }
- } else if (authorizable instanceof Group) {
- //check if the user is a member of the 'Group administrator' group
- Authorizable groupAdmin = userManager.getAuthorizable(this.groupAdminGroupName);
- if (groupAdmin instanceof Group) {
- boolean isMember = ((Group)groupAdmin).isMember(currentUser);
- if (isMember) {
- return true;
- }
- }
- }
- } catch (RepositoryException e) {
- log.warn("Failed to determine if {} can remove authorizable {}", jcrSession.getUserID(), principalId);
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo#canUpdateGroupMembers(javax.jcr.Session, java.lang.String)
- */
- public boolean canUpdateGroupMembers(Session jcrSession, String groupId) {
- try {
- UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
- Authorizable currentUser = userManager.getAuthorizable(jcrSession.getUserID());
-
- if (((User)currentUser).isAdmin()) {
- return true; //admin user has full control
- }
-
- Authorizable authorizable = userManager.getAuthorizable(groupId);
- if (authorizable instanceof Group) {
- //check if the user is a member of the 'Group administrator' group
- Authorizable groupAdmin = userManager.getAuthorizable(this.groupAdminGroupName);
- if (groupAdmin instanceof Group) {
- boolean isMember = ((Group)groupAdmin).isMember(currentUser);
- if (isMember) {
- 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);
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo#canUpdateProperties(javax.jcr.Session, java.lang.String)
- */
- public boolean canUpdateProperties(Session jcrSession, String principalId) {
- try {
- if (jcrSession.getUserID().equals(principalId)) {
- //user is allowed to update it's own properties
- return true;
- }
-
- UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
- Authorizable currentUser = userManager.getAuthorizable(jcrSession.getUserID());
-
- if (((User)currentUser).isAdmin()) {
- return true; //admin user has full control
- }
-
- Authorizable authorizable = userManager.getAuthorizable(principalId);
- if (authorizable instanceof User) {
- //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;
- }
- }
- } else if (authorizable instanceof Group) {
- //check if the user is a member of the 'Group administrator' group
- Authorizable groupAdmin = userManager.getAuthorizable(this.groupAdminGroupName);
- if (groupAdmin instanceof Group) {
- boolean isMember = ((Group)groupAdmin).isMember(currentUser);
- if (isMember) {
- return true;
- }
- }
- }
- } catch (RepositoryException e) {
- log.warn("Failed to determine if {} can remove authorizable {}", jcrSession.getUserID(), principalId);
- }
- return false;
- }
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo#canAddGroup(javax.jcr.Session)
+ */
+ public boolean canAddGroup(Session jcrSession) {
+ try {
+ UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
+ Authorizable currentUser = userManager.getAuthorizable(jcrSession.getUserID());
+
+ if (currentUser != null) {
+ if (((User)currentUser).isAdmin()) {
+ return true; //admin user has full control
+ }
+
+ //check if the user is a member of the 'Group administrator' group
+ Authorizable groupAdmin = userManager.getAuthorizable(this.groupAdminGroupName);
+ if (groupAdmin instanceof Group) {
+ boolean isMember = ((Group)groupAdmin).isMember(currentUser);
+ if (isMember) {
+ return true;
+ }
+ }
+ }
+ } catch (RepositoryException e) {
+ log.warn("Failed to determine if {} can add a new group", jcrSession.getUserID());
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo#canAddUser(javax.jcr.Session)
+ */
+ public boolean canAddUser(Session jcrSession) {
+ try {
+ //if self-registration is enabled, then anyone can create a user
+ if (componentContext != null) {
+ String filter = "(&(sling.servlet.resourceTypes=sling/users)(|(sling.servlet.methods=POST)(sling.servlet.selectors=create)))";
+ BundleContext bundleContext = componentContext.getBundleContext();
+ ServiceReference[] serviceReferences = bundleContext.getServiceReferences(Servlet.class.getName(), filter);
+ if (serviceReferences != null) {
+ String propName = "self.registration.enabled";
+ for (ServiceReference serviceReference : serviceReferences) {
+ Object propValue = serviceReference.getProperty(propName);
+ if (propValue != null) {
+ boolean selfRegEnabled = Boolean.TRUE.equals(propValue);
+ if (selfRegEnabled) {
+ return true;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
+ Authorizable currentUser = userManager.getAuthorizable(jcrSession.getUserID());
+ if (currentUser != null) {
+ if (((User)currentUser).isAdmin()) {
+ return true; //admin user has full control
+ }
+
+ //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 add a new user", jcrSession.getUserID());
+ } catch (InvalidSyntaxException e) {
+ log.warn("Failed to determine if {} can add a new user", jcrSession.getUserID());
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo#canRemove(javax.jcr.Session, java.lang.String)
+ */
+ public boolean canRemove(Session jcrSession, String principalId) {
+ try {
+ UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
+ Authorizable currentUser = userManager.getAuthorizable(jcrSession.getUserID());
+
+ if (((User)currentUser).isAdmin()) {
+ return true; //admin user has full control
+ }
+
+ Authorizable authorizable = userManager.getAuthorizable(principalId);
+ if (authorizable instanceof User) {
+ //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;
+ }
+ }
+ } else if (authorizable instanceof Group) {
+ //check if the user is a member of the 'Group administrator' group
+ Authorizable groupAdmin = userManager.getAuthorizable(this.groupAdminGroupName);
+ if (groupAdmin instanceof Group) {
+ boolean isMember = ((Group)groupAdmin).isMember(currentUser);
+ if (isMember) {
+ return true;
+ }
+ }
+ }
+ } catch (RepositoryException e) {
+ log.warn("Failed to determine if {} can remove authorizable {}", jcrSession.getUserID(), principalId);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo#canUpdateGroupMembers(javax.jcr.Session, java.lang.String)
+ */
+ public boolean canUpdateGroupMembers(Session jcrSession, String groupId) {
+ try {
+ UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
+ Authorizable currentUser = userManager.getAuthorizable(jcrSession.getUserID());
+
+ if (((User)currentUser).isAdmin()) {
+ return true; //admin user has full control
+ }
+
+ Authorizable authorizable = userManager.getAuthorizable(groupId);
+ if (authorizable instanceof Group) {
+ //check if the user is a member of the 'Group administrator' group
+ Authorizable groupAdmin = userManager.getAuthorizable(this.groupAdminGroupName);
+ if (groupAdmin instanceof Group) {
+ boolean isMember = ((Group)groupAdmin).isMember(currentUser);
+ if (isMember) {
+ 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);
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo#canUpdateProperties(javax.jcr.Session, java.lang.String)
+ */
+ public boolean canUpdateProperties(Session jcrSession, String principalId) {
+ try {
+ if (jcrSession.getUserID().equals(principalId)) {
+ //user is allowed to update it's own properties
+ return true;
+ }
+
+ UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
+ Authorizable currentUser = userManager.getAuthorizable(jcrSession.getUserID());
+
+ if (((User)currentUser).isAdmin()) {
+ return true; //admin user has full control
+ }
+
+ Authorizable authorizable = userManager.getAuthorizable(principalId);
+ if (authorizable instanceof User) {
+ //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;
+ }
+ }
+ } else if (authorizable instanceof Group) {
+ //check if the user is a member of the 'Group administrator' group
+ Authorizable groupAdmin = userManager.getAuthorizable(this.groupAdminGroupName);
+ if (groupAdmin instanceof Group) {
+ boolean isMember = ((Group)groupAdmin).isMember(currentUser);
+ if (isMember) {
+ return true;
+ }
+ }
+ }
+ } catch (RepositoryException e) {
+ log.warn("Failed to determine if {} can remove authorizable {}", jcrSession.getUserID(), principalId);
+ }
+ return false;
+ }
- // ---------- SCR Integration ----------------------------------------------
+ // ---------- SCR Integration ----------------------------------------------
- //keep track of the bundle context
- private ComponentContext componentContext;
+ //keep track of the bundle context
+ private ComponentContext componentContext;
/**
* Called by SCR to activate the component.
@@ -320,21 +320,21 @@ public class AuthorizablePrivilegesInfoI
throws InvalidKeyException, NoSuchAlgorithmException,
IllegalStateException, UnsupportedEncodingException {
- this.componentContext = componentContext;
-
+ this.componentContext = componentContext;
+
Dictionary<?, ?> properties = componentContext.getProperties();
this.userAdminGroupName = OsgiUtil.toString(properties.get(PAR_USER_ADMIN_GROUP_NAME),
- DEFAULT_USER_ADMIN_GROUP_NAME);
+ DEFAULT_USER_ADMIN_GROUP_NAME);
log.info("User Admin Group Name {}", this.userAdminGroupName);
this.groupAdminGroupName = OsgiUtil.toString(properties.get(PAR_GROUP_ADMIN_GROUP_NAME),
- DEFAULT_GROUP_ADMIN_GROUP_NAME);
+ DEFAULT_GROUP_ADMIN_GROUP_NAME);
log.info("Group Admin Group Name {}", this.groupAdminGroupName);
}
protected void deactivate(ComponentContext componentContext) {
- this.userAdminGroupName = DEFAULT_USER_ADMIN_GROUP_NAME;
- this.groupAdminGroupName = DEFAULT_GROUP_ADMIN_GROUP_NAME;
+ this.userAdminGroupName = DEFAULT_USER_ADMIN_GROUP_NAME;
+ this.groupAdminGroupName = DEFAULT_GROUP_ADMIN_GROUP_NAME;
}
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractAuthorizablePostServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractAuthorizablePostServlet.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractAuthorizablePostServlet.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractAuthorizablePostServlet.java Thu Nov 10 21:21:44 2011
@@ -138,7 +138,7 @@ public abstract class AbstractAuthorizab
String typeHintValue = convertToString(e.getValue());
if (typeHintValue != null) {
- prop.setTypeHintValue(typeHintValue);
+ prop.setTypeHintValue(typeHintValue);
}
continue;
@@ -508,186 +508,186 @@ public abstract class AbstractAuthorizab
}
- protected String convertToString(Object obj) {
- if (obj == null) {
- return null;
- }
-
- if (obj instanceof String) {
- return (String)obj;
- } else if (obj instanceof String[]) {
- String [] values = (String[])obj;
- if (values.length > 0) {
- return values[0];
- }
- return null;
- } else if (obj instanceof RequestParameter) {
- ((RequestParameter)obj).getString();
- } else if (obj instanceof RequestParameter[]) {
- RequestParameter[] values = (RequestParameter[])obj;
- if (values.length > 0) {
- return values[0].getString();
- }
- return null;
- }
- return null;
- }
+ protected String convertToString(Object obj) {
+ if (obj == null) {
+ return null;
+ }
+
+ if (obj instanceof String) {
+ return (String)obj;
+ } else if (obj instanceof String[]) {
+ String [] values = (String[])obj;
+ if (values.length > 0) {
+ return values[0];
+ }
+ return null;
+ } else if (obj instanceof RequestParameter) {
+ ((RequestParameter)obj).getString();
+ } else if (obj instanceof RequestParameter[]) {
+ RequestParameter[] values = (RequestParameter[])obj;
+ if (values.length > 0) {
+ return values[0].getString();
+ }
+ return null;
+ }
+ return null;
+ }
+
+ protected String[] convertToStringArray(Object obj) {
+ if (obj == null) {
+ return null;
+ }
+
+ if (obj instanceof String) {
+ return new String[] {(String)obj};
+ } else if (obj instanceof String[]) {
+ return (String[])obj;
+ } else if (obj instanceof RequestParameter) {
+ return new String[] {((RequestParameter)obj).getString()};
+ } else if (obj instanceof RequestParameter[]) {
+ RequestParameter[] values = (RequestParameter[])obj;
+ String [] strValues = new String[values.length];
+ for (int i=0; i < values.length; i++) {
+ strValues[i] = values[i].getString();
+ }
+ return strValues;
+ }
+ return null;
+ }
+
+ protected RequestParameter[] convertToRequestParameterArray(Object obj) {
+ if (obj == null) {
+ return null;
+ }
+
+ if (obj instanceof String) {
+ return new RequestParameter[] {
+ new RequestParameterImpl((String)obj, null)
+ };
+ } else if (obj instanceof String[]) {
+ String [] strValues = (String[])obj;
+ RequestParameter [] values = new RequestParameter[strValues.length];
+ for (int i=0; i < strValues.length; i++) {
+ values[i] = new RequestParameterImpl(strValues[i], null);
+ }
+ return values;
+ } else if (obj instanceof RequestParameter) {
+ return new RequestParameter[] {(RequestParameter)obj};
+ } else if (obj instanceof RequestParameter[]) {
+ return (RequestParameter[])obj;
+ }
+ return null;
+ }
- protected String[] convertToStringArray(Object obj) {
- if (obj == null) {
- return null;
- }
-
- if (obj instanceof String) {
- return new String[] {(String)obj};
- } else if (obj instanceof String[]) {
- return (String[])obj;
- } else if (obj instanceof RequestParameter) {
- return new String[] {((RequestParameter)obj).getString()};
- } else if (obj instanceof RequestParameter[]) {
- RequestParameter[] values = (RequestParameter[])obj;
- String [] strValues = new String[values.length];
- for (int i=0; i < values.length; i++) {
- strValues[i] = values[i].getString();
- }
- return strValues;
- }
- return null;
- }
-
- protected RequestParameter[] convertToRequestParameterArray(Object obj) {
- if (obj == null) {
- return null;
- }
-
- if (obj instanceof String) {
- return new RequestParameter[] {
- new RequestParameterImpl((String)obj, null)
- };
- } else if (obj instanceof String[]) {
- String [] strValues = (String[])obj;
- RequestParameter [] values = new RequestParameter[strValues.length];
- for (int i=0; i < strValues.length; i++) {
- values[i] = new RequestParameterImpl(strValues[i], null);
- }
- return values;
- } else if (obj instanceof RequestParameter) {
- return new RequestParameter[] {(RequestParameter)obj};
- } else if (obj instanceof RequestParameter[]) {
- return (RequestParameter[])obj;
- }
- return null;
- }
-
- static class RequestParameterImpl implements RequestParameter {
-
- private String value;
- private String encoding;
-
- private byte[] content;
-
- RequestParameterImpl(String value, String encoding) {
- this.encoding = encoding;
- this.value = value;
- this.content = null;
- }
-
- String getEncoding() {
- return this.encoding;
- }
-
- void setEncoding(String encoding) {
- // recode this parameter by encoding the string with the current
- // encoding and decode the bytes with the encoding
- try {
- this.value = getString(encoding);
- } catch (UnsupportedEncodingException uee) {
- throw new SlingUnsupportedEncodingException(uee);
- }
- this.encoding = encoding;
- }
-
- /**
- * @see org.apache.sling.api.request.RequestParameter#get()
- */
- public byte[] get() {
- if (content == null) {
- try {
- content = getString().getBytes(getEncoding());
- } catch (Exception e) {
- // UnsupportedEncodingException, IllegalArgumentException
- content = getString().getBytes();
- }
- }
- return content;
- }
-
- /**
- * @see org.apache.sling.api.request.RequestParameter#getContentType()
- */
- public String getContentType() {
- // none known for www-form-encoded parameters
- return null;
- }
-
- /**
- * @see org.apache.sling.api.request.RequestParameter#getInputStream()
- */
- public InputStream getInputStream() {
- return new ByteArrayInputStream(this.get());
- }
-
- /**
- * @see org.apache.sling.api.request.RequestParameter#getFileName()
- */
- public String getFileName() {
- // no original file name
- return null;
- }
-
- /**
- * @see org.apache.sling.api.request.RequestParameter#getSize()
- */
- public long getSize() {
- return this.get().length;
- }
-
- /**
- * @see org.apache.sling.api.request.RequestParameter#getString()
- */
- public String getString() {
- return value;
- }
-
- /**
- * @see org.apache.sling.api.request.RequestParameter#getString(java.lang.String)
- */
- public String getString(String encoding)
- throws UnsupportedEncodingException {
- return new String(this.get(), encoding);
- }
-
- /**
- * @see org.apache.sling.api.request.RequestParameter#isFormField()
- */
- public boolean isFormField() {
- // www-form-encoded are always form fields
- return true;
- }
-
- public String toString() {
- return this.getString();
- }
- }
-
- static class SlingUnsupportedEncodingException extends SlingIOException {
-
- private static final long serialVersionUID = -4482276105859280247L;
-
- SlingUnsupportedEncodingException(UnsupportedEncodingException uee) {
- super(uee);
- }
+ static class RequestParameterImpl implements RequestParameter {
- }
+ private String value;
+ private String encoding;
+
+ private byte[] content;
+
+ RequestParameterImpl(String value, String encoding) {
+ this.encoding = encoding;
+ this.value = value;
+ this.content = null;
+ }
+
+ String getEncoding() {
+ return this.encoding;
+ }
+
+ void setEncoding(String encoding) {
+ // recode this parameter by encoding the string with the current
+ // encoding and decode the bytes with the encoding
+ try {
+ this.value = getString(encoding);
+ } catch (UnsupportedEncodingException uee) {
+ throw new SlingUnsupportedEncodingException(uee);
+ }
+ this.encoding = encoding;
+ }
+
+ /**
+ * @see org.apache.sling.api.request.RequestParameter#get()
+ */
+ public byte[] get() {
+ if (content == null) {
+ try {
+ content = getString().getBytes(getEncoding());
+ } catch (Exception e) {
+ // UnsupportedEncodingException, IllegalArgumentException
+ content = getString().getBytes();
+ }
+ }
+ return content;
+ }
+
+ /**
+ * @see org.apache.sling.api.request.RequestParameter#getContentType()
+ */
+ public String getContentType() {
+ // none known for www-form-encoded parameters
+ return null;
+ }
+
+ /**
+ * @see org.apache.sling.api.request.RequestParameter#getInputStream()
+ */
+ public InputStream getInputStream() {
+ return new ByteArrayInputStream(this.get());
+ }
+
+ /**
+ * @see org.apache.sling.api.request.RequestParameter#getFileName()
+ */
+ public String getFileName() {
+ // no original file name
+ return null;
+ }
+
+ /**
+ * @see org.apache.sling.api.request.RequestParameter#getSize()
+ */
+ public long getSize() {
+ return this.get().length;
+ }
+
+ /**
+ * @see org.apache.sling.api.request.RequestParameter#getString()
+ */
+ public String getString() {
+ return value;
+ }
+
+ /**
+ * @see org.apache.sling.api.request.RequestParameter#getString(java.lang.String)
+ */
+ public String getString(String encoding)
+ throws UnsupportedEncodingException {
+ return new String(this.get(), encoding);
+ }
+
+ /**
+ * @see org.apache.sling.api.request.RequestParameter#isFormField()
+ */
+ public boolean isFormField() {
+ // www-form-encoded are always form fields
+ return true;
+ }
+
+ public String toString() {
+ return this.getString();
+ }
+ }
+
+ static class SlingUnsupportedEncodingException extends SlingIOException {
+
+ private static final long serialVersionUID = -4482276105859280247L;
+
+ SlingUnsupportedEncodingException(UnsupportedEncodingException uee) {
+ super(uee);
+ }
+
+ }
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractGroupPostServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractGroupPostServlet.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractGroupPostServlet.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractGroupPostServlet.java Thu Nov 10 21:21:44 2011
@@ -49,9 +49,9 @@ public abstract class AbstractGroupPostS
* @throws RepositoryException
*/
protected void updateGroupMembership(Resource baseResource,
- Map<String, ?> properties,
- Authorizable authorizable,
- List<Modification> changes)
+ Map<String, ?> properties,
+ Authorizable authorizable,
+ List<Modification> changes)
throws RepositoryException {
if (authorizable.isGroup()) {
Group group = ((Group) authorizable);
@@ -106,23 +106,23 @@ public abstract class AbstractGroupPostS
* @param resolver the resource resolver for this request.
* @return the authorizable, or null if no authorizable was found.
*/
- private Authorizable getAuthorizable(Resource baseResource,
- String member,
- UserManager userManager,
- ResourceResolver resolver) {
- Authorizable memberAuthorizable = null;
- try {
- memberAuthorizable = userManager.getAuthorizable(member);
- } catch (RepositoryException e) {
- // if we can't find the members then it may be resolvable as a resource.
- }
- if ( memberAuthorizable == null ) {
- Resource res = resolver.getResource(baseResource, member);
- if (res != null) {
- memberAuthorizable = res.adaptTo(Authorizable.class);
- }
- }
- return memberAuthorizable;
- }
+ private Authorizable getAuthorizable(Resource baseResource,
+ String member,
+ UserManager userManager,
+ ResourceResolver resolver) {
+ Authorizable memberAuthorizable = null;
+ try {
+ memberAuthorizable = userManager.getAuthorizable(member);
+ } catch (RepositoryException e) {
+ // if we can't find the members then it may be resolvable as a resource.
+ }
+ if ( memberAuthorizable == null ) {
+ Resource res = resolver.getResource(baseResource, member);
+ if (res != null) {
+ memberAuthorizable = res.adaptTo(Authorizable.class);
+ }
+ }
+ return memberAuthorizable;
+ }
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractPostServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractPostServlet.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractPostServlet.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractPostServlet.java Thu Nov 10 21:21:44 2011
@@ -45,9 +45,9 @@ import org.slf4j.LoggerFactory;
public abstract class AbstractPostServlet extends
SlingAllMethodsServlet {
- private static final long serialVersionUID = 7408267654653472120L;
-
- /**
+ private static final long serialVersionUID = 7408267654653472120L;
+
+ /**
* default log
*/
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -161,11 +161,11 @@ public abstract class AbstractPostServle
* or a {@link org.apache.sling.api.servlets.HtmlResponse} otherwise
*/
protected HtmlResponse createHtmlResponse(SlingHttpServletRequest req) {
- if (JSONResponse.RESPONSE_CONTENT_TYPE.equals(req.getResponseContentType())) {
- return new JSONResponse();
- } else {
+ if (JSONResponse.RESPONSE_CONTENT_TYPE.equals(req.getResponseContentType())) {
+ return new JSONResponse();
+ } else {
return new HtmlResponse();
- }
+ }
}
/**
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/ChangeUserPasswordServlet.java Thu Nov 10 21:21:44 2011
@@ -126,7 +126,7 @@ public class ChangeUserPasswordServlet e
Dictionary<?, ?> props = componentContext.getProperties();
this.userAdminGroupName = OsgiUtil.toString(props.get(PAR_USER_ADMIN_GROUP_NAME),
- DEFAULT_USER_ADMIN_GROUP_NAME);
+ DEFAULT_USER_ADMIN_GROUP_NAME);
log.info("User Admin Group Name {}", this.userAdminGroupName);
}
@@ -141,45 +141,45 @@ public class ChangeUserPasswordServlet e
protected void handleOperation(SlingHttpServletRequest request,
HtmlResponse htmlResponse, List<Modification> changes)
throws RepositoryException {
-
+
Resource resource = request.getResource();
Session session = request.getResourceResolver().adaptTo(Session.class);
- changePassword(session,
- resource.getName(),
- request.getParameter("oldPwd"),
- request.getParameter("newPwd"),
- request.getParameter("newPwdConfirm"),
- changes);
+ changePassword(session,
+ resource.getName(),
+ request.getParameter("oldPwd"),
+ request.getParameter("newPwd"),
+ request.getParameter("newPwdConfirm"),
+ changes);
}
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.ChangeUserPassword#changePassword(javax.jcr.Session, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.List)
- */
- public User changePassword(Session jcrSession,
- String name,
- String oldPassword,
- String newPassword,
- String newPasswordConfirm,
- List<Modification> changes)
- throws RepositoryException {
-
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.ChangeUserPassword#changePassword(javax.jcr.Session, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.List)
+ */
+ public User changePassword(Session jcrSession,
+ String name,
+ String oldPassword,
+ String newPassword,
+ String newPasswordConfirm,
+ List<Modification> changes)
+ throws RepositoryException {
+
if ("anonymous".equals(name)) {
throw new RepositoryException(
"Can not change the password of the anonymous user.");
}
-
- User user;
+
+ User user;
UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
Authorizable authorizable = userManager.getAuthorizable(name);
if (authorizable instanceof User) {
- user = (User)authorizable;
+ user = (User)authorizable;
} else {
throw new ResourceNotFoundException(
- "User to update could not be determined");
+ "User to update could not be determined");
}
- //SLING-2069: if the current user is an administrator, then a missing oldPwd is ok,
- // otherwise the oldPwd must be supplied.
+ //SLING-2069: if the current user is an administrator, then a missing oldPwd is ok,
+ // otherwise the oldPwd must be supplied.
boolean administrator = false;
// check that the submitted parameter values have valid values.
@@ -190,22 +190,22 @@ public class ChangeUserPasswordServlet e
administrator = currentUser.isAdmin();
if (!administrator) {
- //check if the user is a member of the 'User administrator' group
- Authorizable userAdmin = um.getAuthorizable(this.userAdminGroupName);
- if (userAdmin instanceof Group) {
- boolean isMember = ((Group)userAdmin).isMember(currentUser);
- if (isMember) {
- administrator = true;
- }
- }
-
+ //check if the user is a member of the 'User administrator' group
+ Authorizable userAdmin = um.getAuthorizable(this.userAdminGroupName);
+ if (userAdmin instanceof Group) {
+ boolean isMember = ((Group)userAdmin).isMember(currentUser);
+ if (isMember) {
+ administrator = true;
+ }
+ }
+
}
} catch ( Exception ex ) {
log.warn("Failed to determine if the user is an admin, assuming not. Cause: "+ex.getMessage());
administrator = false;
}
if (!administrator) {
- throw new RepositoryException("Old Password was not submitted");
+ throw new RepositoryException("Old Password was not submitted");
}
}
if (newPassword == null || newPassword.length() == 0) {
@@ -225,7 +225,7 @@ public class ChangeUserPasswordServlet e
((User) authorizable).changePassword(digestPassword(newPassword));
String userPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX
- + user.getID();
+ + user.getID();
changes.add(Modification.onModified(userPath
+ "/rep:password"));
@@ -234,7 +234,7 @@ public class ChangeUserPasswordServlet e
}
return user;
- }
+ }
private void checkPassword(Authorizable authorizable, String oldPassword)
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateGroupServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateGroupServlet.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateGroupServlet.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateGroupServlet.java Thu Nov 10 21:21:44 2011
@@ -88,7 +88,7 @@ public class CreateGroupServlet extends
private static final long serialVersionUID = -1084915263933901466L;
/** @scr.reference */
- private JcrResourceResolverFactory resourceResolverFactory;
+ private JcrResourceResolverFactory resourceResolverFactory;
/*
* (non-Javadoc)
@@ -105,28 +105,28 @@ public class CreateGroupServlet extends
Session session = request.getResourceResolver().adaptTo(Session.class);
String principalName = request.getParameter(SlingPostConstants.RP_NODE_NAME);
Group group = createGroup(session,
- principalName,
- request.getRequestParameterMap(),
- changes);
+ principalName,
+ request.getRequestParameterMap(),
+ changes);
String groupPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX
- + group.getID();
+ + group.getID();
response.setPath(groupPath);
response.setLocation(externalizePath(request, groupPath));
response.setParentLocation(externalizePath(request,
AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PATH));
}
-
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.CreateGroup#createGroup(javax.jcr.Session, java.lang.String, java.util.Map, java.util.List)
- */
- public Group createGroup(Session jcrSession, final String name,
- Map<String, ?> properties, List<Modification> changes)
- throws RepositoryException {
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.CreateGroup#createGroup(javax.jcr.Session, java.lang.String, java.util.Map, java.util.List)
+ */
+ public Group createGroup(Session jcrSession, final String name,
+ Map<String, ?> properties, List<Modification> changes)
+ throws RepositoryException {
// check that the parameter values have valid values.
- if (jcrSession == null) {
- throw new IllegalArgumentException("JCR Session not found");
+ if (jcrSession == null) {
+ throw new IllegalArgumentException("JCR Session not found");
}
if (name == null || name.length() == 0) {
@@ -162,18 +162,18 @@ public class CreateGroupServlet extends
// update the group memberships
ResourceResolver resourceResolver = null;
try {
- //create a resource resolver to resolve the relative paths used for group membership values
+ //create a resource resolver to resolve the relative paths used for group membership values
resourceResolver = resourceResolverFactory.getResourceResolver(jcrSession);
Resource baseResource = resourceResolver.getResource(AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PATH);
updateGroupMembership(baseResource, properties, group, changes);
} finally {
- if (resourceResolver != null) {
- resourceResolver.close();
- }
+ if (resourceResolver != null) {
+ resourceResolver.close();
+ }
}
}
return group;
- }
+ }
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/CreateUserServlet.java Thu Nov 10 21:21:44 2011
@@ -170,7 +170,7 @@ public class CreateUserServlet extends A
Dictionary<?, ?> props = componentContext.getProperties();
Object propValue = props.get(PROP_SELF_REGISTRATION_ENABLED);
if (propValue instanceof Boolean) {
- selfRegistrationEnabled = (Boolean)propValue;
+ selfRegistrationEnabled = (Boolean)propValue;
} else if (propValue instanceof String) {
selfRegistrationEnabled = Boolean.parseBoolean((String) propValue);
} else {
@@ -178,7 +178,7 @@ public class CreateUserServlet extends A
}
this.userAdminGroupName = OsgiUtil.toString(props.get(PAR_USER_ADMIN_GROUP_NAME),
- DEFAULT_USER_ADMIN_GROUP_NAME);
+ DEFAULT_USER_ADMIN_GROUP_NAME);
log.info("User Admin Group Name {}", this.userAdminGroupName);
}
@@ -197,32 +197,32 @@ public class CreateUserServlet extends A
Session session = request.getResourceResolver().adaptTo(Session.class);
String principalName = request.getParameter(SlingPostConstants.RP_NODE_NAME);
- User user = createUser(session,
- principalName,
- request.getParameter("pwd"),
- request.getParameter("pwdConfirm"),
- request.getRequestParameterMap(),
- changes);
-
+ User user = createUser(session,
+ principalName,
+ request.getParameter("pwd"),
+ request.getParameter("pwdConfirm"),
+ request.getRequestParameterMap(),
+ changes);
+
String userPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_USER_PREFIX
- + user.getID();
+ + user.getID();
response.setPath(userPath);
response.setLocation(externalizePath(request, userPath));
response.setParentLocation(externalizePath(request,
AuthorizableResourceProvider.SYSTEM_USER_MANAGER_USER_PATH));
}
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.CreateUser#createUser(javax.jcr.Session, java.lang.String, java.lang.String, java.lang.String, java.util.Map, java.util.List)
- */
- public User createUser(Session jcrSession,
- String name,
- String password,
- String passwordConfirm,
- Map<String, ?> properties,
- List<Modification> changes)
- throws RepositoryException {
-
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.CreateUser#createUser(javax.jcr.Session, java.lang.String, java.lang.String, java.lang.String, java.util.Map, java.util.List)
+ */
+ public User createUser(Session jcrSession,
+ String name,
+ String password,
+ String passwordConfirm,
+ Map<String, ?> properties,
+ List<Modification> changes)
+ throws RepositoryException {
+
if (jcrSession == null) {
throw new RepositoryException("JCR Session not found");
}
@@ -235,15 +235,15 @@ public class CreateUserServlet extends A
administrator = currentUser.isAdmin();
if (!administrator) {
- //check if the user is a member of the 'User administrator' group
- Authorizable userAdmin = um.getAuthorizable(this.userAdminGroupName);
- if (userAdmin instanceof Group) {
- boolean isMember = ((Group)userAdmin).isMember(currentUser);
- if (isMember) {
- administrator = true;
- }
- }
-
+ //check if the user is a member of the 'User administrator' group
+ Authorizable userAdmin = um.getAuthorizable(this.userAdminGroupName);
+ if (userAdmin instanceof Group) {
+ boolean isMember = ((Group)userAdmin).isMember(currentUser);
+ if (isMember) {
+ administrator = true;
+ }
+ }
+
}
} catch ( Exception ex ) {
log.warn("Failed to determine if the user is an admin, assuming not. Cause: "+ex.getMessage());
@@ -275,11 +275,11 @@ public class CreateUserServlet extends A
boolean useAdminSession = !administrator && selfRegistrationEnabled;
try {
if (useAdminSession) {
- //the current user doesn't have permission to create the user,
- // but self-registration is enabled, so use an admin session
- // to do the work.
+ //the current user doesn't have permission to create the user,
+ // but self-registration is enabled, so use an admin session
+ // to do the work.
selfRegSession = getSession();
- }
+ }
UserManager userManager = AccessControlUtil.getUserManager(selfRegSession);
Authorizable authorizable = userManager.getAuthorizable(name);
@@ -307,24 +307,24 @@ public class CreateUserServlet extends A
}
if (useAdminSession) {
- //lookup the user from the user session so we can return a live object
+ //lookup the user from the user session so we can return a live object
UserManager userManager2 = AccessControlUtil.getUserManager(jcrSession);
Authorizable authorizable2 = userManager2.getAuthorizable(user.getID());
if (authorizable2 instanceof User) {
- user = (User)authorizable2;
+ user = (User)authorizable2;
} else {
- user = null;
+ user = null;
}
}
}
} finally {
if (useAdminSession) {
- //done with the self-reg admin session, so clean it up
+ //done with the self-reg admin session, so clean it up
ungetSession(selfRegSession);
- }
+ }
}
-
- return user;
- }
+
+ return user;
+ }
}
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/DeleteAuthorizableServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/DeleteAuthorizableServlet.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/DeleteAuthorizableServlet.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/DeleteAuthorizableServlet.java Thu Nov 10 21:21:44 2011
@@ -88,7 +88,7 @@ import org.apache.sling.servlets.post.Sl
* @scr.property name="sling.servlet.selectors" value="delete"
*/
public class DeleteAuthorizableServlet extends AbstractPostServlet
- implements DeleteUser, DeleteGroup, DeleteAuthorizables {
+ implements DeleteUser, DeleteGroup, DeleteAuthorizables {
private static final long serialVersionUID = 5874621724096106496L;
/*
@@ -107,10 +107,10 @@ public class DeleteAuthorizableServlet e
Resource resource = request.getResource();
String[] applyTo = request.getParameterValues(SlingPostConstants.RP_APPLY_TO);
if (applyTo != null) {
- deleteAuthorizables(session,
- resource,
- applyTo,
- changes);
+ deleteAuthorizables(session,
+ resource,
+ applyTo,
+ changes);
} else {
Authorizable item = resource.adaptTo(Authorizable.class);
if (item == null) {
@@ -119,70 +119,70 @@ public class DeleteAuthorizableServlet e
htmlResponse.setStatus(HttpServletResponse.SC_NOT_FOUND, msg);
throw new ResourceNotFoundException(msg);
} else {
- if (item instanceof User) {
- deleteUser(session, item.getID(), changes);
- } else if (item instanceof Group) {
- deleteGroup(session, item.getID(), changes);
- }
+ if (item instanceof User) {
+ deleteUser(session, item.getID(), changes);
+ } else if (item instanceof Group) {
+ deleteGroup(session, item.getID(), changes);
+ }
}
}
}
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.DeleteUser#deleteUser(javax.jcr.Session, java.lang.String, java.util.List)
- */
- public void deleteUser(Session jcrSession, String name,
- List<Modification> changes) throws RepositoryException {
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.DeleteUser#deleteUser(javax.jcr.Session, java.lang.String, java.util.List)
+ */
+ public void deleteUser(Session jcrSession, String name,
+ List<Modification> changes) throws RepositoryException {
- User user;
- UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
+ User user;
+ UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
Authorizable authorizable = userManager.getAuthorizable(name);
if (authorizable instanceof User) {
- user = (User)authorizable;
+ user = (User)authorizable;
} else {
throw new ResourceNotFoundException(
- "User to delete could not be determined");
+ "User to delete could not be determined");
}
String userPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_USER_PREFIX
- + user.getID();
+ + user.getID();
user.remove();
changes.add(Modification.onDeleted(userPath));
- }
-
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.DeleteGroup#deleteGroup(javax.jcr.Session, java.lang.String, java.util.List)
- */
- public void deleteGroup(Session jcrSession,
- String name,
- List<Modification> changes) throws RepositoryException {
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.DeleteGroup#deleteGroup(javax.jcr.Session, java.lang.String, java.util.List)
+ */
+ public void deleteGroup(Session jcrSession,
+ String name,
+ List<Modification> changes) throws RepositoryException {
- Group group;
- UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
+ Group group;
+ UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
Authorizable authorizable = userManager.getAuthorizable(name);
if (authorizable instanceof Group) {
- group = (Group)authorizable;
+ group = (Group)authorizable;
} else {
throw new ResourceNotFoundException(
- "Group to delete could not be determined");
+ "Group to delete could not be determined");
}
String groupPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX
- + group.getID();
+ + group.getID();
group.remove();
changes.add(Modification.onDeleted(groupPath));
- }
+ }
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.DeleteAuthorizables#deleteAuthorizables(javax.jcr.Session, org.apache.sling.api.resource.Resource, java.lang.String[], java.util.List)
- */
- public void deleteAuthorizables(Session jcrSession,
- Resource baseResource,
- String[] paths,
- List<Modification> changes)
- throws RepositoryException {
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.DeleteAuthorizables#deleteAuthorizables(javax.jcr.Session, org.apache.sling.api.resource.Resource, java.lang.String[], java.util.List)
+ */
+ public void deleteAuthorizables(Session jcrSession,
+ Resource baseResource,
+ String[] paths,
+ List<Modification> changes)
+ throws RepositoryException {
- ApplyToIterator iterator = new ApplyToIterator(baseResource, paths);
+ ApplyToIterator iterator = new ApplyToIterator(baseResource, paths);
while (iterator.hasNext()) {
Resource resource = iterator.next();
Authorizable item = resource.adaptTo(Authorizable.class);
@@ -191,7 +191,7 @@ public class DeleteAuthorizableServlet e
changes.add(Modification.onDeleted(resource.getPath()));
}
}
- }
+ }
private static class ApplyToIterator implements Iterator<Resource> {
Modified: sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/UpdateGroupServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/UpdateGroupServlet.java?rev=1200559&r1=1200558&r2=1200559&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/UpdateGroupServlet.java (original)
+++ sling/trunk/bundles/jcr/jackrabbit-usermanager/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/UpdateGroupServlet.java Thu Nov 10 21:21:44 2011
@@ -85,11 +85,11 @@ import org.apache.sling.servlets.post.im
* @scr.property name="sling.servlet.selectors" value="update"
*/
public class UpdateGroupServlet extends AbstractGroupPostServlet
- implements UpdateGroup {
+ implements UpdateGroup {
private static final long serialVersionUID = -8292054361992488797L;
/** @scr.reference */
- private JcrResourceResolverFactory resourceResolverFactory;
+ private JcrResourceResolverFactory resourceResolverFactory;
/*
* (non-Javadoc)
@@ -105,30 +105,30 @@ public class UpdateGroupServlet extends
Resource resource = request.getResource();
Session session = request.getResourceResolver().adaptTo(Session.class);
updateGroup(session,
- resource.getName(),
- request.getRequestParameterMap(),
- changes);
+ resource.getName(),
+ request.getRequestParameterMap(),
+ changes);
}
- /* (non-Javadoc)
- * @see org.apache.sling.jackrabbit.usermanager.UpdateGroup#updateGroup(javax.jcr.Session, java.lang.String, java.util.Map, java.util.List)
- */
- public Group updateGroup(Session jcrSession,
- String name,
- Map<String, ?> properties,
- List<Modification> changes)
- throws RepositoryException {
+ /* (non-Javadoc)
+ * @see org.apache.sling.jackrabbit.usermanager.UpdateGroup#updateGroup(javax.jcr.Session, java.lang.String, java.util.Map, java.util.List)
+ */
+ public Group updateGroup(Session jcrSession,
+ String name,
+ Map<String, ?> properties,
+ List<Modification> changes)
+ throws RepositoryException {
- Group group = null;
+ Group group = null;
UserManager userManager = AccessControlUtil.getUserManager(jcrSession);
Authorizable authorizable = userManager.getAuthorizable(name);
if (authorizable instanceof Group) {
- group = (Group)authorizable;
+ group = (Group)authorizable;
} else {
throw new ResourceNotFoundException(
- "Group to update could not be determined");
+ "Group to update could not be determined");
}
-
+
String groupPath = AuthorizableResourceProvider.SYSTEM_USER_MANAGER_GROUP_PREFIX
+ group.getID();
@@ -143,19 +143,19 @@ public class UpdateGroupServlet extends
// update the group memberships
ResourceResolver resourceResolver = null;
try {
- //create a resource resolver to resolve the relative paths used for group membership values
+ //create a resource resolver to resolve the relative paths used for group membership values
resourceResolver = resourceResolverFactory.getResourceResolver(jcrSession);
Resource baseResource = resourceResolver.getResource(groupPath);
updateGroupMembership(baseResource, properties, group, changes);
} finally {
- if (resourceResolver != null) {
- resourceResolver.close();
- }
+ if (resourceResolver != null) {
+ resourceResolver.close();
+ }
}
} catch (RepositoryException re) {
throw new RepositoryException("Failed to update group.", re);
}
return group;
- }
+ }
}