Example #1
0
  private void processOpen(
      String aSessionId, String aConnectorId, HttpServletRequest aReq, HttpServletResponse aResp)
      throws IOException {
    try {
      String lOrigin = aReq.getScheme() + "://" + aReq.getRemoteHost();
      if (!EngineUtils.isOriginValid(lOrigin, mEngine.getConfiguration().getDomains())) {
        sendMessage(401, "Origin not allowed!", aResp);
        return;
      }

      mConnectorsManager.add(aSessionId, aConnectorId);
      HTTPConnector lConnector = getConnector(aConnectorId, aReq, aResp);
      lConnector.setRemoteHost(InetAddress.getByName(aReq.getRemoteHost()));

      // starting connector on request thread intentionally
      lConnector.startConnector();
    } catch (Exception lEx) {
      sendMessage(500, lEx.getLocalizedMessage(), aResp);
    }
  }