Simplify security model.

This commit is contained in:
Paulo Gustavo Veiga
2012-06-12 11:23:47 -03:00
parent 249080cc20
commit cbdd6dd146
25 changed files with 101 additions and 166 deletions

View File

@@ -30,8 +30,6 @@ public class UpdateSecurityAdvise
extends BaseSecurityAdvice
implements MethodInterceptor {
private CollaborationRole grantedRole = CollaborationRole.EDITOR;
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
checkRole(methodInvocation);
return methodInvocation.proceed();
@@ -39,16 +37,16 @@ public class UpdateSecurityAdvise
protected boolean isAllowed(@NotNull User user, @NotNull MindMap map) {
boolean result;
if (map.getOwner() == null) {
if (map.getCreator() == null) {
// This means that the map is new and is an add operation.
result = true;
} else {
result = getMindmapService().isAllowedToView(user, map, grantedRole);
result = getMindmapService().hasPermissions(user, map, CollaborationRole.EDITOR);
}
return result;
}
protected boolean isAllowed(User user, int mapId) {
return getMindmapService().isAllowedToView(user, mapId, grantedRole);
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.EDITOR);
}
}

View File

@@ -28,7 +28,6 @@ import org.jetbrains.annotations.NotNull;
public class ViewBaseSecurityAdvise
extends BaseSecurityAdvice
implements MethodInterceptor {
private CollaborationRole grantedRole = CollaborationRole.VIEWER;
public Object invoke(@NotNull MethodInvocation methodInvocation) throws Throwable {
checkRole(methodInvocation);
@@ -36,10 +35,10 @@ public class ViewBaseSecurityAdvise
}
protected boolean isAllowed(User user, MindMap map) {
return getMindmapService().isAllowedToView(user, map, grantedRole);
return getMindmapService().hasPermissions(user, map, CollaborationRole.VIEWER);
}
protected boolean isAllowed(User user, int mapId) {
return getMindmapService().isAllowedToView(user, mapId, grantedRole);
return getMindmapService().hasPermissions(user, mapId, CollaborationRole.VIEWER);
}
}