Ejemplo n.º 1
0
 private void done() {
   if (handler != null) {
     handler.close();
   }
   if (passport != null) {
     passport.close();
   }
   HBCIUtils.doneThread();
 }
Ejemplo n.º 2
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();
      }
    }
  }
Ejemplo n.º 3
0
  /** @see de.willuhn.jameica.hbci.passports.rdh.keyformat.KeyFormat#createKey(java.io.File) */
  public RDHKey createKey(File file) throws ApplicationException, OperationCanceledException {
    HBCIHandler handler = null;
    RDHKeyImpl key = null;

    try {
      key = new RDHKeyImpl(file);
      key.setFormat(this);

      // Wir machen den Handler einmal auf und wieder zu, damit
      // der Schluessel gleich initialisiert wird.
      HBCIPassport passport = load(key, true);
      passport.saveChanges();
      passport.syncSigId();
      passport.syncSysId();

      // Bei der Neuerstellung fragen wir immer den User nach der HBCI-Version
      // Wir fragen die HBCI-Version via Messaging ab, damit sie ggf. auch
      // (z.Bsp. vom Payment-Server) automatisch beantwortet werden kann.
      QueryMessage msg = new QueryMessage(passport);
      Application.getMessagingFactory()
          .getMessagingQueue("hibiscus.passport.rdh.hbciversion")
          .sendSyncMessage(msg);
      Object data = msg.getData();
      if (data == null || !(data instanceof String))
        throw new ApplicationException(i18n.tr("HBCI-Version nicht ermittelbar"));

      String version = (String) msg.getData();
      Logger.info("using hbci version: " + version);

      handler = new HBCIHandler(version, passport);
      handler.close();
      handler = null;
      Application.getMessagingFactory()
          .sendMessage(
              new StatusBarMessage(
                  i18n.tr("Schlüssel erfolgreich erstellt"), StatusBarMessage.TYPE_SUCCESS));
      return key;
    } catch (ApplicationException ae) {
      throw ae;
    } catch (OperationCanceledException oce) {
      throw oce;
    } catch (Exception e) {
      OperationCanceledException oce =
          (OperationCanceledException) HBCIFactory.getCause(e, OperationCanceledException.class);
      if (oce != null) throw oce;

      ApplicationException ae =
          (ApplicationException) HBCIFactory.getCause(e, ApplicationException.class);
      if (ae != null) throw ae;

      NeedKeyAckException ack =
          (NeedKeyAckException) HBCIFactory.getCause(e, NeedKeyAckException.class);
      if (ack != null) {
        Application.getMessagingFactory()
            .sendMessage(
                new StatusBarMessage(
                    i18n.tr("Schlüssel erfolgreich erstellt"), StatusBarMessage.TYPE_SUCCESS));
        String msg =
            i18n.tr(
                "Bitte senden Sie den INI-Brief an Ihre Bank\nund warten Sie auf die Freischaltung durch die Bank.");
        try {
          Application.getCallback().notifyUser(msg);
        } catch (Exception e2) {
          Logger.error("unable to notify user", e2);
          Application.getMessagingFactory()
              .sendMessage(new StatusBarMessage(msg, StatusBarMessage.TYPE_SUCCESS));
        }
        return key;
      }

      Logger.error("unable to create key " + file.getAbsolutePath(), e);
      throw new ApplicationException(
          i18n.tr("Fehler beim Erstellen des Schlüssels: {0}", e.getMessage()));
    } finally {
      try {
        if (handler != null) handler.close();
      } catch (Throwable t) {
        Logger.error("error while closing handler", t);
      }
    }
  }