Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Authenticator.java @ 3486:23095983c249
Implement Features handling for WAS authentication
flys-client/trunk@5184 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Bjoern Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 10 Aug 2012 08:17:52 +0000 |
parents | 71ba3cf3ec5e |
children | 5041105d2edd |
comparison
equal
deleted
inserted
replaced
3485:71ba3cf3ec5e | 3486:23095983c249 |
---|---|
13 import de.intevation.flys.client.server.GGInATrustStrategy; | 13 import de.intevation.flys.client.server.GGInATrustStrategy; |
14 import de.intevation.flys.client.server.auth.Authentication; | 14 import de.intevation.flys.client.server.auth.Authentication; |
15 import de.intevation.flys.client.server.auth.AuthenticationException; | 15 import de.intevation.flys.client.server.auth.AuthenticationException; |
16 import de.intevation.flys.client.server.features.Features; | 16 import de.intevation.flys.client.server.features.Features; |
17 | 17 |
18 public class Authenticator implements de.intevation.flys.client.server.auth.Authenticator { | 18 public class Authenticator |
19 implements de.intevation.flys.client.server.auth.Authenticator { | |
19 | 20 |
20 @Override | 21 @Override |
21 public Authentication auth(String username, String password, String encoding, Features faetures) | 22 public Authentication auth( |
22 throws AuthenticationException, IOException { | 23 String username, |
24 String password, | |
25 String encoding, | |
26 Features features | |
27 ) throws | |
28 AuthenticationException, | |
29 IOException | |
30 { | |
23 try { | 31 try { |
24 SSLSocketFactory sf = new SSLSocketFactory( | 32 SSLSocketFactory sf = new SSLSocketFactory( |
25 new GGInATrustStrategy()); | 33 new GGInATrustStrategy()); |
26 Scheme https = new Scheme("https", 443, sf); | 34 Scheme https = new Scheme("https", 443, sf); |
27 HttpClient httpclient = new DefaultHttpClient(); | 35 HttpClient httpclient = new DefaultHttpClient(); |
28 httpclient.getConnectionManager().getSchemeRegistry().register(https); | 36 httpclient.getConnectionManager().getSchemeRegistry().register( |
37 https); | |
29 | 38 |
30 Request httpget = new Request("https://geoportal.bafg.de/" + | 39 Request httpget = new Request("https://geoportal.bafg.de/" + |
31 "administration/WAS", username, password, encoding); | 40 "administration/WAS", username, password, encoding); |
32 HttpResponse response = httpclient.execute(httpget); | 41 HttpResponse response = httpclient.execute(httpget); |
33 HttpEntity entity = response.getEntity(); | 42 HttpEntity entity = response.getEntity(); |
34 if (entity == null) { | 43 if (entity == null) { |
35 //FIXME throw AuthenticationException | 44 //FIXME throw AuthenticationException |
36 return null; | 45 return null; |
37 } | 46 } |
38 else { | 47 else { |
39 return new Response(entity, username, password); | 48 return new Response(entity, username, password, features); |
40 } | 49 } |
41 } | 50 } |
42 catch(GeneralSecurityException e) { | 51 catch(GeneralSecurityException e) { |
43 throw new AuthenticationException(e); | 52 throw new AuthenticationException(e); |
44 } | 53 } |