[Lada-commits] [PATCH 02 of 10] Added method to check authorization with user infos and db object

Wald Commits scm-commit at wald.intevation.org
Thu Apr 16 15:49:17 CEST 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1429191859 -7200
# Node ID 6c2921100b7f62a6d4564dc1d2faaf63b84d0f90
# Parent  34b38ff45990224f0bd6f867a2b6b9dc2a05c79f
Added method to check authorization with user infos and db object.

diff -r 34b38ff45990 -r 6c2921100b7f src/main/java/de/intevation/lada/util/auth/Authorization.java
--- a/src/main/java/de/intevation/lada/util/auth/Authorization.java	Thu Apr 16 15:43:15 2015 +0200
+++ b/src/main/java/de/intevation/lada/util/auth/Authorization.java	Thu Apr 16 15:44:19 2015 +0200
@@ -8,5 +8,6 @@
     public <T> Response filter(Object source, Response data, Class<T> clazz);
     public <T> boolean isAuthorized(
         Object source, Object data, RequestMethod method, Class<T> clazz);
-	boolean isReadOnly(Integer probeId);
+    public boolean isAuthorized(UserInfo userInfo, Object data);
+    boolean isReadOnly(Integer probeId);
 }
diff -r 34b38ff45990 -r 6c2921100b7f src/main/java/de/intevation/lada/util/auth/DefaultAuthorization.java
--- a/src/main/java/de/intevation/lada/util/auth/DefaultAuthorization.java	Thu Apr 16 15:43:15 2015 +0200
+++ b/src/main/java/de/intevation/lada/util/auth/DefaultAuthorization.java	Thu Apr 16 15:44:19 2015 +0200
@@ -30,4 +30,9 @@
     public boolean isReadOnly(Integer probeId) {
         return false;
     }
+
+    @Override
+    public boolean isAuthorized(UserInfo userInfo, Object data) {
+        return true;
+    }
 }
diff -r 34b38ff45990 -r 6c2921100b7f src/main/java/de/intevation/lada/util/auth/OpenIdAuthorization.java
--- a/src/main/java/de/intevation/lada/util/auth/OpenIdAuthorization.java	Thu Apr 16 15:43:15 2015 +0200
+++ b/src/main/java/de/intevation/lada/util/auth/OpenIdAuthorization.java	Thu Apr 16 15:44:19 2015 +0200
@@ -378,4 +378,12 @@
         }
         return true;
     }
+
+    @Override
+    public boolean isAuthorized(UserInfo userInfo, Object data) {
+        if (data instanceof LProbe) {
+            return getAuthorization(userInfo, (LProbe)data);
+        }
+        return false;
+    }
 }


More information about the Lada-commits mailing list