bjoern@2956: package de.intevation.flys.client.server.auth.was; bjoern@2956: bjoern@2956: import java.io.IOException; bjoern@2956: import java.security.GeneralSecurityException; bjoern@2956: bjoern@2956: import org.apache.http.HttpEntity; bjoern@2956: import org.apache.http.HttpResponse; bjoern@2956: import org.apache.http.client.HttpClient; bjoern@2956: import org.apache.http.conn.scheme.Scheme; bjoern@2956: import org.apache.http.conn.ssl.SSLSocketFactory; bjoern@2956: import org.apache.http.impl.client.DefaultHttpClient; bjoern@2956: bjoern@2956: import de.intevation.flys.client.server.GGInATrustStrategy; bjoern@2956: import de.intevation.flys.client.server.auth.Authentication; bjoern@2956: import de.intevation.flys.client.server.auth.AuthenticationException; bjoern@2956: bjoern@2956: public class Authenticator implements de.intevation.flys.client.server.auth.Authenticator { bjoern@2956: bjoern@2956: public Authentication auth(String username, String password, String encoding) bjoern@2956: throws AuthenticationException, IOException { bjoern@2956: try { bjoern@2956: SSLSocketFactory sf = new SSLSocketFactory( bjoern@2956: new GGInATrustStrategy()); bjoern@2956: Scheme https = new Scheme("https", 443, sf); bjoern@2956: HttpClient httpclient = new DefaultHttpClient(); bjoern@2956: httpclient.getConnectionManager().getSchemeRegistry().register(https); bjoern@2956: bjoern@2956: Request httpget = new Request("https://geoportal.bafg.de/" + bjoern@2956: "administration/WAS", username, password, encoding); bjoern@2956: HttpResponse response = httpclient.execute(httpget); bjoern@2956: HttpEntity entity = response.getEntity(); bjoern@2956: if (entity == null) { bjoern@2956: //FIXME throw AuthenticationException bjoern@2956: return null; bjoern@2956: } bjoern@2956: else { bjoern@2956: return new Response(entity, username, password); bjoern@2956: } bjoern@2956: } bjoern@2956: catch(GeneralSecurityException e) { bjoern@2956: throw new AuthenticationException(e); bjoern@2956: } bjoern@2956: } bjoern@2956: }