Пример #1
0
 @Override
 protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
   SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();
   authorizationInfo.addRole("role1");
   authorizationInfo.addRole("role2");
   authorizationInfo.addObjectPermission(new BitPermission("+user1+10"));
   authorizationInfo.addObjectPermission(new WildcardPermission("user1:*"));
   authorizationInfo.addStringPermission("+user2+10");
   authorizationInfo.addStringPermission("user2:*");
   return authorizationInfo;
 }
Пример #2
0
  /** Builds the permission list for a give user. */
  @Override
  protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
    SimpleAuthorizationInfo authz = new SimpleAuthorizationInfo();

    // Only give 'log' permission to 'user1'
    if (principals.getPrimaryPrincipal().equals("user1")) {
      authz.addObjectPermission(new DomainPermission("log"));
      authz.addStringPermission("encoder:*:config:specialKey");
    }

    if (principals.getPrimaryPrincipal().equals("user2")) {
      authz.addStringPermission("encoder:dave:config:*");
    }

    return authz;
  }