Allow inject Map into SessionRegistryImpl

As principals and sessionIds are set in class itself so one can't share
user session count across nodes(Cluster). Using constructor for setting
principals and sessionIds we can pass Cache map to constructor which can
enable common session count in cluster otherwise user would be allowed to
logged in with multiple sessions. There is no point keeping principals
and sessionIds completely internal.

Fixes gh-4772
This commit is contained in:
Gajendra kumar 2016-12-29 08:05:22 +05:30 committed by Rob Winch
parent cd63329b63
commit 6cbf71bd72

View File

@ -48,13 +48,23 @@ public class SessionRegistryImpl implements SessionRegistry,
protected final Log logger = LogFactory.getLog(SessionRegistryImpl.class);
/** <principal:Object,SessionIdSet> */
private final ConcurrentMap<Object, Set<String>> principals = new ConcurrentHashMap<Object, Set<String>>();
private final ConcurrentMap<Object, Set<String>> principals;
/** <sessionId:Object,SessionInformation> */
private final Map<String, SessionInformation> sessionIds = new ConcurrentHashMap<String, SessionInformation>();
private final Map<String, SessionInformation> sessionIds;
// ~ Methods
// ========================================================================================================
public SessionRegistryImpl() {
this.principals = new ConcurrentHashMap<Object, Set<String>>();
this.sessionIds = new ConcurrentHashMap<String, SessionInformation>();
}
public SessionRegistryImpl(ConcurrentMap<Object, Set<String>> principals,Map<String, SessionInformation> sessionIds) {
this.principals=principals;
this.sessionIds=sessionIds;
}
public List<Object> getAllPrincipals() {
return new ArrayList<Object>(principals.keySet());
}