javax.jcr.security.AccessControlException Java Examples

The following examples show how to use javax.jcr.security.AccessControlException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PurRepositoryTestingUtils.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Create a {@linkplain JcrCallback} for setting up ACL management in test repository
 * 
 * @return acl management callback
 */
static JcrCallback setAclManagementCallback() {
  return new JcrCallback() {
    @Override
    public Object doInJcr( Session session ) throws IOException, RepositoryException {
      PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
      Workspace workspace = session.getWorkspace();
      PrivilegeManager privilegeManager = ( (JackrabbitWorkspace) workspace ).getPrivilegeManager();
      try {
        privilegeManager.getPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE() );
      } catch ( AccessControlException ace ) {
        privilegeManager.registerPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE(), false,
            new String[0] );
      }
      session.save();
      return null;
    }
  };
}
 
Example #2
Source File: UIEERepositoryDirectoryIT.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
private void setAclManagement() {
  testJcrTemplate.execute( new JcrCallback() {
    @Override
    public Object doInJcr( Session session ) throws IOException, RepositoryException {
      PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
      Workspace workspace = session.getWorkspace();
      PrivilegeManager privilegeManager = ( (JackrabbitWorkspace) workspace ).getPrivilegeManager();
      try {
        privilegeManager.getPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE() );
      } catch ( AccessControlException ace ) {
        privilegeManager.registerPrivilege( pentahoJcrConstants.getPHO_ACLMANAGEMENT_PRIVILEGE(), false,
            new String[0] );
      }
      session.save();
      return null;
    }
  } );
}
 
Example #3
Source File: JackrabbitAccessControlListUtil.java    From APM with Apache License 2.0 5 votes vote down vote up
public static JackrabbitAccessControlList getModifiableAcl(final AccessControlManager accessManager,
		final String path) throws RepositoryException {
	final JackrabbitAccessControlList acl = getAccessControlList(accessManager, path);
	if (null != acl) {
		return acl;
	}

	final JackrabbitAccessControlList applicableAcl = getApplicableAccessControlList(accessManager, path);
	if (null != applicableAcl) {
		return applicableAcl;
	}

	throw new AccessControlException("No modifiable ACL at " + path);
}
 
Example #4
Source File: PermissionActionHelper.java    From APM with Apache License 2.0 5 votes vote down vote up
private List<Privilege> createPrivileges(final AccessControlManager accessControlManager,
    final String permission) throws RepositoryException, PermissionException {
  try {
    Optional<PrivilegeGroup> privilegeGroup = PrivilegeGroup.getFromTitle(permission);
    if (privilegeGroup.isPresent()) {
      return privilegeGroup.get().toPrivileges(accessControlManager);
    } else {
      return Collections.singletonList(accessControlManager.privilegeFromName(permission));
    }
  } catch (AccessControlException e) {
    throw new PermissionException("Unknown permission " + permission, e);
  }
}
 
Example #5
Source File: JackrabbitACLImporter.java    From jackrabbit-filevault with Apache License 2.0 5 votes vote down vote up
T getApplicablePolicy(Class<T> clz, Principal principal) throws RepositoryException {
    if (acMgr instanceof JackrabbitAccessControlManager) {
        for (AccessControlPolicy p : ((JackrabbitAccessControlManager) acMgr).getApplicablePolicies(principal)) {
            if (clz.isAssignableFrom(p.getClass())) {
                return (T) p;
            }
        }
    }

    // no applicable policy
    throw new AccessControlException("no applicable AccessControlPolicy of type "+ clz + " for " + principal.getName());
}
 
Example #6
Source File: JackrabbitAccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public JackrabbitAccessControlPolicy[] getApplicablePolicies(Principal principal) throws AccessDeniedException, AccessControlException, UnsupportedRepositoryOperationException, RepositoryException {
    return delegate.getApplicablePolicies(principal);
}
 
Example #7
Source File: JackrabbitAccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public JackrabbitAccessControlPolicy[] getPolicies(Principal principal) throws AccessDeniedException, AccessControlException, UnsupportedRepositoryOperationException, RepositoryException {
    return delegate.getPolicies(principal);
}
 
Example #8
Source File: JackrabbitAccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public AccessControlPolicy[] getEffectivePolicies(Set<Principal> principals) throws AccessDeniedException, AccessControlException, UnsupportedRepositoryOperationException, RepositoryException {
    return delegate.getEffectivePolicies(principals);
}
 
Example #9
Source File: PrivilegeManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public Privilege getPrivilege(String privilegeName) throws AccessControlException, RepositoryException {
    return delegate.getPrivilege(privilegeName);
}
 
Example #10
Source File: AccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public Privilege privilegeFromName(String privilegeName) throws AccessControlException, RepositoryException {
    return delegate.privilegeFromName(privilegeName);
}
 
Example #11
Source File: AccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public void setPolicy(String absPath, AccessControlPolicy policy) throws PathNotFoundException, AccessControlException, AccessDeniedException, LockException, VersionException, RepositoryException {
    delegate.setPolicy(absPath, policy);
}
 
Example #12
Source File: AccessControlManagerWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public void removePolicy(String absPath, AccessControlPolicy policy) throws PathNotFoundException, AccessControlException, AccessDeniedException, LockException, VersionException, RepositoryException {
    delegate.removePolicy(absPath, policy);
}