use of org.alfresco.repo.security.permissions.impl.SimplePermissionEntry in project alfresco-repository by Alfresco.
the class ACLEntryVoterTest method testBasicAllowStore.
public void testBasicAllowStore() throws Exception {
runAs("andy");
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ), "andy", AccessStatus.ALLOWED));
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("testOneStoreRef", new Class[] { StoreRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_NODE.0.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
method.invoke(proxy, new Object[] { rootNodeRef.getStoreRef() });
}
use of org.alfresco.repo.security.permissions.impl.SimplePermissionEntry in project alfresco-repository by Alfresco.
the class ACLEntryVoterTest method testMultiNodeMethodsArg0.
public void testMultiNodeMethodsArg0() throws Exception {
runAs("andy");
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("testManyNodeRef", new Class[] { NodeRef.class, NodeRef.class, NodeRef.class, NodeRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_NODE.0.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
method.invoke(proxy, new Object[] { null, null, null, null });
try {
method.invoke(proxy, new Object[] { rootNodeRef, null, null, null });
assertNotNull(null);
} catch (InvocationTargetException e) {
}
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ), "andy", AccessStatus.ALLOWED));
method.invoke(proxy, new Object[] { rootNodeRef, null, null, null });
}
use of org.alfresco.repo.security.permissions.impl.SimplePermissionEntry in project alfresco-repository by Alfresco.
the class ACLEntryVoterTest method testDenyParentAssocNode.
public void testDenyParentAssocNode() throws Exception {
runAs("andy");
permissionService.setPermission(new SimplePermissionEntry(systemNodeRef, getPermission(PermissionService.READ), "andy", AccessStatus.ALLOWED));
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("testOneChildAssociationRef", new Class[] { ChildAssociationRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_PARENT.0.sys:base.Read")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
try {
method.invoke(proxy, new Object[] { nodeService.getPrimaryParent(systemNodeRef) });
assertNotNull(null);
} catch (InvocationTargetException e) {
}
}
use of org.alfresco.repo.security.permissions.impl.SimplePermissionEntry in project alfresco-repository by Alfresco.
the class ACLEntryVoterTest method testBasicAllow.
public void testBasicAllow() throws Exception {
runAs("andy");
permissionService.setPermission(new SimplePermissionEntry(rootNodeRef, getPermission(PermissionService.READ), "andy", AccessStatus.ALLOWED));
Object o = new ClassWithMethods();
Method method = o.getClass().getMethod("testOneNodeRef", new Class[] { NodeRef.class });
AdvisorAdapterRegistry advisorAdapterRegistry = GlobalAdvisorAdapterRegistry.getInstance();
ProxyFactory proxyFactory = new ProxyFactory();
proxyFactory.addAdvisor(advisorAdapterRegistry.wrap(new Interceptor("ACL_ALLOW")));
proxyFactory.setTargetSource(new SingletonTargetSource(o));
Object proxy = proxyFactory.getProxy();
method.invoke(proxy, new Object[] { rootNodeRef });
}
use of org.alfresco.repo.security.permissions.impl.SimplePermissionEntry in project alfresco-repository by Alfresco.
the class GetSetPermissionsMethod method execute.
private NodePermissionEntry execute(Reference reference, Set<String> toAllow, Set<String> toDeny) {
NodeRef rNodeRef = reference.toNodeRef();
List<PermissionEntry> permissions = new LinkedList<>();
for (String permission : toAllow) {
PermissionReference permissionReference = PermissionReferenceImpl.getPermissionReference(userPermissions.getPermissionTypeQName(), permission);
permissions.add(new SimplePermissionEntry(rNodeRef, permissionReference, authority, AccessStatus.ALLOWED));
}
for (String permission : toDeny) {
PermissionReference permissionReference = PermissionReferenceImpl.getPermissionReference(userPermissions.getPermissionTypeQName(), permission);
permissions.add(new SimplePermissionEntry(rNodeRef, permissionReference, authority, AccessStatus.DENIED));
}
return new SimpleNodePermissionEntry(rNodeRef, false, permissions);
}
Aggregations