Search in sources :

Example 1 with USER

use of org.molgenis.data.security.auth.UserMetaData.USER in project molgenis by molgenis.

the class PermissionManagerController method toPluginPermissions.

private Permissions toPluginPermissions(List<Plugin> plugins, Map<ObjectIdentity, Acl> aclMap, Sid sid) {
    Permissions permissions = new Permissions();
    // set permissions: entity ids
    Map<String, String> pluginMap = plugins.stream().collect(toMap(Plugin::getId, Plugin::getId, (u, v) -> {
        throw new IllegalStateException(format("Duplicate key %s", u));
    }, LinkedHashMap::new));
    permissions.setEntityIds(pluginMap);
    // set permissions: user of group id
    boolean isUser = setUserOrGroup(sid, permissions);
    // set permissions: permissions
    aclMap.forEach((objectIdentity, acl) -> {
        String pluginId = objectIdentity.getIdentifier().toString();
        acl.getEntries().forEach(ace -> {
            if (ace.getSid().equals(sid)) {
                org.molgenis.security.permission.Permission pluginPermission = toPluginPermission(ace);
                if (isUser) {
                    permissions.addUserPermission(pluginId, pluginPermission);
                } else {
                    permissions.addGroupPermission(pluginId, pluginPermission);
                }
            }
        });
    });
    return permissions;
}
Also used : PluginController(org.molgenis.web.PluginController) java.util(java.util) EntityTypeMetadata(org.molgenis.data.meta.model.EntityTypeMetadata) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) WebRequest(org.springframework.web.context.request.WebRequest) LoggerFactory(org.slf4j.LoggerFactory) PackageMetadata(org.molgenis.data.meta.model.PackageMetadata) Controller(org.springframework.stereotype.Controller) Collections.singletonList(java.util.Collections.singletonList) Valid(javax.validation.Valid) User(org.molgenis.data.security.auth.User) Model(org.springframework.ui.Model) Lists(com.google.common.collect.Lists) ANONYMOUS_USERNAME(org.molgenis.security.core.utils.SecurityUtils.ANONYMOUS_USERNAME) Collectors.toMap(java.util.stream.Collectors.toMap) USER(org.molgenis.data.security.auth.UserMetaData.USER) PluginPermission(org.molgenis.data.plugin.model.PluginPermission) Objects.requireNonNull(java.util.Objects.requireNonNull) PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) SystemEntityTypeRegistry(org.molgenis.data.meta.system.SystemEntityTypeRegistry) org.springframework.security.acls.model(org.springframework.security.acls.model) Comparator.comparing(java.util.Comparator.comparing) URI(org.molgenis.core.ui.admin.permission.PermissionManagerController.URI) SidUtils(org.molgenis.security.acl.SidUtils) Logger(org.slf4j.Logger) USERNAME(org.molgenis.data.security.auth.UserMetaData.USERNAME) org.molgenis.data.security(org.molgenis.data.security) SidUtils.createAnonymousSid(org.molgenis.security.acl.SidUtils.createAnonymousSid) EntityType(org.molgenis.data.meta.model.EntityType) Collectors(java.util.stream.Collectors) MutableAclClassService(org.molgenis.security.acl.MutableAclClassService) String.format(java.lang.String.format) GrantedAuthoritySid(org.springframework.security.acls.domain.GrantedAuthoritySid) PrincipalSid(org.springframework.security.acls.domain.PrincipalSid) HttpStatus(org.springframework.http.HttpStatus) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) GROUP(org.molgenis.data.security.auth.GroupMetaData.GROUP) org.springframework.web.bind.annotation(org.springframework.web.bind.annotation) DataService(org.molgenis.data.DataService) Package(org.molgenis.data.meta.model.Package) Group(org.molgenis.data.security.auth.Group) PLUGIN(org.molgenis.data.plugin.model.PluginMetadata.PLUGIN) Permissions(org.molgenis.security.permission.Permissions) Plugin(org.molgenis.data.plugin.model.Plugin) Transactional(org.springframework.transaction.annotation.Transactional) Permissions(org.molgenis.security.permission.Permissions)

Aggregations

Lists (com.google.common.collect.Lists)1 String.format (java.lang.String.format)1 java.util (java.util)1 Collections.singletonList (java.util.Collections.singletonList)1 Comparator.comparing (java.util.Comparator.comparing)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Stream (java.util.stream.Stream)1 Valid (javax.validation.Valid)1 URI (org.molgenis.core.ui.admin.permission.PermissionManagerController.URI)1 DataService (org.molgenis.data.DataService)1 EntityType (org.molgenis.data.meta.model.EntityType)1 EntityTypeMetadata (org.molgenis.data.meta.model.EntityTypeMetadata)1 Package (org.molgenis.data.meta.model.Package)1 PackageMetadata (org.molgenis.data.meta.model.PackageMetadata)1 SystemEntityTypeRegistry (org.molgenis.data.meta.system.SystemEntityTypeRegistry)1 Plugin (org.molgenis.data.plugin.model.Plugin)1 PluginIdentity (org.molgenis.data.plugin.model.PluginIdentity)1