use of ddf.security.permission.impl.KeyValuePermissionImpl 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());
}
use of ddf.security.permission.impl.KeyValuePermissionImpl in project ddf by codice.
the class AdminConfigPolicyTest method testRemoveUnknownAttribute.
@Test
public void testRemoveUnknownAttribute() {
AdminConfigPolicy adminConfigPolicy = new AdminConfigPolicy();
adminConfigPolicy.setPermissions(new PermissionsImpl());
List<KeyValuePermission> matchOneServicePermissions = new ArrayList<>();
matchOneServicePermissions.add(new KeyValuePermissionImpl(AdminConfigPolicy.SERVICE_PID, Sets.newHashSet("UNKNOWN_ATTRIBUTE_NAME")));
KeyValueCollectionPermission requestedServicePermissions = new KeyValueCollectionPermissionImpl(AdminConfigPolicy.VIEW_SERVICE_ACTION, matchOneServicePermissions.stream().toArray(KeyValuePermissionImpl[]::new));
assertTrue(adminConfigPolicy.isPermittedMatchAll(getSubjectPermissions(), requestedServicePermissions, requestedServicePermissions).isEmpty());
}
use of ddf.security.permission.impl.KeyValuePermissionImpl in project ddf by codice.
the class AdminConfigPolicyTest method testValidateAllPermissions.
@Test
public void testValidateAllPermissions() {
AdminConfigPolicy adminConfigPolicy = new AdminConfigPolicy();
adminConfigPolicy.setPermissions(new PermissionsImpl());
adminConfigPolicy.setFeaturePolicies(getValidPolicyPermissions());
adminConfigPolicy.setServicePolicies(getValidPolicyPermissions());
KeyValueCollectionPermission requestedFeaturePermissions = new KeyValueCollectionPermissionImpl(AdminConfigPolicy.VIEW_FEATURE_ACTION, getMatchOnePermissions(AdminConfigPolicy.FEATURE_NAME).stream().toArray(KeyValuePermissionImpl[]::new));
KeyValueCollectionPermission requestedServicePermissions = new KeyValueCollectionPermissionImpl(AdminConfigPolicy.VIEW_SERVICE_ACTION, getMatchOnePermissions(AdminConfigPolicy.SERVICE_PID).stream().toArray(KeyValuePermissionImpl[]::new));
assertTrue(adminConfigPolicy.isPermittedMatchOne(getSubjectPermissions(), requestedFeaturePermissions, requestedFeaturePermissions).isEmpty());
assertTrue(adminConfigPolicy.isPermittedMatchOne(getSubjectPermissions(), requestedServicePermissions, requestedServicePermissions).isEmpty());
}
use of ddf.security.permission.impl.KeyValuePermissionImpl 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;
}
use of ddf.security.permission.impl.KeyValuePermissionImpl in project ddf by codice.
the class XacmlPdpTest method generateSubjectInfo.
private AuthorizationInfo generateSubjectInfo(String country) {
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
Set<Permission> permissions = new HashSet<Permission>();
Set<String> roles = new HashSet<String>();
// add roles
roles.add("users");
roles.add("admin");
// add permissions
KeyValuePermission citizenshipPermission = new KeyValuePermissionImpl(COUNTRY);
citizenshipPermission.addValue(country);
permissions.add(citizenshipPermission);
KeyValuePermission typePermission = new KeyValuePermissionImpl(SUBJECT_ACCESS);
typePermission.addValue(ACCESS_TYPE_A);
typePermission.addValue(ACCESS_TYPE_B);
KeyValuePermission nameIdentPermission = new KeyValuePermissionImpl(NAME_IDENTIFIER);
nameIdentPermission.addValue("testuser1");
KeyValuePermission givenNamePermission = new KeyValuePermissionImpl(GIVEN_NAME);
givenNamePermission.addValue("Test User");
permissions.add(typePermission);
permissions.add(nameIdentPermission);
permissions.add(givenNamePermission);
info.setRoles(roles);
info.setObjectPermissions(permissions);
return info;
}
Aggregations