private static void initSessionTimer() {
   Integer delay =
       1000
           * 60
           * new Integer(
               AgentUtils.readSetting(
                   settings,
                   AgentConstants.SETTINGS_KEY_SESSION_TIMEOUT,
                   AgentConstants.SETTINGS_SESSION_TIMEOUT));
   sessionTimer =
       new Timer(
           delay,
           new ActionListener() {
             @Override
             public void actionPerformed(ActionEvent event) {
               TrayProcess.deviceService.getClient().clearSession();
               Logger.getLogger(TrayProcess.class.getName())
                   .log(Level.INFO, "Clear session request has been sent to the device.");
             }
           });
   sessionTimer.setRepeats(false);
 }
  protected static void start() throws Exception {
    agent = new SSHAgent();

    if (agent.isCreatedCorrectly()) {

      File settingsFile =
          new File(
              System.getProperty("user.home") + File.separator + AgentConstants.SETTINGS_FILE_NAME);

      if (!settingsFile.exists()) {
        try {
          settings = AgentUtils.initSettingsFile(settingsFile); // create default settings file
          Logger.getLogger(TrayProcess.class.getName())
              .log(
                  Level.INFO,
                  "New settings file created: {0}",
                  new Object[] {settingsFile.getPath()});
        } catch (Exception ex) {
          TrayProcess.createError(
              LocalizedLogger.getLocalizedMessage(
                  "INIT_SETTINGS_FILE_ERROR", ex.getLocalizedMessage()),
              false,
              ex);
          // Logger.getLogger(TrayProcess.class.getName()).log(Level.SEVERE, null, ex);
        }
      } else {
        settings = new Properties();
        try (FileInputStream fileIn = new FileInputStream(settingsFile)) {
          settings.load(fileIn);
        }
        Logger.getLogger(TrayProcess.class.getName())
            .log(
                Level.INFO,
                "Existing settings file loaded: {0}",
                new Object[] {settingsFile.getPath()});
      }

      // start device USB service depending on device type
      String deviceTypeProperty =
          AgentUtils.readSetting(
              settings, AgentConstants.SETTINGS_KEY_DEVICE, AgentConstants.TREZOR_LABEL);
      switch (deviceTypeProperty.toLowerCase()) {
        case (AgentConstants.SETTINGS_KEEPKEY_DEVICE):
          deviceType = AgentConstants.KEEPKEY_LABEL;
          deviceService = KeepKeyService.startKeepKeyService();
          break;
        default:
          deviceType = AgentConstants.TREZOR_LABEL;
          deviceService = TrezorService.startTrezorService();
      }

      initSessionTimer(); // start timer to control session (PIN+Passphrase) expiration

      SwingUtilities.invokeLater(
          new Runnable() { // start GUI
            @Override
            public void run() {
              TrayProcess.createAndShowGUI();
            }
          });

      agent.startMainLoop(); // start SSH Agent emulating Pageant and listening Windows requests
    }
  }