Search in sources :

Example 41 with Permission

use of org.apache.shiro.authz.Permission in project graylog2-server by Graylog2.

the class RootAccountRealm method addRootAccount.

private void addRootAccount(String username, String password) {
    LOG.debug("Adding root account named {}, having all permissions", username);
    add(new SimpleAccount(username, password, getName(), CollectionUtils.asSet("root"), CollectionUtils.<Permission>asSet(new AllPermission())));
}
Also used : SimpleAccount(org.apache.shiro.authc.SimpleAccount) Permission(org.apache.shiro.authz.Permission) AllPermission(org.apache.shiro.authz.permission.AllPermission) AllPermission(org.apache.shiro.authz.permission.AllPermission)

Example 42 with Permission

use of org.apache.shiro.authz.Permission in project graylog2-server by Graylog2.

the class UserServiceImpl method getPermissionsForUser.

@Override
public List<Permission> getPermissionsForUser(User user) {
    final GRN principal = grnRegistry.ofUser(user);
    final ImmutableSet.Builder<Permission> permSet = ImmutableSet.<Permission>builder().addAll(user.getPermissions().stream().map(CaseSensitiveWildcardPermission::new).collect(Collectors.toSet())).addAll(permissionAndRoleResolver.resolvePermissionsForPrincipal(principal)).addAll(getUserPermissionsFromRoles(user).stream().map(CaseSensitiveWildcardPermission::new).collect(Collectors.toSet()));
    return permSet.build().asList();
}
Also used : GRN(org.graylog.grn.GRN) ImmutableSet(com.google.common.collect.ImmutableSet) WildcardPermission(org.apache.shiro.authz.permission.WildcardPermission) GRNPermission(org.graylog.security.permissions.GRNPermission) Permission(org.apache.shiro.authz.Permission) CaseSensitiveWildcardPermission(org.graylog.security.permissions.CaseSensitiveWildcardPermission) CaseSensitiveWildcardPermission(org.graylog.security.permissions.CaseSensitiveWildcardPermission)

Aggregations

Permission (org.apache.shiro.authz.Permission)42 CollectionPermission (ddf.security.permission.CollectionPermission)22 KeyValueCollectionPermission (ddf.security.permission.KeyValueCollectionPermission)21 KeyValuePermission (ddf.security.permission.KeyValuePermission)20 Test (org.junit.Test)15 SimpleAuthorizationInfo (org.apache.shiro.authz.SimpleAuthorizationInfo)8 WildcardPermission (org.apache.shiro.authz.permission.WildcardPermission)8 ArrayList (java.util.ArrayList)7 KeyValuePermissionImpl (ddf.security.permission.impl.KeyValuePermissionImpl)6 PrincipalCollection (org.apache.shiro.subject.PrincipalCollection)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 KeyValueCollectionPermissionImpl (ddf.security.permission.impl.KeyValueCollectionPermissionImpl)4 MatchOneCollectionPermission (ddf.security.permission.impl.MatchOneCollectionPermission)4 AuthorizationException (org.apache.shiro.authz.AuthorizationException)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 List (java.util.List)3 RolePermissionResolver (org.apache.shiro.authz.permission.RolePermissionResolver)3 GRN (org.graylog.grn.GRN)3 CaseSensitiveWildcardPermission (org.graylog.security.permissions.CaseSensitiveWildcardPermission)3