1 // license-header java merge-point
2 //
3 // Attention: Generated code! Do not modify by hand!
4 // Generated by: SpringPrincipalStore.vsl in andromda-spring-cartridge.
5 //
6 package fr.ifremer.quadrige2.core.dao;
7
8 /*-
9 * #%L
10 * Quadrige2 Core :: Server API
11 * %%
12 * Copyright (C) 2017 Ifremer
13 * %%
14 * This program is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Affero General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU Affero General Public License
25 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 * #L%
27 */
28
29 import java.security.Principal;
30
31 /**
32 * Stores the currently logged in Principal. The principal is passed
33 * from another tier of the application (i.e. the web application).
34 */
35 public final class PrincipalStore
36 {
37 /**
38 * The security realm of this application.
39 */
40 public static String SECURITY_REALM = "$securityRealm";
41
42 private static final ThreadLocal<Principal> store = new ThreadLocal<Principal>();
43
44 /**
45 * Get the user <code>principal</code>
46 * for the currently executing thread.
47 *
48 * @return the current principal.
49 */
50 public static Principal get()
51 {
52 return store.get();
53 }
54
55 /**
56 * Set the <code>principal</code> for the currently executing thread.
57 *
58 * @param principal the user principal
59 */
60 public static void set(final Principal principal)
61 {
62 store.set(principal);
63 }
64 }