changeset 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 3dfe7bbab70f
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Authenticator.java flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Response.java flys-client/src/main/java/de/intevation/flys/client/server/auth/was/User.java
diffstat 4 files changed, 37 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Aug 10 07:06:18 2012 +0000
+++ b/flys-client/ChangeLog	Fri Aug 10 08:17:52 2012 +0000
@@ -1,3 +1,9 @@
+2012-08-08	Björn Ricks <bjoern.ricks@intevation.de>
+	* src/main/java/de/intevation/flys/client/server/auth/was/Authenticator.java,
+	  src/main/java/de/intevation/flys/client/server/auth/was/Response.java,
+	  src/main/java/de/intevation/flys/client/server/auth/was/User.java:
+	  Implement Features handling for WAS authentication.
+
 2012-08-08	Björn Ricks <bjoern.ricks@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/LoginServlet.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Authenticator.java	Fri Aug 10 07:06:18 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Authenticator.java	Fri Aug 10 08:17:52 2012 +0000
@@ -15,17 +15,26 @@
 import de.intevation.flys.client.server.auth.AuthenticationException;
 import de.intevation.flys.client.server.features.Features;
 
-public class Authenticator implements de.intevation.flys.client.server.auth.Authenticator {
+public class Authenticator
+implements de.intevation.flys.client.server.auth.Authenticator {
 
     @Override
-    public Authentication auth(String username, String password, String encoding, Features faetures)
-        throws AuthenticationException, IOException {
+    public Authentication auth(
+        String username,
+        String password,
+        String encoding,
+        Features features
+    ) throws
+        AuthenticationException,
+        IOException
+    {
             try {
                 SSLSocketFactory sf = new SSLSocketFactory(
                         new GGInATrustStrategy());
                 Scheme https = new Scheme("https", 443, sf);
                 HttpClient httpclient = new DefaultHttpClient();
-                httpclient.getConnectionManager().getSchemeRegistry().register(https);
+                httpclient.getConnectionManager().getSchemeRegistry().register(
+                        https);
 
                 Request httpget = new Request("https://geoportal.bafg.de/" +
                         "administration/WAS", username, password, encoding);
@@ -36,7 +45,7 @@
                     return null;
                 }
                 else {
-                    return new Response(entity, username, password);
+                    return new Response(entity, username, password, features);
                 }
             }
             catch(GeneralSecurityException e) {
--- a/flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Response.java	Fri Aug 10 07:06:18 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/auth/was/Response.java	Fri Aug 10 08:17:52 2012 +0000
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.List;
 
 import org.apache.commons.codec.binary.Base64InputStream;
 
@@ -17,6 +18,8 @@
 import de.intevation.flys.client.server.auth.Authentication;
 import de.intevation.flys.client.server.auth.AuthenticationException;
 
+import de.intevation.flys.client.server.features.Features;
+
 public class Response implements Authentication {
 
     private static Logger logger = Logger.getLogger(Response.class);
@@ -25,9 +28,10 @@
     private Assertion assertion;
     private String username;
     private String password;
+    private Features features;
 
 
-    public Response(HttpEntity entity, String username, String password) throws AuthenticationException, IOException {
+    public Response(HttpEntity entity, String username, String password, Features features) throws AuthenticationException, IOException {
 
         if (entity == null) {
             throw new ServiceException("Invalid response");
@@ -55,6 +59,7 @@
             this.root = root;
             this.username = username;
             this.password = password;
+            this.features = features;
 
         }
         catch(JDOMException e) {
@@ -102,7 +107,10 @@
         if (assertion == null) {
             throw new AuthenticationException("Response doesn't contain an assertion");
         }
-        return new User(this.username, this.password, this.assertion.getRoles(), assertion);
+        List<String> features = this.features.getFeatures(
+                this.assertion.getRoles());
+        return new User(this.username, this.password,
+                this.assertion.getRoles(), assertion, features);
     }
 }
 // vim: set si et fileencoding=utf-8 ts=4 sw=4 tw=80:
--- a/flys-client/src/main/java/de/intevation/flys/client/server/auth/was/User.java	Fri Aug 10 07:06:18 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/auth/was/User.java	Fri Aug 10 08:17:52 2012 +0000
@@ -11,11 +11,17 @@
 
     private Assertion assertion;
 
-    public User(String name, String password, List<String> roles, Assertion assertion) {
+    public User(String name,
+        String       password,
+        List<String> roles,
+        Assertion    assertion,
+        List<String> features
+    ) {
         this.setName(name);
         this.setPassword(password);
         this.setRoles(roles);
         this.assertion = assertion;
+        this.setAllowedFeatures(features);
     }
 
     @Override

http://dive4elements.wald.intevation.org