annotate src/main/java/de/intevation/lada/util/auth/TestAuthorization.java @ 1028:1c41c7b8f7c2 schema-update

Updated server application to new database model. THIS IS STILL WIP!!!
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 08 Jul 2016 15:32:36 +0200
parents 2fe625c91ab3
children 657f35a7467d
rev   line source
640
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8 package de.intevation.lada.util.auth;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10 import java.util.ArrayList;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import java.util.List;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12
1028
1c41c7b8f7c2 Updated server application to new database model. THIS IS STILL WIP!!!
Raimund Renkert <raimund.renkert@intevation.de>
parents: 840
diff changeset
13 import de.intevation.lada.model.stammdaten.Auth;
640
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 import de.intevation.lada.util.annotation.AuthorizationConfig;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 import de.intevation.lada.util.rest.RequestMethod;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 import de.intevation.lada.util.rest.Response;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17
720
5815920ccabc Removed the OpenId authentorization files and dependencies.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 640
diff changeset
18 @AuthorizationConfig(type=AuthorizationType.NONE)
640
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 public class TestAuthorization implements Authorization {
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 @Override
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 public UserInfo getInfo(Object source) {
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 UserInfo info = new UserInfo();
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 info.setName("testeins");
838
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
25 List<Auth> auth = new ArrayList<Auth>();
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
26 Auth a1 = new Auth();
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
27 a1.setFunktionId(0);
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
28 a1.setLdapGroup("mst_06010");
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
29 a1.setMstId("06010");
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
30 a1.setNetzbetreiberId("06");
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
31 auth.add(a1);
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
32 Auth a2 = new Auth();
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
33 a2.setFunktionId(0);
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
34 a2.setLdapGroup("mst_11010");
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
35 a2.setNetzbetreiberId("11");
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
36 a2.setMstId("11010");
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
37 auth.add(a2);
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
38 Auth a3 = new Auth();
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
39 a3.setLdapGroup("Imis_world");
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
40 a3.setFunktionId(0);
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
41 auth.add(a3);
640
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 List<String> roles = new ArrayList<String>();
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 roles.add("mst_06010");
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 roles.add("mst_11010");
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 roles.add("ImisWorld");
838
1ed347eb856b Use auth objects in user info to keep mst <-> function association.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
46 info.setAuth(auth);
640
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 return info;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 }
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 @Override
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 public <T> Response filter(Object source, Response data, Class<T> clazz) {
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 return data;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 }
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 @Override
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 public <T> boolean isAuthorized(Object source, Object data,
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 RequestMethod method, Class<T> clazz) {
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 return true;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 }
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 @Override
833
fa922101a462 Refactored Authorization.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 800
diff changeset
62 public <T> boolean isAuthorized(UserInfo userInfo, Object data, Class<T> clazz) {
640
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 return true;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 }
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 @Override
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 public boolean isReadOnly(Integer probeId) {
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 return false;
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 }
bd4099d42d83 Added authorization class for test env.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)