- return userId;
- }
-
- protected void setHomeNodeAuthorizations(User user) {
- // give all privileges on user home
- // FIXME: fails on an empty repo
- String userId = "<not yet set>";
- try {
- userId = user.getID();
- Node userHome = JcrUtils.getUserHome(getSystemSession(), userId);
- // autocreate home node?
-// if (userHome == null)
-// userHome = JcrUtils.createUserHome(getSystemSession(),
-// HOME_BASE_PATH, userId);
-
- if (userHome != null) {
- String path = userHome.getPath();
- AccessControlPolicy policy = null;
- AccessControlManager acm = getSystemSession()
- .getAccessControlManager();
- AccessControlPolicyIterator policyIterator = acm
- .getApplicablePolicies(path);
- if (policyIterator.hasNext()) {
- policy = policyIterator.nextAccessControlPolicy();
- } else {
- AccessControlPolicy[] existingPolicies = acm
- .getPolicies(path);
- policy = existingPolicies[0];
- }
- if (policy instanceof AccessControlList) {
- Privilege[] privileges = { acm
- .privilegeFromName(Privilege.JCR_ALL) };
- ((AccessControlList) policy).addAccessControlEntry(
- user.getPrincipal(), privileges);
- acm.setPolicy(path, policy);
- }
- }
- } catch (Exception e) {
- log.warn("Cannot set authorization on user node for " + userId
- + ": " + e.getMessage());
- }
-