[OpenLayers-Users] Login into Geoserver via java
paweluz
paweluz at o2.pl
Wed Mar 31 03:37:19 EDT 2010
Hi!
I am trying to write an login into Geoserver functionality via Java. I use
GWT, Geoserver 2.0.1 and Openlayers 2.8. I have configured geoserver (by
layer.properties and users.properties) that only admin can do anything. If
you are not logged you can not read or write anything.
I used 'mode=CHALLENGE' in the layer.properties file. Did I choose wright? I
do not want the Web Browser basic authorization login functionality. I want
my functionality written in GWT.
My goal: When the user is starting the page he is asked for name and the
password. If he does not now it, he will not be able to see any (or some)
data.
My code in java looks like this:
final String urlString =
"http://localhost:8080/geoserver2_0_1/admin/login.do";
final String userName = "admin";
final String password = "geoserver";
public String setConnection() throws IOException{
URL url;
url = new URL( urlString );
HttpURLConnection con = (HttpURLConnection)
url.openConnection();
con.setRequestMethod( "POST" );
con.setDoInput( true );
byte[] encodedPassword = ( userName + ":" + password
).getBytes();
BASE64Encoder encoder = new BASE64Encoder();
con.setRequestProperty( "Authorization",
" Basic " + encoder.encode(
encodedPassword ) );
con.connect();
String result = con.getResponseMessage();
return result;
}
Maybe I got wrong url to geoserver?? Or am I doing something else wrong??
Anyone have any ideas??
I know this is more like Geoserver question but I thought that someone who
used OpenLayers and Geoserver had similar issues...
Regards,
Poul
--
View this message in context: http://n2.nabble.com/Login-into-Geoserver-via-java-tp4829436p4829436.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
More information about the Users
mailing list