Search in sources :

Example 1 with WildcardPermission

use of org.apache.shiro.authz.permission.WildcardPermission in project airpal by airbnb.

the class UserGroup method setPermissions.

public void setPermissions(Set<String> permissions) {
    ImmutableSet.Builder<Permission> builder = ImmutableSet.builder();
    for (String permission : permissions) {
        builder.add(new WildcardPermission(permission));
    }
    this.permissions = builder.build();
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) Permission(org.apache.shiro.authz.Permission) WildcardPermission(org.apache.shiro.authz.permission.WildcardPermission) WildcardPermission(org.apache.shiro.authz.permission.WildcardPermission)

Example 2 with WildcardPermission

use of org.apache.shiro.authz.permission.WildcardPermission in project camel by apache.

the class ShiroAuthorizationTest method createRouteBuilders.

@Override
protected RouteBuilder[] createRouteBuilders() throws Exception {
    return new RouteBuilder[] { new RouteBuilder() {

        public void configure() {
            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);
            onException(CamelAuthorizationException.class).to("mock:authorizationException");
            from("direct:secureEndpoint").policy(securityPolicy).to("log:incoming payload").to("mock:success");
        }
    }, new RouteBuilder() {

        public void configure() {
            List<Permission> permissionsList = new ArrayList<Permission>();
            Permission permission = new WildcardPermission("zone1:readonly:*");
            permissionsList.add(permission);
            permission = new WildcardPermission("zone1:writeonly:*");
            permissionsList.add(permission);
            final ShiroSecurityPolicy securityPolicy = new ShiroSecurityPolicy("src/test/resources/securityconfig.ini", passPhrase, true, permissionsList);
            onException(CamelAuthorizationException.class).to("mock:authorizationException");
            from("direct:secureAnyEndpoint").policy(securityPolicy).to("log:incoming payload").to("mock:success");
        }
    }, new RouteBuilder() {

        public void configure() {
            List<Permission> permissionsList = new ArrayList<Permission>();
            Permission permission = new WildcardPermission("zone1:readonly:*");
            permissionsList.add(permission);
            permission = new WildcardPermission("zone1:writeonly:*");
            permissionsList.add(permission);
            final ShiroSecurityPolicy securityPolicy = new ShiroSecurityPolicy("src/test/resources/securityconfig.ini", passPhrase, true, permissionsList);
            securityPolicy.setAllPermissionsRequired(true);
            onException(CamelAuthorizationException.class).to("mock:authorizationException");
            from("direct:secureAllEndpoint").policy(securityPolicy).to("log:incoming payload").to("mock:success");
        }
    } };
}
Also used : CamelAuthorizationException(org.apache.camel.CamelAuthorizationException) RouteBuilder(org.apache.camel.builder.RouteBuilder) ArrayList(java.util.ArrayList) Permission(org.apache.shiro.authz.Permission) WildcardPermission(org.apache.shiro.authz.permission.WildcardPermission) WildcardPermission(org.apache.shiro.authz.permission.WildcardPermission)

Example 3 with WildcardPermission

use of org.apache.shiro.authz.permission.WildcardPermission in project geode by apache.

the class ResourcePermissionTest method testIsPermission.

@Test
public void testIsPermission() {
    context = new ResourcePermission();
    assertTrue(context instanceof WildcardPermission);
}
Also used : WildcardPermission(org.apache.shiro.authz.permission.WildcardPermission) ResourcePermission(org.apache.geode.security.ResourcePermission) UnitTest(org.apache.geode.test.junit.categories.UnitTest) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) Test(org.junit.Test)

Example 4 with WildcardPermission

use of org.apache.shiro.authz.permission.WildcardPermission in project geode by apache.

the class ResourcePermissionTest method testImples.

@Test
public void testImples() {
    WildcardPermission role = new WildcardPermission("*:read");
    role.implies(new ResourcePermission("data", "read"));
    role.implies(new ResourcePermission("cluster", "read"));
    role = new WildcardPermission("*:read:*");
    role.implies(new ResourcePermission("data", "read", "testRegion"));
    role.implies(new ResourcePermission("cluster", "read", "anotherRegion", "key1"));
    role = new WildcardPermission("data:*:testRegion");
    role.implies(new ResourcePermission("data", "read", "testRegion"));
    role.implies(new ResourcePermission("data", "write", "testRegion"));
}
Also used : WildcardPermission(org.apache.shiro.authz.permission.WildcardPermission) ResourcePermission(org.apache.geode.security.ResourcePermission) UnitTest(org.apache.geode.test.junit.categories.UnitTest) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) Test(org.junit.Test)

Example 5 with WildcardPermission

use of org.apache.shiro.authz.permission.WildcardPermission in project ddf by codice.

the class AuthzRealmTest method testIsWildcardPermitted.

@Test
public void testIsWildcardPermitted() {
    permissionList.clear();
    WildcardPermission kvp = new WildcardPermission("role:admin");
    permissionList.add(kvp);
    boolean[] permittedArray = testRealm.isPermitted(mockSubjectPrincipal, permissionList);
    for (boolean permitted : permittedArray) {
        Assert.assertEquals(true, permitted);
    }
}
Also used : WildcardPermission(org.apache.shiro.authz.permission.WildcardPermission) Test(org.junit.Test)

Aggregations

WildcardPermission (org.apache.shiro.authz.permission.WildcardPermission)8 Test (org.junit.Test)4 ResourcePermission (org.apache.geode.security.ResourcePermission)2 SecurityTest (org.apache.geode.test.junit.categories.SecurityTest)2 UnitTest (org.apache.geode.test.junit.categories.UnitTest)2 Permission (org.apache.shiro.authz.Permission)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CamelAuthorizationException (org.apache.camel.CamelAuthorizationException)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 CommandResult (org.apache.geode.management.internal.cli.result.CommandResult)1 ErrorResultData (org.apache.geode.management.internal.cli.result.ErrorResultData)1