Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Provide basic authentication for secure SOS #73

Open
glegal opened this issue Mar 15, 2017 · 8 comments
Open

Provide basic authentication for secure SOS #73

glegal opened this issue Mar 15, 2017 · 8 comments
Assignees
Milestone

Comments

@glegal
Copy link

glegal commented Mar 15, 2017

I'm trying to use the SOS importer with a SOS server which has the transactional operation secure by basic authentication.

I'd like to add the support of this feature by adding credentials to the configuration file and use PreemptiveBasicAuthenticationHttpClient when the credentials are available.

@EHJ-52n EHJ-52n added this to the 0.5.0 milestone Apr 5, 2017
@EHJ-52n
Copy link
Member

EHJ-52n commented Apr 5, 2017

@glegal
I implemented the support for basic auth in the OX-Framework. Take a look here: 52North/OX-Framework#51.

You can configure basic auth using the following methods SOSWrapper.setBasicAuthHost(...), setBasicAuthUser(...), and setBasicAuthPassword(...).

I would recommend to store these settings in the <SosMetadata> element in the configuration as optional child elements. These could be done in the SensorObservationService constructor after creating the SOSWrapper instance.

What do you think?

@glegal
Copy link
Author

glegal commented Apr 13, 2017

@EHJ-52n
I look at what you did. i had prepared a patch for OX-framework on my side, but i will try to use your changes.
For the configuration part, i already made the settings in that part (<SosMetatada>) and call it in SensorObservationService constructor.

However, i update my forks with the latest changes and try to use it.

  • First remark : there is a small regression, i can't launch the jar without specifying the optional -d datafile anymore. It cause a NPE because of a log added recently printing the datafile before extracting it from configuration.
Exception in thread "OneTimeFeeder" java.lang.NullPointerException
	at org.n52.sos.importer.feeder.task.OneTimeFeeder.run(OneTimeFeeder.java:176)
  • Second remark : I was not able to test the basic authentication, the application crash while trying to send the first getcapabilities request :
14:59:29.550 [org.n52.sos.importer.feeder.task.OneTimeFeeder] INFO  OneTimeFeeder - Starting feeding data from file 'example-data.csv' via configuration 'example-data.csv.52n-sos-import-config.xml' to SOS instance
14:59:29.576 [org.n52.sos.importer.feeder.task.OneTimeFeeder] TRACE SensorObservationService - SensorObservationService(Configuration [file=example-data.csv.52n-sos-import-config.xml])
14:59:29.721 [org.n52.sos.importer.feeder.task.OneTimeFeeder] DEBUG SimpleHttpClient - executing POST method to 'http://localhost:8080/constellation/WS/sos/default'.
Exception in thread "org.n52.sos.importer.feeder.task.OneTimeFeeder" java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/client/methods/CloseableHttpResponse;
	at org.n52.oxf.util.web.SimpleHttpClient.executeMethod(SimpleHttpClient.java:167)
	at org.n52.oxf.util.web.SimpleHttpClient.executePost(SimpleHttpClient.java:162)
	at org.n52.oxf.util.web.SimpleHttpClient.executePost(SimpleHttpClient.java:155)
	at org.n52.oxf.sos.adapter.SOSAdapter.doOperation(SOSAdapter.java:388)
	at org.n52.oxf.sos.adapter.SOSAdapter.initService(SOSAdapter.java:250)
	at org.n52.oxf.sos.adapter.wrapper.SosWrapperFactory.doGetCapabilities(SosWrapperFactory.java:84)
	at org.n52.oxf.sos.adapter.wrapper.SosWrapperFactory.newInstance(SosWrapperFactory.java:65)
	at org.n52.sos.importer.feeder.SensorObservationService.<init>(SensorObservationService.java:230)
	at org.n52.sos.importer.feeder.task.OneTimeFeeder.run(OneTimeFeeder.java:195)

@EHJ-52n
Copy link
Member

EHJ-52n commented Apr 18, 2017

@glegal
Thank you very much for your feedback and the good and detailed explanation.

Re your first remark: I created an additional issue for the NPE thrown by the info log statement: #74

Re your second remark: Which branch did you use to build the OX-F for the importer? My changes are merged into the main develop branch (52North/OX-Framework@9a597fb).

@glegal
Copy link
Author

glegal commented Apr 18, 2017

@EHJ-52n
I work on 2 fork i made on our github.
https://github.com/Geomatys/OX-Framework
https://github.com/Geomatys/sos-importer

They are updated, and i build the develop branch on both

@EHJ-52n
Copy link
Member

EHJ-52n commented Apr 18, 2017

  • Which apache http client version is linked in your IDE? It should be httpclient-4.2.3.
  • Are you able to send the following request to your service endpoint?
    • HTTP method: POST
    • HTTP header Content-Type: application/xml
    • HTTP header Accept: application/xml
    • Body:
      <?xml version="1.0" encoding="UTF-8"?>
      <sos:GetCapabilities
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:sos="http://www.opengis.net/sos/2.0"
          xmlns:ows="http://www.opengis.net/ows/1.1"
          xmlns:swe="http://www.opengis.net/swe/2.0" service="SOS"    
          xsi:schemaLocation="http://www.opengis.net/sos/2.0
              http://schemas.opengis.net/sos/2.0/sosGetCapabilities.xsd">
          <ows:AcceptVersions>
              <ows:Version>2.0.0</ows:Version>
          </ows:AcceptVersions>
          <ows:Sections>
              <ows:Section>OperationsMetadata</ows:Section>
              <ows:Section>ServiceIdentification</ows:Section>
              <ows:Section>ServiceProvider</ows:Section>
              <ows:Section>FilterCapabilities</ows:Section>
              <ows:Section>Contents</ows:Section>
          </ows:Sections>
      </sos:GetCapabilities>
      

@glegal
Copy link
Author

glegal commented Apr 18, 2017

I guess the difference between the version in OX and importer cause the error :

java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/client/methods/CloseableHttpResponse;

  • For the request GetCapabilities, No it don't pass on my server because of the <ows:Section>FilterCapabilities</ows:Section>

we expect
<ows:Section>Filter_Capabilities</ows:Section>

you can see in the OGC example that they use the same value as our server :
http://schemas.opengis.net/sos/2.0/examples/_useCase_airbase_station_network/GetCapabilities.xml

@EHJ-52n
Copy link
Member

EHJ-52n commented Apr 18, 2017

I think, that this might solve the problem regarding the NoSuchMethodError.

Regarding the section naming in the GetCapabilities, I would like to say, that the specification (OGC#12-006) states in Table 14: Additional section names for SOS Capabilities that the section name for the filter capabilities is FilterCapabilities. I think, that the example, you mentioned above needs to be fixed by the OGC.
What do you think?

@glegal
Copy link
Author

glegal commented Apr 18, 2017

Yes the example is indeed false, the "Filter_Capabilities" value was like that in SOS 1.0.0. I'll try to fix it on my server.

@EHJ-52n EHJ-52n self-assigned this Apr 18, 2017
@EHJ-52n EHJ-52n modified the milestones: 0.5.0, 0.5.1 Jul 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants