Search in sources :

Example 1 with Security

use of org.codice.ddf.security.impl.Security in project ddf by codice.

the class ContentDirectoryMonitorTest method createContentDirectoryMonitor.

private ContentDirectoryMonitor createContentDirectoryMonitor() {
    ContentDirectoryMonitor monitor = new ContentDirectoryMonitor(camelContext, mock(AttributeRegistry.class), 1, 1, Runnable::run, new Security());
    monitor.systemSubjectBinder = exchange -> {
    };
    monitor.setNumThreads(1);
    monitor.setReadLockIntervalMilliseconds(1000);
    return monitor;
}
Also used : AttributeRegistry(ddf.catalog.data.AttributeRegistry) Security(org.codice.ddf.security.impl.Security)

Example 2 with Security

use of org.codice.ddf.security.impl.Security in project ddf by codice.

the class ApplicationServiceImplTest method testGetInstallProfilesException.

/**
 * Tests the {@link ApplicationServiceImpl#getInstallationProfiles()} method for the case where
 * featuresService.listFeatures() throws an exception
 */
@Test
public void testGetInstallProfilesException() throws Exception {
    Set<Repository> activeRepos = new HashSet<>(Arrays.asList(mainFeatureRepo, noMainFeatureRepo1));
    FeaturesService featuresService = createMockFeaturesService(activeRepos, null, null);
    when(bundleContext.getService(mockFeatureRef)).thenReturn(featuresService);
    ApplicationService appService = new ApplicationServiceImpl(featuresService, new Security()) {

        @Override
        protected BundleContext getContext() {
            return bundleContext;
        }
    };
    doThrow(new NullPointerException()).when(featuresService).listFeatures();
    assertThat("No installation profiles should of been found, expected an empty collection", appService.getInstallationProfiles(), is(empty()));
}
Also used : Repository(org.apache.karaf.features.Repository) FeaturesService(org.apache.karaf.features.FeaturesService) Security(org.codice.ddf.security.impl.Security) HashSet(java.util.HashSet) ApplicationService(org.codice.ddf.admin.application.service.ApplicationService) Test(org.junit.Test)

Example 3 with Security

use of org.codice.ddf.security.impl.Security 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 4 with Security

use of org.codice.ddf.security.impl.Security 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 5 with Security

use of org.codice.ddf.security.impl.Security in project ddf by codice.

the class FilterPluginTest method testNoRequestSubjectNoStrategies.

@Test(expected = StopProcessingException.class)
public void testNoRequestSubjectNoStrategies() throws Exception {
    QueryResponseImpl response = new QueryResponseImpl(null);
    plugin = new FilterPlugin(new Security());
    plugin.processPostQuery(response);
    fail("Plugin should have thrown exception when no subject was sent in.");
}
Also used : QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) FilterPlugin(ddf.catalog.security.filter.plugin.FilterPlugin) Security(org.codice.ddf.security.impl.Security) Test(org.junit.Test)

Aggregations

Security (org.codice.ddf.security.impl.Security)18 Test (org.junit.Test)14 FilterPlugin (ddf.catalog.security.filter.plugin.FilterPlugin)5 PermissionsImpl (ddf.security.permission.impl.PermissionsImpl)4 SecurityLogger (ddf.security.audit.SecurityLogger)3 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)2 Subject (ddf.security.Subject)2 SubjectUtils (ddf.security.service.impl.SubjectUtils)2 Before (org.junit.Before)2 AttributeRegistry (ddf.catalog.data.AttributeRegistry)1 Metacard (ddf.catalog.data.Metacard)1 ResultImpl (ddf.catalog.data.impl.ResultImpl)1 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)1 DeleteRequest (ddf.catalog.operation.DeleteRequest)1 QueryResponse (ddf.catalog.operation.QueryResponse)1 ResourceRequest (ddf.catalog.operation.ResourceRequest)1 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)1 DeleteResponseImpl (ddf.catalog.operation.impl.DeleteResponseImpl)1 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)1 ResourceResponseImpl (ddf.catalog.operation.impl.ResourceResponseImpl)1