You can use following code
import javax.jcr.security.AccessControlManager;
import javax.jcr.security.Privilege;
import com.day.cq.replication.Replicator;
import javax.jcr.Session;
public static boolean canReplicate(String path, Session session) throws RepositoryException {
AccessControlManager acMgr = session.getAccessControlManager();
return session.getAccessControlManager().hasPrivileges(path, new Privilege[] {acMgr.privilegeFromName(Replicator.REPLICATE_PRIVILEGE)});
}
In fact you can use this code to check any rights. Just replace privilege with any privilege in http://jackrabbit.apache.org/api/1.5/org/apache/jackrabbit/api/jsr283/security/Privilege.html
For example
privilegios[0] = acMgr.privilegeFromName(Privilege.JCR_READ);
privilegios[1] = acMgr.privilegeFromName(Privilege.JCR_ADD_CHILD_NODES);
privilegios[2] = acMgr.privilegeFromName(Privilege.JCR_REMOVE_CHILD_NODES);
.. More
This comment has been removed by the author.
ReplyDeleteYou can create session for any user you want using admin session and then impersonate or logged in session.
DeleteYogesh
Sorry, i was thinking that my question was really stupid. So my question would be: in a system with about 1500 to 3000 authors, about 100 groups and fine graned access control policies. How would i perform this check for like ... any user.
DeleteYou can create a utility that can take user name and give you access right. Also you can use crxde light and login as admin and for any path you can check effective permission (Either jcr:all or crx:replicate). Or through CRX explorer login in to crx explorer and then go to :/crx/explorer/ui/acltest.jsp to test.
DeleteHi Yogesh
ReplyDeleteHow can I get the source code for /crx/explorer/ui/acltest.jsp ? I tried to search in CRX but I could n't find it. I appreciate if you could let me know the location for this jsp file
Shaji
Thank you very much for this article.
ReplyDeleteMovers and Packers in Pune
Movers and Packers in Gurgaon
Movers and Packers in Bangalore
I am glad that I saw this post. It is informative blog for us and we need this type of blog thanks for share this blog, Keep posting such instructional blogs and I am looking forward for your future posts.
DeleteCyber Security Projects for Final Year
JavaScript Training in Chennai
Project Centers in Chennai
JavaScript Training in Chennai
Thank you very much for this article
ReplyDeletePackers and Movers Mumbai
Packers and Movers Navi Mumbai
Packers and Movers Thane
Packers and Movers Ghaziabad
Packers and Movers Faridabad
Packers and Movers Delhi
Packers and Movers Noida