use of ddf.security.permission.KeyValueCollectionPermission in project ddf by codice.
the class XacmlPdpTest method testActionBadCountry.
@Test
public void testActionBadCountry() {
RequestType request = testRealm.createXACMLRequest(USER_NAME, generateSubjectInfo("CAN"), new KeyValueCollectionPermission(QUERY_ACTION));
assertFalse(testRealm.isPermitted(request));
}
use of ddf.security.permission.KeyValueCollectionPermission in project ddf by codice.
the class XacmlPdpTest method testActionBadAction.
@Test
public void testActionBadAction() {
RequestType request = testRealm.createXACMLRequest(USER_NAME, generateSubjectInfo(TEST_COUNTRY), new KeyValueCollectionPermission("bad"));
assertFalse(testRealm.isPermitted(request));
}
use of ddf.security.permission.KeyValueCollectionPermission in project ddf by codice.
the class XacmlPdpTest method testEnvironmentVariables.
@Test
public void testEnvironmentVariables() {
RequestType request = testRealm.createXACMLRequest(USER_NAME, generateSubjectInfo(TEST_COUNTRY), new KeyValueCollectionPermission(QUERY_ACTION));
List<AttributesType> attributes = request.getAttributes();
AttributesType environmentAttributes = null;
for (AttributesType attribute : attributes) {
if (attribute.getCategory().equals(XACMLConstants.ENVIRONMENT_CATEGORY)) {
environmentAttributes = attribute;
}
}
assertNotNull(environmentAttributes);
assertThat(environmentAttributes.getAttribute().get(0).getAttributeId(), is("item0"));
assertThat(environmentAttributes.getAttribute().get(0).getAttributeValue().size(), is(1));
assertThat(environmentAttributes.getAttribute().get(1).getAttributeId(), is("item1"));
assertThat(environmentAttributes.getAttribute().get(1).getAttributeValue().size(), is(2));
assertThat(environmentAttributes.getAttribute().get(2).getAttributeId(), is("item2"));
assertThat(environmentAttributes.getAttribute().get(2).getAttributeValue().size(), is(3));
}
use of ddf.security.permission.KeyValueCollectionPermission in project ddf by codice.
the class XacmlPdpTest method testResourceIsNotPermitted.
@Test
public void testResourceIsNotPermitted() {
HashMap<String, List<String>> security = new HashMap<String, List<String>>();
security.put(RESOURCE_ACCESS, Arrays.asList(ACCESS_TYPE_A, ACCESS_TYPE_B, ACCESS_TYPE_C));
KeyValueCollectionPermission resourcePermissions = new KeyValueCollectionPermission(CollectionPermission.READ_ACTION, security);
RequestType request = testRealm.createXACMLRequest(USER_NAME, generateSubjectInfo(TEST_COUNTRY), resourcePermissions);
assertFalse(testRealm.isPermitted(request));
}
use of ddf.security.permission.KeyValueCollectionPermission in project ddf by codice.
the class QueryOperations method canAccessSource.
boolean canAccessSource(FederatedSource source, QueryRequest request) {
Map<String, Set<String>> securityAttributes = source.getSecurityAttributes();
if (securityAttributes.isEmpty()) {
return true;
}
Object requestSubject = request.getProperties().get(SecurityConstants.SECURITY_SUBJECT);
if (requestSubject instanceof ddf.security.Subject) {
Subject subject = (Subject) requestSubject;
KeyValueCollectionPermission kvCollection = new KeyValueCollectionPermission(CollectionPermission.READ_ACTION, securityAttributes);
return subject.isPermitted(kvCollection);
}
return false;
}
Aggregations