-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathUserGenericPrincipal.java
More file actions
42 lines (30 loc) · 1.09 KB
/
UserGenericPrincipal.java
File metadata and controls
42 lines (30 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.occamlab.te.realm;
import java.security.Principal;
import java.util.HashMap;
import java.util.logging.Logger;
public class UserGenericPrincipal {
private static final Logger logger = Logger.getLogger(UserGenericPrincipal.class.getPackage().getName());
private HashMap<String, Principal> principals = new HashMap<String, Principal>();
private static volatile UserGenericPrincipal userPrincipal = null;
public static UserGenericPrincipal getInstance() {
if (null == userPrincipal) {
synchronized (UserGenericPrincipal.class) {
// check again, because the thread might have been preempted
// just after the outer if was processed but before the
// synchronized statement was executed
if (userPrincipal == null) {
userPrincipal = new UserGenericPrincipal();
}
}
}
return userPrincipal;
}
public Principal removePrincipal(String username) {
synchronized (principals) {
return (Principal) principals.remove(username);
}
}
public HashMap<String, Principal> getPrincipals() {
return principals;
}
}