Search in sources :

Example 6 with BasicPreemptiveSecurityConnector

use of org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector in project geo-platform by geosdi.

the class CatalogCapabilitiesTest method testSecureGetCapabilities.

@Ignore("Require to add the SNIPC certificate into default keystore")
@Test
public void testSecureGetCapabilities() throws Exception {
    GPCatalogConnectorStore serverConnector = newConnector().withServerUrl(new URL(snipcUrl)).withClientSecurity(new BasicPreemptiveSecurityConnector(snipcUsername, snipcPassword)).build();
    CatalogGetCapabilitiesRequest<CapabilitiesType> request = serverConnector.createGetCapabilitiesRequest();
    CapabilitiesType response = request.getResponse();
    logger.info("CSW SECURE GET_CAPABILITIES VERSION @@@@@@@@@@@@@@@@@@@@@@@ {}", response.getVersion());
}
Also used : CapabilitiesType(org.geosdi.geoplatform.xml.csw.v202.CapabilitiesType) BasicPreemptiveSecurityConnector(org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector) URL(java.net.URL) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with BasicPreemptiveSecurityConnector

use of org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector 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 8 with BasicPreemptiveSecurityConnector

use of org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector 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)8 BasicPreemptiveSecurityConnector (org.geosdi.geoplatform.connector.server.security.BasicPreemptiveSecurityConnector)8 Test (org.junit.Test)6 JAXBElement (javax.xml.bind.JAXBElement)4 GPSecurityConnector (org.geosdi.geoplatform.connector.server.security.GPSecurityConnector)4 Ignore (org.junit.Ignore)4 MalformedURLException (java.net.MalformedURLException)2 QName (javax.xml.namespace.QName)2 FeatureCollection (org.geojson.FeatureCollection)2 GPCSWConnectorBuilder (org.geosdi.geoplatform.connector.GPCSWConnectorBuilder)2 GPCatalogConnectorStore (org.geosdi.geoplatform.connector.GPCatalogConnectorStore)2 GPWFSConnectorStore (org.geosdi.geoplatform.connector.GPWFSConnectorStore)2 WFSGetFeatureRequest (org.geosdi.geoplatform.connector.server.request.WFSGetFeatureRequest)2 FeatureCollectionDTO (org.geosdi.geoplatform.connector.wfs.response.FeatureCollectionDTO)2 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)2 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)2 WFSGetFeatureStaxReader (org.geosdi.geoplatform.support.wfs.feature.reader.WFSGetFeatureStaxReader)2 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)2 FileOutputStream (java.io.FileOutputStream)1 QueryDTO (org.geosdi.geoplatform.connector.wfs.response.QueryDTO)1