Example #1
0
  public synchronized void startWaiting(long seconds, String errMsg) {
    try {
      if (!notified) {
        HBCIUtils.log(name + ".startWaiting: !notified, waiting now", HBCIUtils.LOG_DEBUG);
        // wenn das notify() nicht schon vor dem wait() kam, dann
        // wirklich warten

        waiting = true;
        wait(seconds * 1000);
        waiting = false;

        if (!notified) {
          HBCIUtils.log(
              name + ".startWaiting: end of wait: !notified (timeouted)", HBCIUtils.LOG_DEBUG);
          // wenn das wait() wegen timeouted terminierte
          timeouted = true;
          throw new RuntimeException(name + ": " + errMsg);
        }
        HBCIUtils.log(
            name + ".startWaiting: end of wait: notified, normal end of wait", HBCIUtils.LOG_DEBUG);

        // damit ist alles wieder im ausgangszustand
        notified = false;
      } else {
        HBCIUtils.log(
            name + ".startWaiting: notified (notified before wait())", HBCIUtils.LOG_DEBUG);
        notified = false;
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
Example #2
0
  /** ct. */
  private ChallengeInfo() {
    HBCIUtils.log("initializing challenge info engine", HBCIUtils.LOG_DEBUG);

    ////////////////////////////////////////////////////////////////////////////
    // XML-Datei lesen
    String xmlpath = HBCIUtils.getParam("kernel.kernel.challengedatapath", "");
    InputStream dataStream = null;

    String filename = xmlpath + "challengedata.xml";
    dataStream = ChallengeInfo.class.getClassLoader().getResourceAsStream(filename);
    if (dataStream == null)
      throw new InvalidUserDataException("*** can not load challenge information from " + filename);

    // mit den so gefundenen xml-daten ein xml-dokument bauen
    Document doc = null;
    try {
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      dbf.setIgnoringComments(true);
      dbf.setValidating(true);

      DocumentBuilder db = dbf.newDocumentBuilder();
      doc = db.parse(dataStream);
      dataStream.close();
    } catch (Exception e) {
      throw new HBCI_Exception("*** can not load challengedata from file " + filename, e);
    }
    //
    ////////////////////////////////////////////////////////////////////////////

    data = new HashMap<String, Job>();

    ////////////////////////////////////////////////////////////////////////////
    // Parsen
    NodeList jobs = doc.getElementsByTagName("job");
    int size = jobs.getLength();

    for (int i = 0; i < size; ++i) {
      Element job = (Element) jobs.item(i);
      String code = job.getAttribute("code");
      data.put(code, new Job(job));
    }
    //
    ////////////////////////////////////////////////////////////////////////////

    HBCIUtils.log("challenge information loaded", HBCIUtils.LOG_DEBUG);
  }
Example #3
0
  public synchronized void stopWaiting() {
    HBCIUtils.log(name + ".stopWaiting", HBCIUtils.LOG_DEBUG);
    notified = true;
    if (waiting) {
      HBCIUtils.log(name + ".stopWaiting: someone waits, so notify()", HBCIUtils.LOG_DEBUG);
      notify();
    } else {
      if (timeouted) {
        HBCIUtils.log(
            name + ".stopWaiting: trying to awake a timeouted wait() - aborting",
            HBCIUtils.LOG_DEBUG);
        timeouted = false;
        throw new RuntimeException(name + ": can not awake a timeouted wait()");
      }

      HBCIUtils.log(name + ".stopWaiting: no one waits, so we do nothing", HBCIUtils.LOG_DEBUG);
    }
  }
 public static String getLocMsg(String key) {
   ThreadGroup group = Thread.currentThread().getThreadGroup();
   try {
     return locMsgs.get(group).getString(key);
   } catch (MissingResourceException re) {
     // tolerieren wir
     HBCIUtils.log(re, HBCIUtils.LOG_ERR);
     return key;
   }
 }
  public static boolean ignoreError(HBCIPassport passport, String paramName, String msg) {
    boolean ret = false;
    String paramValue = HBCIUtils.getParam(paramName, "no");

    if (paramValue.equals("yes")) {
      HBCIUtils.log(msg, HBCIUtils.LOG_ERR);
      HBCIUtils.log("ignoring error because param " + paramName + "=yes", HBCIUtils.LOG_ERR);
      ret = true;
    } else if (paramValue.equals("callback")) {
      StringBuffer sb = new StringBuffer();
      getCallback().callback(passport, HBCICallback.HAVE_ERROR, msg, HBCICallback.TYPE_BOOLEAN, sb);
      if (sb.length() == 0) {
        HBCIUtils.log(msg, HBCIUtils.LOG_ERR);
        HBCIUtils.log("ignoring error because param " + paramName + "=callback", HBCIUtils.LOG_ERR);
        ret = true;
      }
    }

    return ret;
  }
Example #6
0
  /**
   * Uebernimmt die Challenge-Parameter in den HKTAN-Geschaeftsvorfall.
   *
   * @param task der Job, zu dem die Challenge-Parameter ermittelt werden sollen.
   * @param hktan der HKTAN-Geschaeftsvorfall, in dem die Parameter gesetzt werden sollen.
   * @param secmech die BPD-Informationen zum TAN-Verfahren.
   */
  public void applyParams(HBCIJobImpl task, HBCIJob hktan, Properties secmech) {
    String code = task.getHBCICode(); // Code des Geschaeftsvorfalls

    // Job-Parameter holen
    Job job = this.getData(code);

    // Den Geschaeftsvorfall kennen wir nicht. Dann brauchen wir
    // auch keine Challenge-Parameter setzen
    if (job == null) {
      HBCIUtils.log(
          "have no challenge data for " + code + ", will not apply challenge params",
          HBCIUtils.LOG_INFO);
      return;
    }

    HHDVersion version = HHDVersion.find(secmech);
    HBCIUtils.log("using hhd version " + version, HBCIUtils.LOG_DEBUG2);

    // Parameter fuer die passende HHD-Version holen
    HhdVersion hhd = job.getVersion(version.getChallengeVersion());

    // Wir haben keine Parameter fuer diese HHD-Version
    if (hhd == null) {
      HBCIUtils.log(
          "have no challenge data for "
              + code
              + " in "
              + version
              + ", will not apply challenge params",
          HBCIUtils.LOG_INFO);
      return;
    }

    // Schritt 1: Challenge-Klasse uebernehmen
    String klass = hhd.getKlass();
    HBCIUtils.log("using challenge klass " + klass, HBCIUtils.LOG_DEBUG2);
    hktan.setParam("challengeklass", klass);

    // Schritt 2: Challenge-Parameter uebernehmen
    List<Param> params = hhd.getParams();
    for (int i = 0; i < params.size(); ++i) {
      int num = i + 1; // Die Job-Parameter beginnen bei 1
      Param param = params.get(i);

      // Checken, ob der Parameter angewendet werden soll.
      if (!param.isComplied(secmech)) {
        HBCIUtils.log(
            "skipping challenge parameter "
                + num
                + " ("
                + param.path
                + "), condition "
                + param.conditionName
                + "="
                + param.conditionValue
                + " not complied",
            HBCIUtils.LOG_DEBUG2);
        continue;
      }

      // Parameter uebernehmen. Aber nur wenn er auch einen Wert hat.
      // Seit HHD 1.4 duerfen Parameter mittendrin optional sein, sie
      // werden dann freigelassen
      String value = param.getValue(task);
      if (value == null || value.length() == 0) {
        HBCIUtils.log(
            "challenge parameter " + num + " (" + param.path + ") is empty", HBCIUtils.LOG_DEBUG2);
        continue;
      }

      HBCIUtils.log(
          "adding challenge parameter " + num + " " + param.path + "=" + value,
          HBCIUtils.LOG_DEBUG2);
      hktan.setParam("ChallengeKlassParam" + num, value);
    }
  }
 public static void infoPointSendPublicKeys(HBCIPassportInternal passport, Properties msgData) {
   if (HBCIUtils.getParam("infoPoint.enabled", "0").equals("1")) {
     getInfoPointConnector().sendPublicKeys(passport, msgData);
   }
 }