use of ddf.security.permission.KeyValueCollectionPermission in project ddf by codice.
the class XacmlPdpTest method testResourceIsPermitted.
@Test
public void testResourceIsPermitted() {
HashMap<String, List<String>> security = new HashMap<String, List<String>>();
security.put(RESOURCE_ACCESS, Arrays.asList(ACCESS_TYPE_A));
KeyValueCollectionPermission resourcePermissions = new KeyValueCollectionPermission(CollectionPermission.READ_ACTION, security);
RequestType request = testRealm.createXACMLRequest(USER_NAME, generateSubjectInfo(TEST_COUNTRY), resourcePermissions);
assertTrue(testRealm.isPermitted(request));
}
use of ddf.security.permission.KeyValueCollectionPermission in project ddf by codice.
the class AuthzRealmTest method testBadPolicyExtension.
@Test
public void testBadPolicyExtension() {
permissionList.clear();
KeyValuePermission kvp = new KeyValuePermission("country", Arrays.asList("AUS", "CAN", "GBR"));
permissionList.add(kvp);
testRealm.addPolicyExtension(new PolicyExtension() {
@Override
public KeyValueCollectionPermission isPermittedMatchAll(CollectionPermission subjectAllCollection, KeyValueCollectionPermission matchAllCollection) {
throw new NullPointerException();
}
@Override
public KeyValueCollectionPermission isPermittedMatchOne(CollectionPermission subjectAllCollection, KeyValueCollectionPermission matchOneCollection) {
throw new NullPointerException();
}
});
boolean[] permittedArray = testRealm.isPermitted(mockSubjectPrincipal, permissionList);
for (boolean permitted : permittedArray) {
Assert.assertEquals(true, permitted);
}
}
use of ddf.security.permission.KeyValueCollectionPermission in project ddf by codice.
the class AuthzRealmTest method testIsPermitted.
@Test
public void testIsPermitted() {
permissionList.clear();
KeyValueCollectionPermission kvcp = new KeyValueCollectionPermission("action", security);
permissionList.add(kvcp);
boolean[] permittedArray = testRealm.isPermitted(mockSubjectPrincipal, permissionList);
for (boolean permitted : permittedArray) {
Assert.assertEquals(true, permitted);
}
}
use of ddf.security.permission.KeyValueCollectionPermission in project ddf by codice.
the class XacmlPdpTest method testActionGoodCountry.
@Test
public void testActionGoodCountry() {
RequestType request = testRealm.createXACMLRequest(USER_NAME, generateSubjectInfo(TEST_COUNTRY), new KeyValueCollectionPermission(QUERY_ACTION));
assertTrue(testRealm.isPermitted(request));
}
use of ddf.security.permission.KeyValueCollectionPermission in project ddf by codice.
the class XacmlPdpTest method testActionGoodSiteName.
@Test
public void testActionGoodSiteName() {
SimpleAuthorizationInfo blankUserInfo = new SimpleAuthorizationInfo(new HashSet<String>());
blankUserInfo.setObjectPermissions(new HashSet<Permission>());
RequestType request = testRealm.createXACMLRequest(USER_NAME, blankUserInfo, new KeyValueCollectionPermission(SITE_NAME_ACTION));
assertTrue(testRealm.isPermitted(request));
}
Aggregations