if your environment is java, you can use OL4JSFProxy.
WEB-INF/web.xml
...
<servlet>
<servlet-name>OL4JSFProxy</servlet-name>
<servlet-class>org.ol4jsf.proxy.servlet.OL4JSFProxy</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>OL4JSFProxy</servlet-name>
<url-pattern>/OL4JSFProxy/*</url-pattern>
</servlet-mapping>
...
WEB-INF/classes/ol4jsf-proxy
<?xml version="1.0" encoding="UTF-8"?>
<ol4jsf-proxy>
<use-environment id="desenv" />
<environment id="desenv">
<description>Development Environment.</description>
<resources>
<resource name="wfs">
<url>http://127.0.0.1:8090/geoserver/wfs</url>
<authentication>
<username>admin</username>
<password>geoserver</password>
</authentication>
</resource>
<resource name="wms">
<url>http://127.0.0.1:8090/geoserver/wms</url>
<authentication>
<username>admin</username>
<password>geoserver</password>
</authentication>
</resource>
</resources>
</environment>
</ol4jsf-proxy>
your_page.xhtml (JSF)
...
<m:wmsLayer name="Cities"
url="
http://localhost:8084/WebApplication1/OL4JSFProxy/wms"
params="{'layers': 'topp:tasmania_cities',
transparent: true, format: 'image/gif'}">
</m:wmsLayer>
...
your_page.xhtml (without JSF)
...
var ol_wms = new OpenLayers.Layer.WMS( "Cities",
"http://localhost:8084/WebApplication1/OL4JSFProxy/wms",
{'layers': 'topp:tasmania_cities', transparent: true, format: 'image/gif'}
);
...
Regards,
Robert
--
Robert Anderson Nogueira de Oliveira
_________________________
MSN: [email protected]
"Ausência de evidência não é evidência de ausência." (Carl Sagan)
On Thu, Feb 10, 2011 at 7:05 AM, Andreas Hocevar <[email protected]>wrote:
> On Feb 10, 2011, at 10:53 , jose garcia wrote:
>
> > I'm trying to load a secured WMS layer from GeoServer, but seem not
> possible to send credentials when loading the layer in the map.
> >
> > I'm trying with this code to create the layer:
> >
> > var ol_wms = new OpenLayers.Layer.WMS( "WMS.Secured",
> > "http://SERVER/geoserver/wms?", {layers: 'SEC_LAYER',
> user: 'XXXX', password: 'XXXX'} );
> >
> >
> > But I get an empty image. Seem the user/password parameters are not valid
> to manage about the authentication for these layers.
>
> Right. You need to authenticate the HTTP Basic Auth way:
>
> var ol_wms = new OpenLayers.Layer.WMS( "WMS.Secured",
> "http://XXXX:XXXX@SERVER/geoserver/wms", {LAYERS:
> 'SEC_LAYER'} );
>
> On a side note: both your method and this method publicly expose username
> and password, so you could unsecure your layer in the first place as well,
> unless you are using the authentication just to do usage tracking.
>
> Regards,
> Andreas.
>
> >
> > I didn't find many information about how getting secured GeoServer layers
> working in OpenLayers, but hope that is possible. If you can point me in the
> right direction would be very grateful.
> >
> > Regards,
> > Jose García
> > _______________________________________________
> > Users mailing list
> > [email protected]
> > http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users