Search in sources :

Example 11 with KeyValueCollectionPermissionImpl

use of ddf.security.permission.impl.KeyValueCollectionPermissionImpl 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());
}
Also used : KeyValueCollectionPermission(ddf.security.permission.KeyValueCollectionPermission) PermissionsImpl(ddf.security.permission.impl.PermissionsImpl) KeyValuePermissionImpl(ddf.security.permission.impl.KeyValuePermissionImpl) ArrayList(java.util.ArrayList) KeyValueCollectionPermissionImpl(ddf.security.permission.impl.KeyValueCollectionPermissionImpl) KeyValuePermission(ddf.security.permission.KeyValuePermission) Test(org.junit.Test)

Example 12 with KeyValueCollectionPermissionImpl

use of ddf.security.permission.impl.KeyValueCollectionPermissionImpl 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());
}
Also used : KeyValueCollectionPermission(ddf.security.permission.KeyValueCollectionPermission) PermissionsImpl(ddf.security.permission.impl.PermissionsImpl) KeyValuePermissionImpl(ddf.security.permission.impl.KeyValuePermissionImpl) KeyValueCollectionPermissionImpl(ddf.security.permission.impl.KeyValueCollectionPermissionImpl) Test(org.junit.Test)

Example 13 with KeyValueCollectionPermissionImpl

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

the class XacmlPdpTest method testSameAccessRedaction.

@Test
public void testSameAccessRedaction() throws PdpException {
    HashMap<String, List<String>> security = new HashMap<String, List<String>>();
    security.put(RESOURCE_ACCESS, Arrays.asList(ACCESS_TYPE_A, ACCESS_TYPE_B));
    KeyValueCollectionPermission resourcePermissions = new KeyValueCollectionPermissionImpl(CollectionPermission.READ_ACTION, security);
    RequestType request = testRealm.createXACMLRequest(USER_NAME, generateSubjectInfo(TEST_COUNTRY), resourcePermissions);
    assertThat(testRealm.isPermitted(request), equalTo(true));
}
Also used : KeyValueCollectionPermission(ddf.security.permission.KeyValueCollectionPermission) HashMap(java.util.HashMap) KeyValueCollectionPermissionImpl(ddf.security.permission.impl.KeyValueCollectionPermissionImpl) ArrayList(java.util.ArrayList) List(java.util.List) RequestType(oasis.names.tc.xacml._3_0.core.schema.wd_17.RequestType) Test(org.junit.Test)

Example 14 with KeyValueCollectionPermissionImpl

use of ddf.security.permission.impl.KeyValueCollectionPermissionImpl 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 KeyValueCollectionPermissionImpl(CollectionPermission.READ_ACTION, security);
    RequestType request = testRealm.createXACMLRequest(USER_NAME, generateSubjectInfo(TEST_COUNTRY), resourcePermissions);
    assertThat(testRealm.isPermitted(request), equalTo(true));
}
Also used : KeyValueCollectionPermission(ddf.security.permission.KeyValueCollectionPermission) HashMap(java.util.HashMap) KeyValueCollectionPermissionImpl(ddf.security.permission.impl.KeyValueCollectionPermissionImpl) ArrayList(java.util.ArrayList) List(java.util.List) RequestType(oasis.names.tc.xacml._3_0.core.schema.wd_17.RequestType) Test(org.junit.Test)

Example 15 with KeyValueCollectionPermissionImpl

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

the class XacmlPdpTest method testActionGoodCountry.

@Test
public void testActionGoodCountry() {
    RequestType request = testRealm.createXACMLRequest(USER_NAME, generateSubjectInfo(TEST_COUNTRY), new KeyValueCollectionPermissionImpl(QUERY_ACTION));
    assertThat(testRealm.isPermitted(request), equalTo(true));
}
Also used : KeyValueCollectionPermissionImpl(ddf.security.permission.impl.KeyValueCollectionPermissionImpl) RequestType(oasis.names.tc.xacml._3_0.core.schema.wd_17.RequestType) Test(org.junit.Test)

Aggregations

KeyValueCollectionPermissionImpl (ddf.security.permission.impl.KeyValueCollectionPermissionImpl)22 KeyValueCollectionPermission (ddf.security.permission.KeyValueCollectionPermission)16 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 RequestType (oasis.names.tc.xacml._3_0.core.schema.wd_17.RequestType)8 KeyValuePermission (ddf.security.permission.KeyValuePermission)7 List (java.util.List)7 KeyValuePermissionImpl (ddf.security.permission.impl.KeyValuePermissionImpl)6 HashMap (java.util.HashMap)5 CollectionPermission (ddf.security.permission.CollectionPermission)4 Permission (org.apache.shiro.authz.Permission)4 PermissionsImpl (ddf.security.permission.impl.PermissionsImpl)3 PdpException (ddf.security.pdp.realm.xacml.processor.PdpException)2 PolicyExtension (ddf.security.policy.extension.PolicyExtension)2 AuthenticationException (org.apache.shiro.authc.AuthenticationException)2 Subject (ddf.security.Subject)1 SecurityAssertion (ddf.security.assertion.SecurityAssertion)1 Expansion (ddf.security.expansion.Expansion)1 CollectionPermissionImpl (ddf.security.permission.impl.CollectionPermissionImpl)1 MatchOneCollectionPermission (ddf.security.permission.impl.MatchOneCollectionPermission)1