In my case, I need to delete the session who logged in with the same credential in previously. It shouldn't allow keeping same user credentials to more than one user. So that I need to terminate the session if a new user logged in with same credentials. I need to serve only to the new user session.
I have tried in my metadata like below but I couldn't disconnect the previous session of the same user name.
private final ConcurrentHashMap<String, Map<String, String>> sessions = new ConcurrentHashMap<String, Map<String, String>>();
private final ConcurrentHashMap<String, String> userinfo = new ConcurrentHashMap<String, String>();

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
synchronized public void notifyNewSession(String user, String sessionID, Map sessionInfo)
throws CreditsException, NotificationException {


assert (!sessions.containsKey(sessionID));
sessions.put(sessionID, sessionInfo);
if (userinfo.containsKey(user)) {
sessions.remove(userinfo.get(user));
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>> REMOVED USER NAME : " + user);
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>> REMOVED USER SESSION : " + userinfo.get(user));
}
userinfo.put(user, sessionID);
}