Package org.apache.shiro.authz

Examples of org.apache.shiro.authz.SimpleAuthorizationInfo


    // only if authenticated with this realm too
    if (!principals.getRealmNames().contains(getName())) {
      return null;
    }
    // add the default role
    final SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
    authorizationInfo.addRole(kenaiRealmConfiguration.getConfiguration().getDefaultRole());
    return authorizationInfo;
  }
View Full Code Here


  }

  @Override
  protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) {

    SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(Collections.singleton("role"));

    Permission permission = new WildcardPermission("other:perm");

    info.setObjectPermissions(Collections.singleton(permission));

    return info;
  }
View Full Code Here

  }

  @Override
  protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) {

    SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(Collections.singleton("role"));

    Permission permission = new WildcardPermission("test:perm");

    info.setObjectPermissions(Collections.singleton(permission));

    return info;
  }
View Full Code Here

  protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {

    // make sure the user is jcool, (its just for testing)

    if (principals.asList().get(0).toString().equals("jcool")) {
      SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();

      info.addRole("test-role1");
      info.addRole("test-role2");

      info.addStringPermission("test:*");

      return info;

    }

View Full Code Here

    }
    catch (UserNotFoundException e) {
      return null;
    }

    return new SimpleAuthorizationInfo(roles);

  }
View Full Code Here

    {
      throw new AuthorizationException("User for principals: " + principals.getPrimaryPrincipal()
          + " not manged by XML realm.");
    }

    SimpleAuthorizationInfo info = new SimpleAuthorizationInfo(roles);

    return info;
  }
View Full Code Here

    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        Integer userId = (Integer) principals.fromRealm(getName()).iterator().next();
        user = PersonDataSource.getPerson(userId);
        if (user != null) {
            SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
            for (Role role : user.getRoles()) {
                info.addRole(role.getName());
                info.addStringPermissions(role.getPermissions());
            }
            return info;
        } else {
            return null;
        }
View Full Code Here

        String currentUserEmail = (String) pc.getPrimaryPrincipal();
        HashSet<String> userRoles = new HashSet<>();
       
        if (currentUserEmail == null) {
            FireLogger.logSevere("No authorization info available for: {0}", FireUtil.getLoggedinUserEmail());
            return new SimpleAuthorizationInfo();
        }
       
        if (!currentUserEmail.equals(FireUtil.getLoggedinUserEmail())) {
            FireLogger.logSevere("WARNING: possible masquerader. Authorizing user is {0} but logged in user is {1}",
                    currentUserEmail,
                    FireUtil.getLoggedinUserEmail());
        }
       
        FireUser currentUser = userManager.findUser(currentUserEmail);
       
        if (currentUser == null) {
            FireLogger.logSevere("FATAL: attempting to find authorization info for non-existen user: {0}", FireUtil.getLoggedinUserEmail());
            return new SimpleAuthorizationInfo();
        }
       
        userRoles.add(currentUser.getRole().toString());
        FireLogger.logInfo("Returning authorization info for user {0}, with role {1}",
                currentUser.getEmail(),
                currentUser.getRole().toString());
       
        /*
        Collection<FireUser> users = pc.byType(FireUser.class);

        if (users.isEmpty()) {
            FireLogger.logInfo("No authorization info available for: " + FireUtil.getLoggedinUserEmail());
            return new SimpleAuthorizationInfo();
        }
        for (FireUser user : users) {
            userRoles.add(user.getRole().toString());
            FireLogger.logInfo("Attempting to obtain authorization info for user email: " + user.getEmail());
        }
        */
       
        return new SimpleAuthorizationInfo(userRoles);
    }
View Full Code Here

    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
        String username = (String) principals.getPrimaryPrincipal();
        User user = userService.findByUsername(username);

        SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
        authorizationInfo.setRoles(userAuthService.findStringRoles(user));
        authorizationInfo.setStringPermissions(userAuthService.findStringPermissions(user));

        return authorizationInfo;
    }
View Full Code Here

      roleNames = ImmutableSet.of();
    } else {
      roleNames = ImmutableSet.of("foo", "goo");
    }

    return new SimpleAuthorizationInfo(roleNames);
  }
View Full Code Here

TOP

Related Classes of org.apache.shiro.authz.SimpleAuthorizationInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.