コード例 #1
0
  public Privilege[] getPrivileges(String s) throws RepositoryException {

    Item item = registrySession.getItem(s);
    if (item instanceof Property) {
      throw new PathNotFoundException("No privilages can be added for Properties");
    }

    Set<Privilege> privileges = new HashSet<Privilege>();

    if (accessCtrlPolicies.get(s) instanceof RegistryAccessControlList) {

      AccessControlEntry[] accessNtries =
          ((RegistryAccessControlList) accessCtrlPolicies.get(s)).getAccessControlEntries();

      for (AccessControlEntry ac : accessNtries) {
        if (ac != null) {
          privileges.addAll(Arrays.asList(ac.getPrivileges()));
        }
      }
    } else {
      // TODO check how to apply NamedAccessControlPolicy
    }

    // Read-only session must have READ privilege on test node
    if (RegistryJCRSpecificStandardLoderUtil.isSessionReadOnly(registrySession.getUserID())
        && !privileges.contains(privilegeRegistry.getPrivilegeFromName(Privilege.JCR_READ))) {
      privileges.add(privilegeRegistry.getPrivilegeFromName(Privilege.JCR_READ));
    }

    if (privileges.size() != 0) {
      return privileges.toArray(new Privilege[privileges.size()]);
    } else return new Privilege[0];
  }
コード例 #2
0
  public void setPolicy(String s, AccessControlPolicy accessControlPolicy)
      throws RepositoryException {
    boolean invalidPolicy = true;
    // Invalid policy may not be set by a READ-only session
    if (RegistryJCRSpecificStandardLoderUtil.isSessionReadOnly(registrySession.getUserID())) {
      if ((accessControlPolicy instanceof RegistryAccessControlList)) {
        invalidPolicy = false;
      } else if ((accessControlPolicy instanceof RegistryNamedAccessControlPolicy)) {
        invalidPolicy = false;
      }
      if (invalidPolicy) {
        throw new AccessControlException("Invalid policy may not be set by a READ-only session");
      }
    }

    if (accessCtrlPolicies.get(s) == null) {

      Set<AccessControlPolicy> policies = new HashSet<AccessControlPolicy>();
      policies.add(accessControlPolicy);
      accessCtrlPolicies.put(s, policies);
    } else {

      accessCtrlPolicies.get(s).add(accessControlPolicy);
      //            Set<AccessControlPolicy> temp = accessCtrlPolicies.get(s);
      //            temp.add(accessControlPolicy);
      //            accessCtrlPolicies.remove(s);
      //            accessCtrlPolicies.put(s, temp);

    }
  }
コード例 #3
0
  public AccessControlPolicy[] getEffectivePolicies(String s) throws RepositoryException {

    if (RegistryJCRSpecificStandardLoderUtil.isSessionReadOnly(registrySession.getUserID())) {
      throw new AccessDeniedException("Read only session may not read AC content");
    }

    Item item = registrySession.getItem(s); // check the validity of the path
    if (item instanceof Property) {
      throw new PathNotFoundException("Cannot apply policies to a property path");
    }
    return getPolicies(s);
  }
コード例 #4
0
  public AccessControlPolicyIterator getApplicablePolicies(String s) throws RepositoryException {

    if (RegistryJCRSpecificStandardLoderUtil.isSessionReadOnly(registrySession.getUserID())) {
      throw new AccessDeniedException("Read only session may not read AC content");
    }

    if (accessCtrlPolicies.size() != 0) {

      return new RegistryAccessControlPolicyIterator(accessCtrlPolicies.get(s));
    } else {

      return new RegistryAccessControlPolicyIterator(new HashSet());
    }
  }
コード例 #5
0
  public AccessControlPolicy[] getPolicies(String s) throws RepositoryException {
    if (RegistryJCRSpecificStandardLoderUtil.isSessionReadOnly(registrySession.getUserID())) {
      throw new AccessDeniedException("Read only session may not read AC content");
    }

    if (accessCtrlPolicies.get(s) != null) {

      return accessCtrlPolicies
          .get(s)
          .toArray(new AccessControlPolicy[accessCtrlPolicies.get(s).size()]);
    } else {

      return new AccessControlPolicy[0];
    }
  }