diff flys-client/src/main/java/de/intevation/flys/client/server/auth/DefaultUser.java @ 3485:71ba3cf3ec5e

Refactor Authentication to allow to pass the Freatures to the user class The Features class can be used to receive the allowed features for the users roles. flys-client/trunk@5183 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 10 Aug 2012 07:06:18 +0000
parents e746e57c65c0
children 5f628a13ca9f
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/auth/DefaultUser.java	Thu Aug 09 08:22:04 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/auth/DefaultUser.java	Fri Aug 10 07:06:18 2012 +0000
@@ -1,6 +1,7 @@
 package de.intevation.flys.client.server.auth;
 
 import java.util.List;
+import java.util.Map;
 
 public class DefaultUser
 implements   User
@@ -9,6 +10,7 @@
     protected String  password;
     protected boolean expired;
     protected List<String> roles;
+    protected List<String> features;
 
     public DefaultUser() {
     }
@@ -17,12 +19,14 @@
         String       name,
         String       password,
         boolean      expired,
-        List<String> roles
+        List<String> roles,
+        List<String> features
     ) {
         this.name     = name;
         this.password = password;
         this.expired  = expired;
         this.roles    = roles;
+        this.features = features;
     }
 
     @Override
@@ -61,5 +65,14 @@
     public void setRoles(List<String> roles) {
         this.roles = roles;
     }
+
+    @Override
+    public boolean canUseFeature(String feature) {
+        return this.features.contains(feature);
+    }
+
+    public void setAllowedFeatures(List<String> features) {
+        this.features = features;
+    }
 }
 // vim:set ts=4 sw=4 si et fenc=utf8 tw=80:

http://dive4elements.wald.intevation.org