Search in sources :

Example 6 with CollectionPermissionImpl

use of ddf.security.permission.impl.CollectionPermissionImpl in project ddf by codice.

the class CollectionPermissionTest method testModifyPermissionList.

/**
 * Tests that the permission list that comes back cannot be modified.
 */
@Test(expected = UnsupportedOperationException.class)
public void testModifyPermissionList() {
    ArrayList<KeyValuePermission> permissionList = new ArrayList<KeyValuePermission>();
    permissionList.add(new KeyValuePermissionImpl("key1", Arrays.asList("val1")));
    permissionList.add(new KeyValuePermissionImpl("key2", Arrays.asList("val2")));
    CollectionPermission collection = new CollectionPermissionImpl("", permissionList);
    collection.getPermissionList().clear();
    fail("Returned list should not be able to modify.");
}
Also used : KeyValuePermissionImpl(ddf.security.permission.impl.KeyValuePermissionImpl) ArrayList(java.util.ArrayList) CollectionPermissionImpl(ddf.security.permission.impl.CollectionPermissionImpl) Test(org.junit.Test)

Example 7 with CollectionPermissionImpl

use of ddf.security.permission.impl.CollectionPermissionImpl in project ddf by codice.

the class CollectionPermissionTest method testGetPermissionList.

/**
 * Tests that the permission list which comes back is the same as what was put in.
 */
@Test
public void testGetPermissionList() {
    ArrayList<KeyValuePermission> permissionList = new ArrayList<KeyValuePermission>();
    permissionList.add(new KeyValuePermissionImpl("key1", Arrays.asList("val1")));
    permissionList.add(new KeyValuePermissionImpl("key2", Arrays.asList("val2")));
    CollectionPermission collection = new CollectionPermissionImpl("", permissionList);
    assertEquals(permissionList, collection.getPermissionList());
}
Also used : KeyValuePermissionImpl(ddf.security.permission.impl.KeyValuePermissionImpl) ArrayList(java.util.ArrayList) CollectionPermissionImpl(ddf.security.permission.impl.CollectionPermissionImpl) Test(org.junit.Test)

Example 8 with CollectionPermissionImpl

use of ddf.security.permission.impl.CollectionPermissionImpl in project ddf by codice.

the class AuthorizationFilterTest method getMockContextPolicy.

private ContextPolicy getMockContextPolicy() {
    ContextPolicy contextPolicy = mock(ContextPolicy.class);
    when(contextPolicy.getAuthenticationMethods()).thenReturn(Collections.singletonList("BASIC"));
    when(contextPolicy.getAllowedAttributePermissions()).thenReturn(new CollectionPermissionImpl(PATH, new KeyValuePermissionImpl(PATH, Collections.singleton("permission"))));
    when(contextPolicy.getContextPath()).thenReturn(PATH);
    return contextPolicy;
}
Also used : KeyValuePermissionImpl(ddf.security.permission.impl.KeyValuePermissionImpl) CollectionPermissionImpl(ddf.security.permission.impl.CollectionPermissionImpl) ContextPolicy(org.codice.ddf.security.policy.context.ContextPolicy)

Aggregations

CollectionPermissionImpl (ddf.security.permission.impl.CollectionPermissionImpl)8 KeyValuePermissionImpl (ddf.security.permission.impl.KeyValuePermissionImpl)8 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)6 CollectionPermission (ddf.security.permission.CollectionPermission)1 KeyValueCollectionPermission (ddf.security.permission.KeyValueCollectionPermission)1 KeyValuePermission (ddf.security.permission.KeyValuePermission)1 KeyValueCollectionPermissionImpl (ddf.security.permission.impl.KeyValueCollectionPermissionImpl)1 MatchOneCollectionPermission (ddf.security.permission.impl.MatchOneCollectionPermission)1 Permission (org.apache.shiro.authz.Permission)1 ContextPolicy (org.codice.ddf.security.policy.context.ContextPolicy)1