Beispiel #1
0
  public static void main(String[] args) throws IOException {
    try {
      HBCIUtils.init(null, new MyCallback());
      readBasicParams();

      readPassportParams();
      passport = AbstractHBCIPassport.getInstance();

      readHBCIVersion();
      readActions();

      if (HBCIUtils.getParam("action.resetBPD").equals("1")) {
        passport.clearBPD();
      }
      if (HBCIUtils.getParam("action.resetUPD").equals("1")) {
        passport.clearUPD();
      }
      hbciHandle =
          new HBCIHandler(HBCIUtils.getParam("client.passport.hbciversion.default"), passport);

      /* HBCIExecStatus ret=hbciHandle.execute();
      System.out.println("ExecStatus");
      System.out.println(ret.toString());
      System.out.println("ExecStatusEnd");
      System.out.println("ExecStatusError");
      System.out.println(ret.getErrorString());
      System.out.println("ExecStatusErrorEnd"); */

      printSupportedGVs(hbciHandle);

      System.out.println();
      System.out.println("finished.");
      System.out.println();
    } finally {
      if (hbciHandle != null) {
        hbciHandle.close();
      } else if (passport != null) {
        passport.close();
      }
    }
  }
Beispiel #2
0
 private static void readBasicParams() throws IOException {
   readParam(
       "client.connection.localPort", null, "local tcp-port to be used for outgoing connections");
   readParam(
       "comm.standard.socks.server",
       null,
       "SOCKS server to be used for outgoing connections (will be ignored for PIN/TAN)");
   readParam(
       "log.loglevel.default",
       "5",
       "loglevel for HBCI4Java-messages (from 0(no logging) to 5(really heavy)");
   readParam(
       "kernel.rewriter",
       HBCIUtils.getParam("kernel.rewriter"),
       "rewriter modules to be activated");
 }
  public HBCIPassportRDH(Object initObject) {
    this(initObject, 0);

    String header = getParamHeader();
    String fname = HBCIUtils.getParam(header + ".filename");
    boolean init = HBCIUtils.getParam(header + ".init", "1").equals("1");

    if (fname == null) {
      throw new NullPointerException(header + ".filename must not be null");
    }

    HBCIUtils.log("loading passport data from file " + fname, HBCIUtils.LOG_DEBUG);
    setFilename(fname);

    if (init) {
      HBCIUtils.log("loading data from file " + fname, HBCIUtils.LOG_DEBUG);

      setFilterType("None");
      setPort(new Integer(3000));

      if (!new File(fname).canRead()) {
        HBCIUtils.log("have to create new passport file", HBCIUtils.LOG_WARN);
        askForMissingData(true, true, true, true, false, true, true);
        saveChanges();
      }

      ObjectInputStream o = null;
      try {
        int retries = Integer.parseInt(HBCIUtils.getParam("client.retries.passphrase", "3"));

        while (true) { // loop for entering the correct passphrase
          if (getPassportKey() == null) setPassportKey(calculatePassportKey(FOR_LOAD));

          PBEParameterSpec paramspec = new PBEParameterSpec(CIPHER_SALT, CIPHER_ITERATIONS);
          Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
          cipher.init(Cipher.DECRYPT_MODE, getPassportKey(), paramspec);

          o = null;
          try {
            o = new ObjectInputStream(new CipherInputStream(new FileInputStream(fname), cipher));
          } catch (StreamCorruptedException e) {
            setPassportKey(null);

            retries--;
            if (retries <= 0) throw new InvalidPassphraseException();
          }

          if (o != null) break;
        }

        setCountry((String) (o.readObject()));
        setBLZ((String) (o.readObject()));
        setHost((String) (o.readObject()));
        setPort((Integer) (o.readObject()));
        setUserId((String) (o.readObject()));
        setSysId((String) (o.readObject()));
        setSigId((Long) (o.readObject()));
        setBPD((Properties) (o.readObject()));
        setUPD((Properties) (o.readObject()));

        for (int i = 0; i < 3; i++) {
          for (int j = 0; j < 2; j++) {
            setKey(i, j, (HBCIKey) (o.readObject()));
          }
        }

        setCID((String) (o.readObject()));
        setHBCIVersion((String) o.readObject());
        setCustomerId((String) o.readObject());

        HBCIKey k = getMyPrivateSigKey();
        if (k != null && k.key != null && !(k.key instanceof RSAPrivateCrtKey)) {
          HBCIUtils.log(
              "private sig key is no CRT key, please contact the author!", HBCIUtils.LOG_WARN);
        }

        k = getMyPrivateEncKey();
        if (k != null && k.key != null && !(k.key instanceof RSAPrivateCrtKey)) {
          HBCIUtils.log(
              "private enc key is no CRT key, please contact the author!", HBCIUtils.LOG_WARN);
        }
      } catch (Exception e) {
        throw new HBCI_Exception("*** loading of passport file failed", e);
      }

      try {
        o.close();
      } catch (Exception e) {
        HBCIUtils.log(e);
      }

      if (askForMissingData(true, true, true, true, false, true, true)) saveChanges();
    }
  }
