Secured WMS Question

8 views
Skip to first unread message

Sven Axt

unread,
Oct 13, 2015, 12:36:28 PM10/13/15
to GeoScript
Hi All,

I would like to access a secured WMS with GeoScript Groovy to generate mbtiles. While unsecured services work fine, there is a problem with a secured one: I see no possibility to set the credentials.

WMS wms = new WMS("https://secured.org/geoserver/test/wms?service=wms&version=1.1.1&request=GetCapabilities")
def layer = new WMSLayer(wms, ["test"])
def minZoom = 9
def maxZoom = 10

Projection latLonProj = new Projection("EPSG:4326")
Projection mercatorProj = new Projection("EPSG:3857")
Bounds latLonBounds = wms.getLayer('test').latLonBounds
Bounds mercatorBounds = latLonBounds.reproject(mercatorProj)

File mbfile = new File("test.mbtiles")
MBTiles mbtiles = new MBTiles(mbfile, "TEST", "test")

TileRenderer renderer = new ImageTileRenderer(mbtiles, layer)
TileSubGridGenerator generator = new TileSubGridGenerator()
generator.generate(mbtiles, renderer, minZoom, maxZoom, mercatorBounds)
mbtiles.close()


The constructor of the WMS class throws a GetCapabilities request, which is of course answered with a "401" without credentials.
The WebMapServer in the WMS class is private, so we can not inject one with credentials.

Does somebody has any idea?

Regards
Sven

scott bortman

unread,
Oct 13, 2015, 7:53:38 PM10/13/15
to geos...@googlegroups.com
Hi Sven,

I some some ideas,  but I'll disclose that I haven't actually tried it.  ;-)

So,  looking at the source for geoscript.layer.WMS,  It is a friendly wrapper
around org.geotools.data.wms.WebMapServer.   If you look at the constructors 
listed in the javadoc,  you'll notice another constructor that isn't in the Groovy
wrapper that takes an additional parameter of type org.geotools.data.ows.HTTPClient.
I think that's where you'll need to pass in the credentials.

I betcha you can subclass GeoScript's WMS and add a constructor to pass that info in
and call the other constructor for WebMapServer.   I've found some sample code that shows
how to create a WebMapServer w/credentials via google:


(check out Example 10)

Hopefully,  that will kinda get the ball rolling,  lemme know.

Take care,
--scottie


--
--
You received this message because you are subscribed to the GeoScript mailing list.
To post to this group, send email to geos...@googlegroups.com
To unsubscribe from this group, send email to geoscript+...@googlegroups.com
Visit this group at http://groups.google.com/group/geoscript or see http://geoscript.org

---
You received this message because you are subscribed to the Google Groups "GeoScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geoscript+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jared Erickson

unread,
Oct 13, 2015, 9:33:21 PM10/13/15
to GeoScript Google Group
Thank you Scottie!  

Sven, can you test this?  If it works, we could add a constructor with user and password parameters.

Cheers,
Jared

Axt, Sven

unread,
Oct 14, 2015, 4:00:42 AM10/14/15
to geos...@googlegroups.com

Hi Jared and  Scott,

 

yes, sure. I will provide feedback.

 

Regards

Sven

 

Von: geos...@googlegroups.com [mailto:geos...@googlegroups.com] Im Auftrag von Jared Erickson
Gesendet: Mittwoch, 14. Oktober 2015 03:36
An: GeoScript Google Group
Betreff: Re: [GeoScript] Secured WMS Question

 

Thank you Scottie!  

 

Sven, can you test this?  If it works, we could add a constructor with user and password parameters.

 

Cheers,

Jared

On Tue, Oct 13, 2015 at 4:53 PM, scott bortman <scott....@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages