Skip to content

Commit

Permalink
CAL-461 update to work with security architecture changes in DDF (#609)
Browse files Browse the repository at this point in the history
  • Loading branch information
stustison authored and clockard committed Aug 16, 2018
1 parent 45c5ed5 commit 739b2fa
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 22 deletions.
22 changes: 20 additions & 2 deletions catalog/nsili/catalog-nsili-source/pom.xml
Expand Up @@ -90,7 +90,7 @@
<dependency>
<groupId>org.codice.thirdparty</groupId>
<artifactId>ogc-filter-v_1_1_0-schema</artifactId>
<version>1.1.0_2</version>
<version>1.1.0_5</version>
</dependency>
<dependency>
<groupId>org.codice.ddf.spatial</groupId>
Expand Down Expand Up @@ -147,6 +147,21 @@
<artifactId>versioning-common</artifactId>
<version>${ddf.version}</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client</artifactId>
<version>1.22.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>${httpcore.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${httpclient.version}</version>
</dependency>

<!-- Test Dependencies -->
<dependency>
Expand Down Expand Up @@ -220,7 +235,10 @@
guava,
geospatial,
commons-net,
security-core-impl
security-core-impl,
google-http-client,
httpcore,
httpclient
</Embed-Dependency>
</instructions>
</configuration>
Expand Down
Expand Up @@ -94,7 +94,8 @@
import org.codice.alliance.nsili.orb.api.CorbaOrb;
import org.codice.alliance.nsili.orb.api.CorbaServiceListener;
import org.codice.alliance.nsili.transformer.DAGConverter;
import org.codice.ddf.cxf.SecureCxfClientFactory;
import org.codice.ddf.cxf.client.ClientFactoryFactory;
import org.codice.ddf.cxf.client.SecureCxfClientFactory;
import org.codice.ddf.spatial.ogc.catalog.common.AvailabilityCommand;
import org.codice.ddf.spatial.ogc.catalog.common.AvailabilityTask;
import org.omg.CORBA.Any;
Expand Down Expand Up @@ -257,6 +258,8 @@ public class NsiliSource extends MaskableImpl

private MetacardType nsiliMetacardType = null;

private ClientFactoryFactory clientFactoryFactory;

static {
try (InputStream properties =
NsiliSource.class.getResourceAsStream(DESCRIBABLE_PROPERTIES_FILE)) {
Expand All @@ -282,7 +285,8 @@ public class NsiliSource extends MaskableImpl
this.orb = orb;
}

public NsiliSource(CorbaOrb corbaOrb) {
public NsiliSource(CorbaOrb corbaOrb, ClientFactoryFactory clientFactoryFactory) {
this.clientFactoryFactory = clientFactoryFactory;
scheduler = Executors.newSingleThreadScheduledExecutor();
setCorbaOrb(corbaOrb);
}
Expand All @@ -309,7 +313,7 @@ private void createClientFactory() {
int timeoutMsec = clientTimeout * 1000;
if (StringUtils.isNotBlank(serverUsername) && StringUtils.isNotBlank(serverPassword)) {
factory =
new SecureCxfClientFactory(
clientFactoryFactory.getSecureCxfClientFactory(
iorUrl,
Nsili.class,
null,
Expand All @@ -322,7 +326,7 @@ private void createClientFactory() {
serverPassword);
} else {
factory =
new SecureCxfClientFactory(
clientFactoryFactory.getSecureCxfClientFactory(
iorUrl, Nsili.class, null, null, true, true, timeoutMsec, timeoutMsec);
}
}
Expand Down
Expand Up @@ -50,8 +50,11 @@
<reference id="nsiliCorbaOrb" interface="org.codice.alliance.nsili.orb.api.CorbaOrb"
availability="mandatory"/>

<reference id="clientFactoryFactory" interface="org.codice.ddf.cxf.client.ClientFactoryFactory" availability="mandatory"/>

<bean id="urlReader" class="ddf.catalog.resource.impl.URLResourceReader">
<argument ref="mimeTypeMapper"/>
<argument ref="clientFactoryFactory"/>
<property name="rootResourceDirectories">
<set>
<value type="java.lang.String">${ddf.home}/data/products</value>
Expand All @@ -66,8 +69,6 @@
interface="ddf.catalog.source.FederatedSource">
<cm:managed-component class="org.codice.alliance.nsili.source.NsiliSource"
init-method="init" destroy-method="destroy">
<argument ref="nsiliCorbaOrb" />

<cm:managed-properties persistent-id="" update-strategy="component-managed"
update-method="refresh"/>
<property name="id" value=""/>
Expand All @@ -89,6 +90,8 @@

<!-- Custom Metacard Type Definitions -->
<property name="nsiliMetacardType" ref="nsiliMetacardType" />
<argument ref="nsiliCorbaOrb" />
<argument ref="clientFactoryFactory"/>
</cm:managed-component>
</cm:managed-service-factory>

Expand All @@ -98,8 +101,6 @@
interface="ddf.catalog.source.ConnectedSource">
<cm:managed-component class="org.codice.alliance.nsili.source.NsiliSource"
init-method="init" destroy-method="destroy">
<argument ref="nsiliCorbaOrb" />

<cm:managed-properties persistent-id="" update-strategy="component-managed"
update-method="refresh"/>
<property name="id" value=""/>
Expand All @@ -121,6 +122,8 @@

<!-- Custom Metacard Type Definitions -->
<property name="nsiliMetacardType" ref="nsiliMetacardType" />
<argument ref="nsiliCorbaOrb" />
<argument ref="clientFactoryFactory"/>
</cm:managed-component>
</cm:managed-service-factory>
</blueprint>
Expand Up @@ -56,7 +56,7 @@
import org.codice.alliance.nsili.common.UCO.NameValue;
import org.codice.alliance.nsili.common.UCO.State;
import org.codice.alliance.nsili.common.UCO.Status;
import org.codice.ddf.cxf.SecureCxfClientFactory;
import org.codice.ddf.cxf.client.SecureCxfClientFactory;
import org.codice.ddf.spatial.ogc.catalog.common.AvailabilityTask;
import org.junit.After;
import org.junit.Before;
Expand Down
3 changes: 3 additions & 0 deletions catalog/nsili/nsili-app/src/main/resources/features.xml
Expand Up @@ -37,6 +37,9 @@
<feature name="catalog-nsili-source" version="${project.version}"
description="Alliance NSILI Source">
<feature>catalog-nsili-orb-impl</feature>
<bundle>
mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream/1.4.9_1
</bundle>
<bundle>mvn:org.codice.alliance.catalog.core/catalog-core-api/${project.version}</bundle>
<bundle>mvn:org.codice.alliance.nsili/catalog-nsili-source/${project.version}</bundle>
</feature>
Expand Down
Expand Up @@ -98,7 +98,7 @@
* org.codice.imaging.nitf:codice-imaging-nitf-render:jar:0.8.1
* org.codice.thirdparty:commons-httpclient:jar:3.1.0_1
* org.codice.thirdparty:ffmpeg:zip:bin:3.1.1_1
* org.codice.thirdparty:ogc-filter-v_1_1_0-schema:jar:1.1.0_2
* org.codice.thirdparty:ogc-filter-v_1_1_0-schema:jar:1.1.0_5
* org.codice.usng4j:usng4j-api:jar:0.1
* org.codice.usng4j:usng4j-impl:jar:0.1
* org.codice.webjars:backbone.modelbinder:jar:1.1.0
Expand Down
8 changes: 7 additions & 1 deletion distribution/sdk/sample-nsili-client/pom.xml
Expand Up @@ -119,6 +119,11 @@
<artifactId>restito</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>ddf.security.core</groupId>
<artifactId>security-core-impl</artifactId>
<version>${ddf.version}</version>
</dependency>
</dependencies>

<build>
Expand All @@ -142,7 +147,8 @@
commons-lang3,
geospatial,
jgrapht-core,
joda-time
joda-time,
security-core-impl
</Embed-Dependency>
</instructions>
</configuration>
Expand Down
Expand Up @@ -26,7 +26,11 @@
import org.codice.alliance.nsili.common.NsiliConstants;
import org.codice.alliance.nsili.common.UCO.DAG;
import org.codice.alliance.nsili.common.UID.Product;
import org.codice.ddf.cxf.client.ClientFactoryFactory;
import org.glassfish.grizzly.http.Method;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -48,8 +52,13 @@ public class Client {

public void runTests(String iorUrl, String emailAddress) throws Exception {
startHttpListener();

SampleNsiliClient sampleNsiliClient = new SampleNsiliClient(LISTEN_PORT, iorUrl, emailAddress);
Bundle bundle = FrameworkUtil.getBundle(Client.class);
ServiceReference<ClientFactoryFactory> serviceReference =
bundle.getBundleContext().getServiceReference(ClientFactoryFactory.class);
ClientFactoryFactory clientFactoryFactory =
bundle.getBundleContext().getService(serviceReference);
SampleNsiliClient sampleNsiliClient =
new SampleNsiliClient(LISTEN_PORT, iorUrl, emailAddress, clientFactoryFactory);

// StandingQueryMgr
if (SHOULD_TEST_STANDING_QUERY_MGR) {
Expand Down Expand Up @@ -122,7 +131,7 @@ private void evaluateResult(SampleNsiliClient sampleNsiliClient, DAG[] results,
}

/**
* Starts the sample nsili server from the comman line and runs tests in the runTests method. See
* Starts the sample nsili server from the command line and runs tests in the runTests method. See
* README.md.
*
* @param args in the format `mvn -Pcorba.client -Dexec.args="url=IORURL,email=EMAIL"`, where the
Expand Down
Expand Up @@ -120,6 +120,7 @@
import org.codice.alliance.nsili.common.UID.Product;
import org.codice.alliance.nsili.common.UID.ProductHelper;
import org.codice.alliance.nsili.transformer.DAGConverter;
import org.codice.ddf.cxf.client.ClientFactoryFactory;
import org.omg.CORBA.Any;
import org.omg.CORBA.IntHolder;
import org.omg.CORBA.ORB;
Expand Down Expand Up @@ -181,9 +182,14 @@ public class SampleNsiliClient {

private SubmitStandingQueryRequest standingQueryRequest = null;

public SampleNsiliClient(int listenPort, String iorUrl, String emailAddress) throws Exception {
private ClientFactoryFactory clientFactoryFactory;

public SampleNsiliClient(
int listenPort, String iorUrl, String emailAddress, ClientFactoryFactory clientFactoryFactory)
throws Exception {
this.listenPort = listenPort;
this.emailAddress = emailAddress;
this.clientFactoryFactory = clientFactoryFactory;
initOrb(iorUrl);
initPoa();
initCorbaLibrary(iorUrl);
Expand Down Expand Up @@ -972,7 +978,7 @@ private String[] getResultAttributes()
}

public String getProductIdFromDag(DAG dag) {
DAGConverter dagConverter = new DAGConverter(new URLResourceReader());
DAGConverter dagConverter = new DAGConverter(new URLResourceReader(clientFactoryFactory));
dagConverter.setNsiliMetacardType(
new MetacardTypeImpl("TestNsiliMetacardType", new ArrayList<>()));
Metacard metacard = dagConverter.convertDAG(dag, false, "");
Expand Down
1 change: 1 addition & 0 deletions distribution/sdk/sdk-app/src/main/resources/features.xml
Expand Up @@ -29,6 +29,7 @@
</feature>

<feature name="sample-nsili-client" version="${project.version}">
<feature>security-core</feature>
<feature>nsili-app</feature>

<bundle>
Expand Down
Expand Up @@ -38,6 +38,7 @@
import org.codice.alliance.nsili.common.NsiliConstants;
import org.codice.alliance.nsili.common.UCO.DAG;
import org.codice.alliance.test.itests.common.AbstractAllianceIntegrationTest;
import org.codice.ddf.cxf.client.ClientFactoryFactory;
import org.codice.ddf.test.common.annotations.AfterExam;
import org.codice.ddf.test.common.annotations.BeforeExam;
import org.glassfish.grizzly.http.Method;
Expand Down Expand Up @@ -113,11 +114,14 @@ public void stopSampleNsiliClientFeature() throws Exception {

@Test
public void testStandingQueryMgr() throws Exception {
ClientFactoryFactory clientFactoryFactory =
getServiceManager().getService(ClientFactoryFactory.class);
SampleNsiliClient sampleNsiliClient =
new SampleNsiliClient(
Integer.parseInt(RESTITO_STUB_SERVER_PORT.getPort()),
NSILI_ENDPOINT_IOR_URL.getUrl(),
null);
null,
clientFactoryFactory);

sampleNsiliClient.testStandingQueryMgr();

Expand All @@ -126,11 +130,14 @@ public void testStandingQueryMgr() throws Exception {

@Test
public void testCatalogMgrGetHitCount() throws Exception {
ClientFactoryFactory clientFactoryFactory =
getServiceManager().getService(ClientFactoryFactory.class);
SampleNsiliClient sampleNsiliClient =
new SampleNsiliClient(
Integer.parseInt(RESTITO_STUB_SERVER_PORT.getPort()),
NSILI_ENDPOINT_IOR_URL.getUrl(),
null);
null,
clientFactoryFactory);

assertThat(sampleNsiliClient.getHitCount(), is(1));

Expand All @@ -139,11 +146,14 @@ public void testCatalogMgrGetHitCount() throws Exception {

@Test
public void testSubmitQuery() throws Exception {
ClientFactoryFactory clientFactoryFactory =
getServiceManager().getService(ClientFactoryFactory.class);
SampleNsiliClient sampleNsiliClient =
new SampleNsiliClient(
Integer.parseInt(RESTITO_STUB_SERVER_PORT.getPort()),
NSILI_ENDPOINT_IOR_URL.getUrl(),
null);
null,
clientFactoryFactory);

// CatalogMgr
DAG[] results = sampleNsiliClient.submitQuery();
Expand Down Expand Up @@ -175,11 +185,14 @@ public void testSubmitQuery() throws Exception {

@Test
public void testCatalogMgrViaCallback() throws Exception {
ClientFactoryFactory clientFactoryFactory =
getServiceManager().getService(ClientFactoryFactory.class);
SampleNsiliClient sampleNsiliClient =
new SampleNsiliClient(
Integer.parseInt(RESTITO_STUB_SERVER_PORT.getPort()),
NSILI_ENDPOINT_IOR_URL.getUrl(),
null);
null,
clientFactoryFactory);

sampleNsiliClient.testCallbackCatalogMgr();

Expand Down

0 comments on commit 739b2fa

Please sign in to comment.