Hi Christian,


Thanks so much for you response. I looked at your example and understood basic 
authentication, but I don't know to how to use it with openLayers. Can you 
please give me an example or guidelines? 


I use openLayers to do WMS request as below. How to use basic authentication 
for this?


.....

// setup tiled layer

tiled = new OpenLayers.Layer.WMS(

"Geoserver layers - Tiled", "http://localhost:8080/geoserver/nc/wms";,

{

LAYERS: 'NC_Map',

STYLES: '',

format: format,

tiled: true,

tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom

},

{

buffer: 0,

displayOutsideMaxExtent: true,

isBaseLayer: true,

yx : {'EPSG:4326' : true}

} 

);


// setup single tiled layer

untiled = new OpenLayers.Layer.WMS(

"Geoserver layers - Untiled", "http://localhost:8080/geoserver/nc/wms";,

{

LAYERS: 'NC_Map',

STYLES: '',

format: format

},

{

singleTile: true, 

ratio: 1, 

isBaseLayer: true,

yx : {'EPSG:4326' : true}

} 

);


map.addLayers([untiled, tiled]);




________________________________
 From: "christian.muel...@nvoe.at" <christian.muel...@nvoe.at>
To: Meichun Li <pcloudy2...@yahoo.com> 
Cc: "geoserver-users@lists.sourceforge.net" 
<geoserver-users@lists.sourceforge.net> 
Sent: Wednesday, January 16, 2013 1:01 AM
Subject: Re: [Geoserver-users] How to access secured WMS in web application
 
To avoid the popup (challenge) you have to send the Http Header

Authorization

which each request.

Look here for an example

http://www.avajava.com/tutorials/lessons/how-do-i-connect-to-a-url-using-basic-authentication.html

Christian

Zitat von Meichun Li <pcloudy2...@yahoo.com>:

> Hi,
>  
> My web application uses Struts Framework, and the enviroments are  JDK 
> 6,Tomcat 6, GeoServer 2.2.2.
>  
> I configured GeoServer to secure WMS, a basic authencitation window  pops up 
> for WMS request. For example, user name and password
> are required to input to access
> http://localhost:8080/geoserver/topp/wms?service=WMS&version=1.1.0&request=GetMap&layers=topp:states&styles=&bbox=-124.73142200000001,24.955967,-66.969849,49.371735&width=780&height=330&srs=EPSG:4326&format=application/openlayers
> In my web application, I don't want to pass username and password in  the URL 
> string, instead, I want to access the secured WMS without  authentication 
> window.
> I used ol4jsf proxy but it doesn't work, the autentication window  still pops 
> up.
>  
> Please see below for my set up. Is there something wrong?
>  
> In my JSP page, I do the WMS request such as these:
> untiled = new OpenLayers.Layer.WMS(
>                     "topp:states - Untiled", 
> "http://localhost:8080/geoserver/topp/wms";,
>                     {
>                         LAYERS: 'topp:states',
>                         STYLES: '',
>                         format: format
>                     },
>                     {
>                        singleTile: true,
>                        ratio: 1,
>                        isBaseLayer: true,
>                        yx : {'EPSG:4326' : true}
>                     }
>   );
>  
> I put ol4jsf-core-2.5.0.jar in my application WEB-INF/lib floder and  create 
> ol4jsf-proxy.xml in WEB-INF/classes:
>  
> <?xml version="1.0" encoding="UTF-8"?>
> <ol4jsf-proxy>
>     <use-environment id="desenv" />
>     <environment id="desenv">
>         <description>Development Environment.</description>
>         <resources>
>             <resource name="wms">
>                 <url>http://http:localhost:8080/geoserver/wms</url>
>                 <authentication>
>                             <username>admin</username>
>                              <password>geoserver</password>
>                  </authentication>
>             </resource>
>         </resources>
>     </environment>
> </ol4jsf-proxy>
> 
> In my web application web.xml page, I added these:
>  
> <!-- Proxy for GeoServer WMS-->
>  
> <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>
>  
> Any suggestions are highly appreciated.
> Thanks!
> Maggie
> 



----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122712
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to