use of com.keybox.manage.model.UserSchSessions in project KeyBox by skavanagh.
the class SecureShellWS method onMessage.
@OnMessage
public void onMessage(String message) {
if (session.isOpen() && StringUtils.isNotEmpty(message)) {
Map jsonRoot = new Gson().fromJson(message, Map.class);
String command = (String) jsonRoot.get("command");
Integer keyCode = null;
Double keyCodeDbl = (Double) jsonRoot.get("keyCode");
if (keyCodeDbl != null) {
keyCode = keyCodeDbl.intValue();
}
for (String idStr : (ArrayList<String>) jsonRoot.get("id")) {
Integer id = Integer.parseInt(idStr);
//get servletRequest.getSession() for user
UserSchSessions userSchSessions = SecureShellAction.getUserSchSessionMap().get(sessionId);
if (userSchSessions != null) {
SchSession schSession = userSchSessions.getSchSessionMap().get(id);
if (keyCode != null) {
if (keyMap.containsKey(keyCode)) {
try {
schSession.getCommander().write(keyMap.get(keyCode));
} catch (IOException ex) {
log.error(ex.toString(), ex);
}
}
} else {
schSession.getCommander().print(command);
}
}
}
//update timeout
AuthUtil.setTimeout(httpSession);
}
}
use of com.keybox.manage.model.UserSchSessions in project KeyBox by skavanagh.
the class SecureShellWS method onClose.
@OnClose
public void onClose() {
if (SecureShellAction.getUserSchSessionMap() != null) {
UserSchSessions userSchSessions = SecureShellAction.getUserSchSessionMap().get(sessionId);
if (userSchSessions != null) {
Map<Integer, SchSession> schSessionMap = userSchSessions.getSchSessionMap();
for (Integer sessionKey : schSessionMap.keySet()) {
SchSession schSession = schSessionMap.get(sessionKey);
//disconnect ssh session
schSession.getChannel().disconnect();
schSession.getSession().disconnect();
schSession.setChannel(null);
schSession.setSession(null);
schSession.setInputToChannel(null);
schSession.setCommander(null);
schSession.setOutFromChannel(null);
schSession = null;
//remove from map
schSessionMap.remove(sessionKey);
}
//clear and remove session map for user
schSessionMap.clear();
SecureShellAction.getUserSchSessionMap().remove(sessionId);
SessionOutputUtil.removeUserSession(sessionId);
}
}
}
Aggregations