changeset 800:8c336f08e76f

Addedd method to authorize a messung using the id and the status.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 19 Nov 2015 16:52:30 +0100
parents 385fab3be7f4
children d0510a89e701
files src/main/java/de/intevation/lada/util/auth/Authorization.java src/main/java/de/intevation/lada/util/auth/DefaultAuthorization.java src/main/java/de/intevation/lada/util/auth/HeaderAuthorization.java src/main/java/de/intevation/lada/util/auth/TestAuthorization.java
diffstat 4 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/util/auth/Authorization.java	Thu Nov 19 08:50:33 2015 +0100
+++ b/src/main/java/de/intevation/lada/util/auth/Authorization.java	Thu Nov 19 16:52:30 2015 +0100
@@ -20,6 +20,7 @@
     public <T> Response filter(Object source, Response data, Class<T> clazz);
     public <T> boolean isAuthorized(
         Object source, Object data, RequestMethod method, Class<T> clazz);
+    public <T> boolean isAuthorized(int id, Class<T> clazz);
     public boolean isAuthorized(UserInfo userInfo, Object data);
     boolean isReadOnly(Integer probeId);
 }
--- a/src/main/java/de/intevation/lada/util/auth/DefaultAuthorization.java	Thu Nov 19 08:50:33 2015 +0100
+++ b/src/main/java/de/intevation/lada/util/auth/DefaultAuthorization.java	Thu Nov 19 16:52:30 2015 +0100
@@ -86,4 +86,9 @@
     public boolean isAuthorized(UserInfo userInfo, Object data) {
         return true;
     }
+
+    @Override
+    public <T> boolean isAuthorized(int id, Class<T> clazz) {
+        return true;
+    }
 }
--- a/src/main/java/de/intevation/lada/util/auth/HeaderAuthorization.java	Thu Nov 19 08:50:33 2015 +0100
+++ b/src/main/java/de/intevation/lada/util/auth/HeaderAuthorization.java	Thu Nov 19 16:52:30 2015 +0100
@@ -107,6 +107,28 @@
         return data;
     }
 
+    @Override
+    public <T> boolean isAuthorized(int id, Class<T> clazz) {
+        if (clazz == LMessung.class) {
+            LMessung messung = repository.getByIdPlain(
+                LMessung.class,
+                id,
+                "land");
+            if (messung.getStatus() == null) {
+                return false;
+            }
+            LStatusProtokoll status = repository.getByIdPlain(
+                LStatusProtokoll.class,
+                messung.getStatus(),
+                "land");
+            if (status.getStatusWert() == 0) {
+                return false;
+            }
+            return true;
+        }
+        return false;
+    }
+
     /**
      * Check whether a user is authorized to operate on the given data.
      *
--- a/src/main/java/de/intevation/lada/util/auth/TestAuthorization.java	Thu Nov 19 08:50:33 2015 +0100
+++ b/src/main/java/de/intevation/lada/util/auth/TestAuthorization.java	Thu Nov 19 16:52:30 2015 +0100
@@ -58,4 +58,9 @@
         return false;
     }
 
+    @Override
+    public <T> boolean isAuthorized(int id, Class<T> clazz) {
+        return true;
+    }
+
 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)