Package org.apache.shiro.authz.permission

Examples of org.apache.shiro.authz.permission.WildcardPermission


        failureEndpoint.assertIsSatisfied();
    }
   
    protected RouteBuilder createRouteBuilder() throws Exception {
        List<Permission> permissionsList = new ArrayList<Permission>();
        Permission permission = new WildcardPermission("zone1:readwrite:*");
        permissionsList.add(permission);
       
        final ShiroSecurityPolicy securityPolicy = new ShiroSecurityPolicy("./src/test/resources/securityconfig.ini", passPhrase, true, permissionsList);
       
        return new RouteBuilder() {
View Full Code Here


  private List<Permission> buildPermissions(String commaSeperatedList) {
    String[] privs = commaSeperatedList.split(",");
    List<Permission> permissions = new ArrayList<Permission>();

    for (int ii = 0; ii < privs.length; ii++) {
      permissions.add(new WildcardPermission(privs[ii].trim()));
    }
    return permissions;
  }
View Full Code Here

    List<Permission> permissionList = Lists.newArrayList();
    List<String> permissionNameList = Lists.newArrayList();

    for (String privilegeKey : privilegeMap.keySet()) {
      permissionList.add(new WildcardPermission(privilegeKey + ":read"));
      permissionList.add(new WildcardPermission(privilegeKey + ":create"));
      permissionList.add(new WildcardPermission(privilegeKey + ":update"));
      permissionList.add(new WildcardPermission(privilegeKey + ":delete"));
      permissionNameList.add(privilegeKey + ":read");
      permissionNameList.add(privilegeKey + ":create");
      permissionNameList.add(privilegeKey + ":update");
      permissionNameList.add(privilegeKey + ":delete");
    }
View Full Code Here

  private void checkSubjectsPermissions(Subject subject, Map<String, Integer> privilegeMap) {
    List<Permission> permissionList = new ArrayList<Permission>();
    List<String> permissionNameList = new ArrayList<String>();

    for (Entry<String, Integer> priv : privilegeMap.entrySet()) {
      permissionList.add(new WildcardPermission(priv.getKey() + ":read"));
      permissionList.add(new WildcardPermission(priv.getKey() + ":create"));
      permissionList.add(new WildcardPermission(priv.getKey() + ":update"));
      permissionList.add(new WildcardPermission(priv.getKey() + ":delete"));
      permissionNameList.add(priv.getKey() + ":read");
      permissionNameList.add(priv.getKey() + ":create");
      permissionNameList.add(priv.getKey() + ":update");
      permissionNameList.add(priv.getKey() + ":delete");
    }
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

public class WildcardPermissionFactory
    implements PermissionFactory
{
  @Override
  public Permission create(final String permission) {
    return new WildcardPermission(permission) {
      private final int cachedHash = super.hashCode();

      @Override
      public int hashCode() {
        return cachedHash;
View Full Code Here

    SimplePrincipalCollection principal = new SimplePrincipalCollection("username", realm.getName());

    Assert.assertTrue(realm.hasRole(principal, "role"));

    // Verify the permission
    Assert.assertTrue(realm.isPermitted(principal, new WildcardPermission("app:config:read")));
    // Verify other method not allowed
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:config:create")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:config:update")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:config:delete")));

    // Verify other permission not allowed
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:read")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:create")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:update")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:delete")));
  }
View Full Code Here

    SimplePrincipalCollection principal = new SimplePrincipalCollection("ABcd", realm.getName());

    Assert.assertTrue(realm.hasRole(principal, "role"));

    // Verify the permission
    Assert.assertTrue(realm.isPermitted(principal, new WildcardPermission("app:config:read")));
    // Verify other method not allowed
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:config:create")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:config:update")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:config:delete")));

    // Verify other permission not allowed
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:read")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:create")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:update")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:delete")));

    principal = new SimplePrincipalCollection("abcd", realm.getName());

    Assert.assertTrue(realm.hasRole(principal, "role"));

    // Verify the permission
    Assert.assertTrue(realm.isPermitted(principal, new WildcardPermission("app:config:read")));
    // Verify other method not allowed
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:config:create")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:config:update")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:config:delete")));

    // Verify other permission not allowed
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:read")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:create")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:update")));
    Assert.assertFalse(realm.isPermitted(principal, new WildcardPermission("app:ui:delete")));
  }
View Full Code Here

            return true;
        }


        //模式匹配
        WildcardPermission p1 = new WildcardPermission(permissionResourceIdentity);
        WildcardPermission p2 = new WildcardPermission(actualResourceIdentity);

        return p1.implies(p2) || p2.implies(p1);
    }
View Full Code Here

TOP

Related Classes of org.apache.shiro.authz.permission.WildcardPermission

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.