Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Authenticator.java @ 4488:5041105d2edd
Check if response code from GGInA is 200 OK
Only parse the GGInA response if the status code is 200 OK. This improves the
error message if GGInA is not available and shows the real reason instead of a
JDOM error while parsing the response.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Wed, 14 Nov 2012 10:36:21 +0100 |
parents | 23095983c249 |
children |
comparison
equal
deleted
inserted
replaced
4487:a08d25476f0a | 4488:5041105d2edd |
---|---|
3 import java.io.IOException; | 3 import java.io.IOException; |
4 import java.security.GeneralSecurityException; | 4 import java.security.GeneralSecurityException; |
5 | 5 |
6 import org.apache.http.HttpEntity; | 6 import org.apache.http.HttpEntity; |
7 import org.apache.http.HttpResponse; | 7 import org.apache.http.HttpResponse; |
8 import org.apache.http.StatusLine; | |
8 import org.apache.http.client.HttpClient; | 9 import org.apache.http.client.HttpClient; |
9 import org.apache.http.conn.scheme.Scheme; | 10 import org.apache.http.conn.scheme.Scheme; |
10 import org.apache.http.conn.ssl.SSLSocketFactory; | 11 import org.apache.http.conn.ssl.SSLSocketFactory; |
11 import org.apache.http.impl.client.DefaultHttpClient; | 12 import org.apache.http.impl.client.DefaultHttpClient; |
12 | 13 |
37 https); | 38 https); |
38 | 39 |
39 Request httpget = new Request("https://geoportal.bafg.de/" + | 40 Request httpget = new Request("https://geoportal.bafg.de/" + |
40 "administration/WAS", username, password, encoding); | 41 "administration/WAS", username, password, encoding); |
41 HttpResponse response = httpclient.execute(httpget); | 42 HttpResponse response = httpclient.execute(httpget); |
43 StatusLine stline = response.getStatusLine(); | |
44 if (stline.getStatusCode() != 200) { | |
45 throw new AuthenticationException("GGInA Server Error. " + | |
46 "Statuscode: " + stline.getStatusCode() + | |
47 ". Reason: " + stline.getReasonPhrase()); | |
48 } | |
42 HttpEntity entity = response.getEntity(); | 49 HttpEntity entity = response.getEntity(); |
43 if (entity == null) { | 50 if (entity == null) { |
44 //FIXME throw AuthenticationException | 51 //FIXME throw AuthenticationException |
45 return null; | 52 return null; |
46 } | 53 } |