Search in sources :

Example 1 with GPSecurityConnector

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;
}
Also used : GPCatalogConnectorStore(org.geosdi.geoplatform.connector.GPCatalogConnectorStore) MalformedURLException(java.net.MalformedURLException) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPSecurityConnector(org.geosdi.geoplatform.connector.server.security.GPSecurityConnector) GPCSWConnectorBuilder(org.geosdi.geoplatform.connector.GPCSWConnectorBuilder) BasicPreemptiveSecurityConnector(org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector) URL(java.net.URL)

Example 2 with GPSecurityConnector

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;
}
Also used : GPCatalogConnectorStore(org.geosdi.geoplatform.connector.GPCatalogConnectorStore) MalformedURLException(java.net.MalformedURLException) IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) GPSecurityConnector(org.geosdi.geoplatform.connector.server.security.GPSecurityConnector) GPCSWConnectorBuilder(org.geosdi.geoplatform.connector.GPCSWConnectorBuilder) BasicPreemptiveSecurityConnector(org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector) URL(java.net.URL)

Example 3 with GPSecurityConnector

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());
}
Also used : GPSecurityConnector(org.geosdi.geoplatform.connector.server.security.GPSecurityConnector) BasicPreemptiveSecurityConnector(org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector) JAXBElement(javax.xml.bind.JAXBElement) URL(java.net.URL) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with GPSecurityConnector

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();
        }
    }
}
Also used : GPSecurityConnector(org.geosdi.geoplatform.connector.server.security.GPSecurityConnector) FileOutputStream(java.io.FileOutputStream) BasicPreemptiveSecurityConnector(org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector) URL(java.net.URL) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

URL (java.net.URL)4 BasicPreemptiveSecurityConnector (org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector)4 GPSecurityConnector (org.geosdi.geoplatform.connector.server.security.GPSecurityConnector)4 MalformedURLException (java.net.MalformedURLException)2 GPCSWConnectorBuilder (org.geosdi.geoplatform.connector.GPCSWConnectorBuilder)2 GPCatalogConnectorStore (org.geosdi.geoplatform.connector.GPCatalogConnectorStore)2 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 FileOutputStream (java.io.FileOutputStream)1 JAXBElement (javax.xml.bind.JAXBElement)1