Search in sources :

Example 6 with PermissionsImpl

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

the class FilterPluginTest method testPluginFilterResourceNoStrategiesGood.

@Test
public void testPluginFilterResourceNoStrategiesGood() throws StopProcessingException {
    plugin = new FilterPlugin(new Security());
    plugin.setPermissions(new PermissionsImpl());
    plugin.processPostResource(resourceResponse, getExactRolesMetacard());
}
Also used : FilterPlugin(ddf.catalog.security.filter.plugin.FilterPlugin) PermissionsImpl(ddf.security.permission.impl.PermissionsImpl) Security(org.codice.ddf.security.impl.Security) Test(org.junit.Test)

Example 7 with PermissionsImpl

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

the class FilterPluginTest method testPluginFilterNoStrategies.

@Test
public void testPluginFilterNoStrategies() {
    plugin = new FilterPlugin(new Security());
    plugin.setPermissions(new PermissionsImpl());
    plugin.setSubjectOperations(new SubjectUtils());
    plugin.setSecurityLogger(mock(SecurityLogger.class));
    try {
        QueryResponse response = plugin.processPostQuery(incomingResponse);
        verifyFilterResponse(response);
    } catch (StopProcessingException e) {
        LOGGER.error("Stopped processing the redaction plugin", e);
    }
}
Also used : SubjectUtils(ddf.security.service.impl.SubjectUtils) FilterPlugin(ddf.catalog.security.filter.plugin.FilterPlugin) PermissionsImpl(ddf.security.permission.impl.PermissionsImpl) QueryResponse(ddf.catalog.operation.QueryResponse) StopProcessingException(ddf.catalog.plugin.StopProcessingException) Security(org.codice.ddf.security.impl.Security) SecurityLogger(ddf.security.audit.SecurityLogger) Test(org.junit.Test)

Example 8 with PermissionsImpl

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

the class ResourceUriPolicyTest method getPolicyPlugin.

private ResourceUriPolicy getPolicyPlugin() {
    ResourceUriPolicy resourceUriPolicy = new ResourceUriPolicy(new String[] { "role=admin", "fizzle=bang" }, new String[] { "role=admin", "fizzle=bang" });
    resourceUriPolicy.setPermissions(new PermissionsImpl());
    return resourceUriPolicy;
}
Also used : PermissionsImpl(ddf.security.permission.impl.PermissionsImpl)

Example 9 with PermissionsImpl

use of ddf.security.permission.impl.PermissionsImpl 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 10 with PermissionsImpl

use of ddf.security.permission.impl.PermissionsImpl 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)

Aggregations

PermissionsImpl (ddf.security.permission.impl.PermissionsImpl)17 ArrayList (java.util.ArrayList)8 Test (org.junit.Test)8 KeyValueCollectionPermission (ddf.security.permission.KeyValueCollectionPermission)7 SecurityLogger (ddf.security.audit.SecurityLogger)6 Before (org.junit.Before)5 FilterPlugin (ddf.catalog.security.filter.plugin.FilterPlugin)4 ByteSource (com.google.common.io.ByteSource)3 Metacard (ddf.catalog.data.Metacard)3 QueryOperations (ddf.catalog.impl.operations.QueryOperations)3 ResourceOperations (ddf.catalog.impl.operations.ResourceOperations)3 SourceOperations (ddf.catalog.impl.operations.SourceOperations)3 ResourceRequest (ddf.catalog.operation.ResourceRequest)3 FederatedSource (ddf.catalog.source.FederatedSource)3 Source (ddf.catalog.source.Source)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 SourceStatus (org.codice.ddf.catalog.sourcepoller.SourceStatus)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3