use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.
the class MolgenisAccessDecisionVoter method vote.
@Override
public int vote(Authentication authentication, FilterInvocation filterInvocation, Collection<ConfigAttribute> attributes) {
String requestUrl = filterInvocation.getRequestUrl();
Matcher pluginMatcher = PATTERN_PLUGINID.matcher(requestUrl);
if (pluginMatcher.matches()) {
String pluginId = pluginMatcher.group(1);
return getMolgenisPermissionService().hasPermission(new PluginIdentity(pluginId), PluginPermission.READ) ? ACCESS_GRANTED : ACCESS_DENIED;
}
Matcher menuMatcher = PATTERN_MENUID.matcher(requestUrl);
if (menuMatcher.matches()) {
String menuId = menuMatcher.group(1);
UiMenu menu = getMolgenisUi().getMenu(menuId);
return menu != null ? ACCESS_GRANTED : ACCESS_DENIED;
}
return ACCESS_DENIED;
}
use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.
the class WebAppPermissionRegistry method getPermissions.
@Override
public Multimap<ObjectIdentity, Pair<Permission, Sid>> getPermissions() {
User anonymousUser = dataService.query(USER, User.class).eq(USERNAME, ANONYMOUS_USERNAME).findOne();
Group allUsersGroup = dataService.query(GROUP, Group.class).eq(NAME, ALL_USER_GROUP).findOne();
ObjectIdentity pluginIdentity = new PluginIdentity(HomeController.ID);
return new ImmutableMultimap.Builder<ObjectIdentity, Pair<Permission, Sid>>().putAll(pluginIdentity, new Pair<>(PluginPermission.READ, createSid(anonymousUser)), new Pair<>(PluginPermission.READ, createSid(allUsersGroup))).build();
}
use of org.molgenis.data.plugin.model.PluginIdentity in project molgenis by molgenis.
the class NegotiatorControllerTest method testShowButtonNoPermissionsOnPlugin.
@Test
public void testShowButtonNoPermissionsOnPlugin() {
when(permissionService.hasPermission(new PluginIdentity("directory"), PluginPermission.READ)).thenReturn(false);
assertFalse(negotiatorController.showDirectoryButton("molgenis_id_1"));
}
Aggregations