use of ddf.security.permission.KeyValuePermission 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 CollectionPermission(PATH, new KeyValuePermission(PATH, Collections.singleton("permission"))));
when(contextPolicy.getContextPath()).thenReturn(PATH);
when(contextPolicy.getRealm()).thenReturn("DDF");
return contextPolicy;
}
use of ddf.security.permission.KeyValuePermission 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 KeyValuePermission(COUNTRY);
citizenshipPermission.addValue(country);
permissions.add(citizenshipPermission);
KeyValuePermission typePermission = new KeyValuePermission(SUBJECT_ACCESS);
typePermission.addValue(ACCESS_TYPE_A);
typePermission.addValue(ACCESS_TYPE_B);
KeyValuePermission nameIdentPermission = new KeyValuePermission(NAME_IDENTIFIER);
nameIdentPermission.addValue("testuser1");
KeyValuePermission givenNamePermission = new KeyValuePermission(GIVEN_NAME);
givenNamePermission.addValue("Test User");
permissions.add(typePermission);
permissions.add(nameIdentPermission);
permissions.add(givenNamePermission);
info.setRoles(roles);
info.setObjectPermissions(permissions);
return info;
}
use of ddf.security.permission.KeyValuePermission in project ddf by codice.
the class AuthzRealmTest method testIsPermittedOneSingle.
@Test
public void testIsPermittedOneSingle() {
permissionList.clear();
KeyValuePermission kvp = new KeyValuePermission("country", Arrays.asList("AUS", "CAN", "GBR"));
permissionList.add(kvp);
boolean[] permittedArray = testRealm.isPermitted(mockSubjectPrincipal, permissionList);
for (boolean permitted : permittedArray) {
Assert.assertEquals(true, permitted);
}
}
use of ddf.security.permission.KeyValuePermission 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.KeyValuePermission in project ddf by codice.
the class AuthzRealmTest method testIsKvpPermitted.
@Test
public void testIsKvpPermitted() {
permissionList.clear();
KeyValuePermission kvp = new KeyValuePermission("role", Arrays.asList("admin"));
permissionList.add(kvp);
boolean[] permittedArray = testRealm.isPermitted(mockSubjectPrincipal, permissionList);
for (boolean permitted : permittedArray) {
Assert.assertEquals(true, permitted);
}
}
Aggregations