WidgetConfig widgetConfig = (WidgetConfig) request.getAttribute(WidgetConfig.KEY) ;
if(widgetConfig!=null) {
Project project = (Project) request.getAttribute(PROJECT_KEY);
User user = (User) request.getAttribute(USER_KEY);
String requestPath = widgetConfig.getPath();
Permission permission = permissionMappings.get(requestPath);
if(permission!=null) {
// validate user
if(permission.userRequired() && user==null) {
return false;
}
// validate project
if(permission.projectRequired() && project==null) {
return false;
}
// validate resource
String[] resources = permission.value();
return permissionService.hasPermission(project, user, resources);
}
}
return true;
}