Mercurial > lada > lada-server
changeset 604:6c2921100b7f
Added method to check authorization with user infos and db object.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 16 Apr 2015 15:44:19 +0200 |
parents | 34b38ff45990 |
children | 03864256fafa |
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/OpenIdAuthorization.java |
diffstat | 3 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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); }
--- 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; + } }
--- 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; + } }