Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Alfresco - Simple Dynamic Authority
package org.alfresco.extension;
import java.util.Set;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.QName;
public class SimpleDynamicAuthority implements DynamicAuthority {
private static final String AUTHORITY_NAME = "SIMPLE_DYNAMIC_AUTHORITY";
private static final String FORBIDDEN_ITEM_NAME = "Private item";
private static final String FORBIDDEN_FOR_USERNAME = "bart.simpson";
private NodeService nodeService;
private boolean doGrantAuthority = true
public boolean hasAuthority(NodeRef nodeRef, String username) {
String name = (String) nodeService.getProperty(nodeRef, QName.createQName("{}name"));
if(name.startsWith(FORBIDDEN_ITEM_NAME) && FORBIDDEN_FOR_USERNAME.equals(username)){
doGrantAuthority = false;
return doGrantAuthority;
public String getAuthority() {
public Set<PermissionReference> requiredFor() {
return null; // required for all checks
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment