annotate src/main/java/de/intevation/lada/util/auth/MessprogrammAuthorizer.java @ 1150:cf1eb19f896b

Authorize messprogramm - messmethode.
author Raimund Renkert <raimund.renkert@intevation.de>
date Mon, 07 Nov 2016 11:06:23 +0100
parents f78f90446084
children 65ed13ff9945
rev   line source
1070
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
3 *
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
7 */
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8 package de.intevation.lada.util.auth;
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9
1150
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
10 import javax.inject.Inject;
1070
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
11
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
12 import de.intevation.lada.model.land.Messprogramm;
1150
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
13 import de.intevation.lada.model.land.MessprogrammMmt;
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
14 import de.intevation.lada.util.annotation.RepositoryConfig;
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
15 import de.intevation.lada.util.data.Repository;
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
16 import de.intevation.lada.util.data.RepositoryType;
1070
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17 import de.intevation.lada.util.rest.RequestMethod;
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
18 import de.intevation.lada.util.rest.Response;
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
19
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
20 public class MessprogrammAuthorizer implements Authorizer {
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21
1150
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
22 @Inject
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
23 @RepositoryConfig(type=RepositoryType.RO)
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
24 private Repository repository;
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
25
1070
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
26 @Override
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
27 public <T> boolean isAuthorized(
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
28 Object data,
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
29 RequestMethod method,
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
30 UserInfo userInfo,
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
31 Class<T> clazz
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
32 ) {
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
33 if (method == RequestMethod.GET) {
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
34 // Allow read access to everybody
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
35 return true;
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36 }
1150
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
37 Messprogramm messprogramm = null;
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
38 if (data instanceof Messprogramm) {
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
39 messprogramm = (Messprogramm)data;
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
40 }
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
41 else if (data instanceof MessprogrammMmt) {
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
42 messprogramm = repository.getByIdPlain(
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
43 Messprogramm.class,
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
44 ((MessprogrammMmt)data).getMessprogrammId(),
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
45 "land");
cf1eb19f896b Authorize messprogramm - messmethode.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1070
diff changeset
46 }
1070
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
47 if (userInfo.getMessstellen().contains(messprogramm.getMstId())) {
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
48 return true;
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
49 }
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
50 return false;
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
51 }
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
52
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
53 @Override
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
54 public <T> Response filter(
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
55 Response data,
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
56 UserInfo userInfo,
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
57 Class<T> clazz
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
58 ) {
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
59 // Allow read access to everybody
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
60 return data;
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
61 }
f78f90446084 Add minimalistic authorization for Messprogramm.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
62 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)