use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrAccessControlUtil method removeHierarchyAllPermissions.
public static boolean removeHierarchyAllPermissions(Node node, Principal principal, Node toNode) {
try {
Node current = node;
Node rootNode = toNode.getSession().getRootNode();
boolean removed = false;
while (!current.equals(toNode) && !current.equals(rootNode)) {
removed |= removeAllPermissions(node.getSession(), current.getPath(), principal);
current = current.getParent();
}
if (current.equals(rootNode) && !toNode.equals(rootNode)) {
throw new IllegalArgumentException("removeHierarchyAllPermissions: The \"toNode\" argument is not in the \"node\" argument's hierarchy: " + toNode);
} else {
removed |= removeAllPermissions(node.getSession(), current.getPath(), principal);
}
return removed;
} catch (AccessDeniedException e) {
throw new AccessControlException(e.getMessage());
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to remove all permission(s) from hierarch from node " + node + " up to " + toNode, e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrAccessControlUtil method getPrivileges.
public static Set<Privilege> getPrivileges(Session session, Principal principal, String path) {
try {
AccessControlManager acm = session.getAccessControlManager();
AccessControlList acl = getAccessControlList(path, acm);
for (AccessControlEntry entry : acl.getAccessControlEntries()) {
if (matchesPrincipal(principal, entry)) {
return new HashSet<>(Arrays.asList(entry.getPrivileges()));
}
}
return Collections.emptySet();
} catch (AccessDeniedException e) {
throw new AccessControlException(e.getMessage());
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to get the privileges for node " + path, e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrActionsGroupBuilder method build.
/* (non-Javadoc)
* @see com.thinkbiganalytics.security.action.config.ActionsModuleBuilder#build()
*/
@Override
public AllowedActions build() {
try {
Session session = this.protoActionsNode.getSession();
JcrAccessControlUtil.addPermissions(this.protoActionsNode, this.managementPrincipal, Privilege.JCR_ALL);
JcrAccessControlUtil.addPermissions(this.protoActionsNode, new UsernamePrincipal(session.getUserID()), Privilege.JCR_ALL);
JcrAccessControlUtil.addPermissions(this.protoActionsNode, SimplePrincipal.EVERYONE, Privilege.JCR_READ);
JcrAllowedActions protoAllowed = new JcrAllowedActions(this.protoActionsNode);
return protoAllowed;
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to build action", e);
}
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrAllowableAction method hashCode.
@Override
public int hashCode() {
// Hierarchy is fixed so hash code need only be calculated once.
if (this.hash == 0) {
try {
List<String> hierList = new ArrayList<>();
Node current = getNode();
while (JcrUtil.isNodeType(current, NODE_TYPE)) {
hierList.add(0, current.getName());
current = current.getParent();
}
this.hash = hierList.hashCode();
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to access action hierarchy of node: " + this.getNode(), e);
}
}
return this.hash;
}
use of com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException in project kylo by Teradata.
the class JcrAllowedEntityActionsProvider method getActions.
protected Optional<AllowedActions> getActions(String groupName, Path groupPath) {
try {
Session session = JcrMetadataAccess.getActiveSession();
if (session.getRootNode().hasNode(groupPath.toString())) {
Node node = session.getRootNode().getNode(groupPath.toString());
JcrAllowedActions actions = new JcrAllowedActions(node);
return Optional.of(actions);
} else {
return Optional.empty();
}
} catch (AccessDeniedException e) {
return Optional.empty();
} catch (RepositoryException e) {
throw new MetadataRepositoryException("Failed to access allowable actions for module: " + groupName, e);
}
}
Aggregations