use of org.geosdi.geoplatform.connector.server.security.GPSecurityConnector in project geo-platform by geosdi.
the class CSWServiceDelegate method createGetRecordsRequest.
private CatalogGetRecordsRequest<GetRecordsResponseType> createGetRecordsRequest(String serverUrl) throws Exception {
GPCatalogConnectorStore serverConnector = null;
try {
URL url = new URL(serverUrl);
GPCSWConnectorBuilder builder = GPCSWConnectorBuilder.newConnector().withServerUrl(url).withProxyConfiguration(cswProxyConfiguration);
if (serverUrl.contains("snipc.protezionecivile.it")) {
GPSecurityConnector securityConnector = new BasicPreemptiveSecurityConnector(snipcProvider.getSnipcUsername(), snipcProvider.getSnipcPassword());
builder.withClientSecurity(securityConnector);
}
serverConnector = builder.build();
} catch (MalformedURLException ex) {
logger.error("### MalformedURLException: {}", ex.getMessage());
throw new IllegalParameterFault("Malformed URL");
}
CatalogGetRecordsRequest<GetRecordsResponseType> request = serverConnector.createGetRecordsRequest();
return request;
}
use of org.geosdi.geoplatform.connector.server.security.GPSecurityConnector in project geo-platform by geosdi.
the class CSWServiceDelegate method createServerConnector.
private GPCatalogConnectorStore createServerConnector(String serverUrl) throws Exception {
GPCatalogConnectorStore serverConnector;
try {
URL url = new URL(serverUrl);
GPCSWConnectorBuilder builder = GPCSWConnectorBuilder.newConnector().withServerUrl(url).withProxyConfiguration(cswProxyConfiguration);
if (serverUrl.contains("snipc.protezionecivile.it")) {
GPSecurityConnector securityConnector = new BasicPreemptiveSecurityConnector(snipcProvider.getSnipcUsername(), snipcProvider.getSnipcPassword());
builder.withClientSecurity(securityConnector);
}
serverConnector = builder.build();
} catch (MalformedURLException ex) {
logger.error("### MalformedURLException: {}", ex.getMessage());
throw new IllegalParameterFault("Malformed URL");
}
return serverConnector;
}
use of org.geosdi.geoplatform.connector.server.security.GPSecurityConnector in project geo-platform by geosdi.
the class CatalogGetRecordByIdTest method testSecureSnipc.
@Ignore("Require to add the SNIPC certificate into default keystore")
@Test
public void testSecureSnipc() throws Exception {
URL url = new URL(snipcUrl);
GPSecurityConnector securityConnector = new BasicPreemptiveSecurityConnector(snipcUsername, snipcPassword);
GPCatalogConnectorStore snipcConnector = GPCSWConnectorBuilder.newConnector().withServerUrl(url).withClientSecurity(securityConnector).build();
CatalogGetRecordByIdRequest<GetRecordByIdResponseType> request = snipcConnector.createGetRecordByIdRequest();
request.setId("PCM:901:20101021:112931");
request.setElementSetType(ElementSetType.FULL.toString());
// request.setOutputSchema(OutputSchema.CSW_V202);
GetRecordByIdResponseType response = request.getResponse();
assertEquals(true, response.isSetAbstractRecord());
assertEquals(false, response.isSetAny());
List<JAXBElement<? extends AbstractRecordType>> abstractRecord = response.getAbstractRecord();
assertEquals(1, abstractRecord.size());
logger.info("RECORD @@@@@@@@@@@@@@@@@@ {}", abstractRecord.get(0).getValue());
}
use of org.geosdi.geoplatform.connector.server.security.GPSecurityConnector in project geo-platform by geosdi.
the class CatalogGetRecordByIdTest method testSecureOutputOriginalSnipc.
/**
* <p>
* SNIPC catalogue is ambiguous so we can't know the OUTPUT SCHEMA and the
* returned Object. For ISO - 19110 the Obeject is
* {@link FCFeatureCatalogueType}. For ISO - 19139 the Object is
* {@link MDMetadataType} </p>
*/
@Ignore("Require to add the SNIPC certificate into default keystore")
@Test
public void testSecureOutputOriginalSnipc() throws Exception {
URL url = new URL(snipcUrl);
GPSecurityConnector securityConnector = new BasicPreemptiveSecurityConnector(snipcUsername, snipcPassword);
GPCatalogConnectorStore snipcConnector = GPCSWConnectorBuilder.newConnector().withServerUrl(url).withClientSecurity(securityConnector).build();
CatalogGetCapabilitiesRequest<CapabilitiesType> requestGetCap = snipcConnector.createGetCapabilitiesRequest();
logger.info("GetCapabilities SNIPC @@@@@@@@@@@@@@@@@@@@@@@@ {}\n", requestGetCap.getResponse());
CatalogGetRecordByIdRequest<GetRecordByIdResponseType> request = snipcConnector.createGetRecordByIdRequest();
request.setId("{3DEE88CB-A0DB-4794-941A-FD8119621A2F}");
request.setElementSetType(ElementSetType.FULL.toString());
request.setOutputSchema(OutputSchema.ORIGINAL);
Object o = request.getResponse();
// MDMetadataType metadata = (MDMetadataType) o;
// Assert.assertNotNull(metadata);
logger.info("FULL METADATA @@@@@@@@@@@@@@@@@@@@@@@@@@@ {}", request.getResponseAsString());
String snipcGetRecordById = "target/snipcGetRecordById.xml";
FileOutputStream fos = null;
try {
fos = new FileOutputStream(snipcGetRecordById);
request.getMarshaller().marshal(o, fos);
} finally {
if (fos != null) {
fos.close();
}
}
}
Aggregations