Beispiel #4
0
  private static void readPassportParams() throws IOException {
    readParam(
        "client.passport.default",
        null,
        "enter type of media you have (Anonymous, DDV, RDHNew, RDH (deprecated), PinTan, SIZRDHFile or RDHXFile)");
    String type = HBCIUtils.getParam("client.passport.default", "");

    if (type.equals("Anonymous")) {
      readParam(
          "client.passport.Anonymous.filename",
          "passport_anon.dat",
          "filename to be used for your HBCI4Java keyfile.");
      readParam("client.passport.Anonymous.init", "1", "never change this value!");
    } else if (type.equals("DDV")) {
      readParam(
          "client.passport.DDV.path",
          "./",
          "the path where to store a file to cash information about your HBCI account");
      readParam(
          "client.passport.DDV.libname.ddv",
          "/home/kleiner/projects/hbci2/chipcard/lib/libhbci4java-card-linux.so",
          "the name of the library needed to use the CTAPI interface of your chipcard terminal");
      readParam(
          "client.passport.DDV.libname.ctapi",
          "/usr/lib/libctapi-cyberjack.so",
          "the name of the library containing the CTAPI interface to your chipcard terminal");
      readParam(
          "client.passport.DDV.port",
          "1",
          "the port to which your chipcard terminal is connected (in most cases 1, 0 or 2)");
      readParam(
          "client.passport.DDV.ctnumber",
          "0",
          "the logical number for your chipcard terminal, can be 0 in most cases");
      readParam(
          "client.passport.DDV.usebio",
          "0",
          "use the biometric interface of Reiner-SCT chipcard terminals (0 or 1)");
      readParam(
          "client.passport.DDV.softpin",
          "0",
          "use the keypad of your chipcard terminal (0) or your PC-keyboard (1) to enter the PIN for your HBCI chipcard");
      readParam(
          "client.passport.DDV.entryidx",
          "1",
          "enter the index, which HBCI account stored on the card should be used");
    } else if (type.equals("RDH")) {
      readParam(
          "client.passport.RDH.filename",
          "my_passport.dat",
          "filename to be used for your HBCI4Java keyfile. DONT LOOSE THIS FILE!");
      readParam("client.passport.RDH.init", "1", "never change this value!");
    } else if (type.equals("RDHNew")) {
      readParam(
          "client.passport.RDHNew.filename",
          "my_passport.dat",
          "filename to be used for your HBCI4Java keyfile. DONT LOOSE THIS FILE!");
      readParam("client.passport.RDHNew.init", "1", "never change this value!");
    } else if (type.equals("PinTan")) {
      readParam(
          "client.passport.PinTan.filename",
          "my_passport_pintan.dat",
          "filename to be used for your PIN/TAN keyfile");
      readParam(
          "client.passport.PinTan.checkcert",
          "1",
          "whether to check the HTTPS-certificate of the server (1) or not (0)");
      readParam(
          "client.passport.PinTan.certfile",
          null,
          "filename with a SSL-certificate for HTTPS-communication; leave blank when you don't want to check the certificate or when the certificate can be checked with the java-builtin CA database");
      readParam(
          "client.passport.PinTan.proxy",
          null,
          "host:port for proxy server to be used; leave blank when you want direct connections to be made");
      readParam(
          "client.passport.PinTan.proxyuser",
          null,
          "when you need proxy authentication enter the username here; leave empty to be queried on demand");
      readParam(
          "client.passport.PinTan.proxypass",
          null,
          "when you need proxy authentication enter the passphrase here; leave empty to be queried on demand");
      readParam("client.passport.PinTan.init", "1", "never change this value!");
    } else if (type.equals("SIZRDHFile")) {
      readParam(
          "client.passport.SIZRDHFile.filename",
          "secret.key",
          "filename of SIZ-RDH-keyfile to be used. MAKE A BACKUP OF THIS FILE BEFORE USE!");
      readParam(
          "client.passport.SIZRDHFile.libname",
          "/usr/lib/libhbci4java-sizrdh.so",
          "filename of native library for accessing SIZ RDH files");
      readParam("client.passport.SIZRDHFile.init", "1", "never change this value!");
    } else if (type.equals("RDHXFile")) {
      readParam(
          "client.passport.RDHXFile.filename",
          "secret.key",
          "filename of SIZ-RDH2-keyfile to be used. MAKE A BACKUP OF THIS FILE BEFORE USE!");
      readParam("client.passport.RDHXFile.init", "1", "never change this value!");
    }
  }
