comparison flys-client/src/main/java/org/dive4elements/river/client/server/auth/was/Authenticator.java @ 5834:f507086aa94b

Repaired internal references.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:31:32 +0200
parents flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Authenticator.java@5041105d2edd
children 821a02bbfb4e
comparison
equal deleted inserted replaced
5833:a2bdc0f524e8 5834:f507086aa94b
1 package de.intevation.flys.client.server.auth.was;
2
3 import java.io.IOException;
4 import java.security.GeneralSecurityException;
5
6 import org.apache.http.HttpEntity;
7 import org.apache.http.HttpResponse;
8 import org.apache.http.StatusLine;
9 import org.apache.http.client.HttpClient;
10 import org.apache.http.conn.scheme.Scheme;
11 import org.apache.http.conn.ssl.SSLSocketFactory;
12 import org.apache.http.impl.client.DefaultHttpClient;
13
14 import de.intevation.flys.client.server.GGInATrustStrategy;
15 import de.intevation.flys.client.server.auth.Authentication;
16 import de.intevation.flys.client.server.auth.AuthenticationException;
17 import de.intevation.flys.client.server.features.Features;
18
19 public class Authenticator
20 implements de.intevation.flys.client.server.auth.Authenticator {
21
22 @Override
23 public Authentication auth(
24 String username,
25 String password,
26 String encoding,
27 Features features
28 ) throws
29 AuthenticationException,
30 IOException
31 {
32 try {
33 SSLSocketFactory sf = new SSLSocketFactory(
34 new GGInATrustStrategy());
35 Scheme https = new Scheme("https", 443, sf);
36 HttpClient httpclient = new DefaultHttpClient();
37 httpclient.getConnectionManager().getSchemeRegistry().register(
38 https);
39
40 Request httpget = new Request("https://geoportal.bafg.de/" +
41 "administration/WAS", username, password, encoding);
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 }
49 HttpEntity entity = response.getEntity();
50 if (entity == null) {
51 //FIXME throw AuthenticationException
52 return null;
53 }
54 else {
55 return new Response(entity, username, password, features);
56 }
57 }
58 catch(GeneralSecurityException e) {
59 throw new AuthenticationException(e);
60 }
61 }
62 }

http://dive4elements.wald.intevation.org