code: public static boolean saveSshSessionAndChannel(Session session, Channel channel, GlobalSessionObject<Map<String, SSHConnection>> sessionParam, String sessionId) {
          final SSHConnection sshConnection;
          if (channel != null) {
              sshConnection = new SSHConnection(session, channel);
          } else {
              sshConnection = new SSHConnection(session);
          }
          if (sessionParam != null) {
              Map<String, SSHConnection> tempMap = sessionParam.get();
              if (tempMap == null) {
                  tempMap = new HashMap<>();
              }
              tempMap.put(sessionId, sshConnection);
              sessionParam.setResource(new SSHSessionResource(tempMap));
              return true;
          }
          return false;
      }
docs: Save the SSH session and the channel in the cache.
  
  @param session      The SSH session.
  @param channel      The SSH channel.
  @param sessionParam The cache: GlobalSessionObject or SessionObject.