Beispiel #5
0
  /* gibt zu einem gegebenen jobnamen des namen dieses jobs in der syntax-spez.
   * zurück (also mit angehängter versionsnummer)
   */
  private void findSpecNameForGV(String jobnameLL, HBCIHandler handler) {
    int maxVersion = 0;
    StringBuffer key = new StringBuffer();

    // alle param-segmente durchlaufen
    Properties bpd = handler.getPassport().getBPD();
    for (Enumeration i = bpd.propertyNames(); i.hasMoreElements(); ) {
      String path = (String) i.nextElement();
      key.setLength(0);
      key.append(path);

      if (key.indexOf("Params") == 0) {
        key.delete(0, key.indexOf(".") + 1);
        // wenn segment mit namen des aktuellen jobs gefunden wurde

        if (key.indexOf(jobnameLL + "Par") == 0 && key.toString().endsWith(".SegHead.code")) {
          // willuhn 2011-06-06 Maximal zulaessige Segment-Version ermitteln
          // Hintergrund: Es gibt Szenarien, in denen nicht die hoechste verfuegbare
          // Versionsnummer verwendet werden kann, weil die Voraussetzungen impliziert,
          // die beim User nicht gegeben sind. Mit diesem Parameter kann die maximale
          // Version nach oben begrenzt werden. In AbstractPinTanPassport#setBPD() ist
          // ein konkretes Beispiel enthalten (Bank macht HITANS5 und damit HHD 1.4, der
          // User hat aber nur ein HHD-1.3-tauglichen TAN-Generator)
          int maxAllowedVersion =
              Integer.parseInt(
                  HBCIUtils.getParam(
                      "kernel.gv." + bpd.getProperty(path, "default") + ".segversion.max", "0"));

          key.delete(0, jobnameLL.length() + ("Par").length());

          // extrahieren der versionsnummer aus dem spez-namen
          String st = key.substring(0, key.indexOf("."));
          int version = 0;

          try {
            version = Integer.parseInt(st);
          } catch (Exception e) {
            HBCIUtils.log(
                "found invalid job version: key="
                    + key
                    + ", jobnameLL="
                    + jobnameLL
                    + " (this is a known, but harmless bug)",
                HBCIUtils.LOG_WARN);
          }

          // willuhn 2011-06-06 Segment-Versionen ueberspringen, die groesser als die max.
          // zulaessige sind
          if (maxAllowedVersion > 0 && version > maxAllowedVersion) {
            HBCIUtils.log(
                "skipping segment version "
                    + version
                    + " for task "
                    + jobnameLL
                    + ", larger than allowed version "
                    + maxAllowedVersion,
                HBCIUtils.LOG_INFO);
            continue;
          }
          // merken der größten jemals aufgetretenen versionsnummer
          if (version != 0) {
            HBCIUtils.log(
                "task " + jobnameLL + " is supported with segment version " + st,
                HBCIUtils.LOG_DEBUG2);
            if (version > maxVersion) {
              maxVersion = version;
            }
          }
        }
      }
    }

    if (maxVersion == 0) {
      throw new JobNotSupportedException(jobnameLL);
    }

    // namen+versionsnummer speichern
    this.jobName = jobnameLL;
    this.segVersion = Integer.toString(maxVersion);
    this.name = jobnameLL + this.segVersion;
  }