Skip to content
All gists
Back to GitHub
Sign in
Sign up
Sign in
Sign up
{{ message }}
Instantly share code, notes, and snippets.
kylefernandadams
/
SimpleDynamicAuthority
Created
July 14, 2014 14:57
Star
2
Fork
0
Star
Code
Revisions
1
Stars
2
Embed
What would you like to do?
Embed
Embed this gist in your website.
Share
Copy sharable link for this gist.
Clone via HTTPS
Clone with Git or checkout with SVN using the repository’s web address.
Learn more about clone URLs
Download ZIP
Alfresco - Simple Dynamic Authority
Raw
SimpleDynamicAuthority
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
package org.alfresco.extension;
import java.util.Set;
import org.alfresco.repo.security.permissions.DynamicAuthority;
import org.alfresco.repo.security.permissions.PermissionReference;
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("{http://www.alfresco.org/model/content/1.0}name"));
if(name.startsWith(FORBIDDEN_ITEM_NAME) && FORBIDDEN_FOR_USERNAME.equals(username)){
doGrantAuthority = false;
}
return doGrantAuthority;
}
public String getAuthority() {
return AUTHORITY_NAME;
}
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
You can’t perform that action at this time.
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.