Search in sources :

Example 16 with PluginIdentity

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;
}
Also used : Matcher(java.util.regex.Matcher) PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) UiMenu(org.molgenis.web.UiMenu)

Example 17 with PluginIdentity

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();
}
Also used : Group(org.molgenis.data.security.auth.Group) User(org.molgenis.data.security.auth.User) ObjectIdentity(org.springframework.security.acls.model.ObjectIdentity) PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) Permission(org.springframework.security.acls.model.Permission) PluginPermission(org.molgenis.data.plugin.model.PluginPermission) Sid(org.springframework.security.acls.model.Sid) SidUtils.createSid(org.molgenis.security.acl.SidUtils.createSid) Pair(org.molgenis.util.Pair)

Example 18 with PluginIdentity

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"));
}
Also used : PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) Test(org.testng.annotations.Test)

Aggregations

PluginIdentity (org.molgenis.data.plugin.model.PluginIdentity)18 Test (org.testng.annotations.Test)13 Group (org.molgenis.data.security.auth.Group)4 Pair (org.molgenis.util.Pair)3 ObjectIdentity (org.springframework.security.acls.model.ObjectIdentity)3 EntityType (org.molgenis.data.meta.model.EntityType)2 PluginPermission (org.molgenis.data.plugin.model.PluginPermission)2 EntityTypeIdentity (org.molgenis.data.security.EntityTypeIdentity)2 User (org.molgenis.data.security.auth.User)2 SidUtils.createSid (org.molgenis.security.acl.SidUtils.createSid)2 UiMenu (org.molgenis.web.UiMenu)2 GrantedAuthoritySid (org.springframework.security.acls.domain.GrantedAuthoritySid)2 Permission (org.springframework.security.acls.model.Permission)2 Sid (org.springframework.security.acls.model.Sid)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1 Matcher (java.util.regex.Matcher)1 Package (org.molgenis.data.meta.model.Package)1 Plugin (org.molgenis.data.plugin.model.Plugin)1 EntityTypePermission (org.molgenis.data.security.EntityTypePermission)1