Package de.willuhn.jameica.hbci.synchronize

Examples of de.willuhn.jameica.hbci.synchronize.SynchronizeSession


  public void callback(HBCIPassport passport, int reason, String msg, int datatype, StringBuffer retData) {
   
    cacheData(passport);

    BeanService service = Application.getBootLoader().getBootable(BeanService.class);
    SynchronizeSession session = service.get(HBCISynchronizeBackend.class).getCurrentSession();

    try {
     
      if (currentHandle != null && currentHandle.callback(passport,reason,msg,datatype,retData))
      {
        Logger.debug("callback [reason " + reason + "] handled by " + currentHandle.getClass());
        return;
      }

      AccountContainer container = accountCache.get(passport);
     
      switch (reason) {
       
        // Hier kommen nur noch die PIN/TAN und DDV-Passports an. Die von RDH werden
        // im PassportHandle verarbeitet
        case NEED_PASSPHRASE_LOAD:
        case NEED_PASSPHRASE_SAVE:
         
          // Passwort aus dem Wallet laden
          Wallet w = Settings.getWallet();
          String pw = (String) w.get("hbci.passport.password." + passport.getClass().getName());
          if (pw != null && pw.length() > 0)
          {
            Logger.debug("using passport key from wallet, passport: " + passport.getClass().getName());
            retData.replace(0,retData.length(),pw);
            break;
          }
           
          // noch kein Passwort definiert. Dann erzeugen wir ein zufaelliges.
          Logger.debug("creating new random passport key, passport: " + passport.getClass().getName());
          byte[] pass = new byte[8];
          SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
          random.nextBytes(pass);
          pw = Base64.encode(pass);

          // Und speichern es im Wallet.
          w.set("hbci.passport.password." + passport.getClass().getName(),pw);
          retData.replace(0,retData.length(),pw);
          break;

        case NEED_CONNECTION:
          if (!Settings.getOnlineMode())
            Application.getCallback().notifyUser(i18n.tr("Bitte stellen Sie eine Internetverbindung her und klicken Sie anschlie�end auf OK."));
          break;
        case CLOSE_CONNECTION:
          if (!Settings.getOnlineMode())
            Application.getCallback().notifyUser(i18n.tr("Sie k�nnen die Internetverbindung nun wieder trennen."));
          break;

        case NEED_COUNTRY:
          if (container == null) container = DialogFactory.getAccountData(passport);
          accountCache.put(passport,container);
          retData.replace(0,retData.length(),container.country);
          break;

        case NEED_BLZ:
          if (container == null) container = DialogFactory.getAccountData(passport);
          accountCache.put(passport,container);
          retData.replace(0,retData.length(),container.blz);
          break;

        case NEED_HOST:
          if (container == null) container = DialogFactory.getAccountData(passport);
          accountCache.put(passport,container);
          retData.replace(0,retData.length(),container.host);
          break;

        case NEED_PORT:
          if (container == null) container = DialogFactory.getAccountData(passport);
          accountCache.put(passport,container);
          retData.replace(0,retData.length(),container.port+"");
          break;

        case NEED_FILTER:
          if (container == null) container = DialogFactory.getAccountData(passport);
          accountCache.put(passport,container);
          retData.replace(0,retData.length(),container.filter);
          break;

        case NEED_USERID:
          if (container == null) container = DialogFactory.getAccountData(passport);
          accountCache.put(passport,container);
          retData.replace(0,retData.length(),container.userid);
          break;

        case NEED_CUSTOMERID:
          if (container == null) container = DialogFactory.getAccountData(passport);
          accountCache.put(passport,container);
          retData.replace(0,retData.length(),container.customerid);
          break;

        case NEED_NEW_INST_KEYS_ACK:
          NewInstKeysDialog nikd = new NewInstKeysDialog(passport);
          Boolean b = (Boolean) nikd.open();
          retData.replace(0,retData.length(),b.booleanValue() ? "" : "ERROR");
          break;

        case HAVE_NEW_MY_KEYS:
          NewKeysDialog nkd = new NewKeysDialog(passport);
          try
          {
            nkd.open();
          }
          catch (OperationCanceledException e)
          {
            // Den INI-Brief kann der User auch noch spaeter ausdrucken
            Logger.warn(e.getMessage());
          }
          break;

        // Die folgenden beiden Callbacks duerfen nicht in den RDH-Passport verschoben
        // werden, weil sie auftreten koennen, wenn kein currentPassport hier hinterlegt ist
        case HAVE_INST_MSG:
          // BUGZILLA 68 http://www.willuhn.de/bugzilla/show_bug.cgi?id=68
          try
          {
            Nachricht n = (Nachricht) Settings.getDBService().createObject(Nachricht.class,null);
            n.setBLZ(passport.getBLZ());
            n.setNachricht(msg);
            n.setDatum(new Date());
            n.store();
            String text = i18n.tr("Neue Institutsnachricht empfangen");
            Application.getMessagingFactory().sendMessage(new StatusBarMessage(text,StatusBarMessage.TYPE_SUCCESS));
            Application.getMessagingFactory().sendMessage(new ImportMessage(n));
            session.getProgressMonitor().setStatusText(text);
          }
          catch (Exception e)
          {
            Logger.error("unable to store system message",e);
            // Im Fehlerfall zeigen wir einfach den Dialog an
            Application.getCallback().notifyUser(msg);
          }
          break;
         
        case NEED_INFOPOINT_ACK:
          QueryMessage qm = new QueryMessage(msg,retData);
          Application.getMessagingFactory().getMessagingQueue("hibiscus.infopoint").sendSyncMessage(qm);
          retData.replace(0,retData.length(),qm.getData() == null ? "" : "false");
          break;
         
         
        case HAVE_IBAN_ERROR:
        case HAVE_CRC_ERROR:
          if (Settings.getKontoCheck())
            Logger.error("IBAN/CRC error: " + msg+ " ["+retData.toString()+"]: ");
          break;
         
        case WRONG_PIN:
          Logger.error("detected wrong PIN: " + msg+ " ["+retData.toString()+"]: ");
          break;
         
        case USERID_CHANGED:
          Logger.info("got changed user/account data (code 3072) - saving in persistent data for later handling");
          ((AbstractHBCIPassport)passport).setPersistentData(PassportHandle.CONTEXT_USERID_CHANGED,retData.toString());
          break;

        case HAVE_ERROR:
          Logger.error("NOT IMPLEMENTED: " + msg+ " ["+retData.toString()+"]: ");
          throw new HBCI_Exception("reason not implemented");

        default:
          Logger.error("unknown reason " + reason + ", datatype: " + datatype + ": " + msg);
          throw new HBCI_Exception("unknown reason " + reason + ": " + msg);
 
      }

    }
    catch (NeedKeyAckException e)
    {
      // Die wird bei HAVE_NEW_MY_KEYS geworfen.
      // Wir brechen ohne Anzeigen eines Fehlers ab.
      session.cancel();
    }
    catch (OperationCanceledException oce)
    {
      // Die wird geworfen, wenn der User selbst abgebrochen hat.
      // Wuerde ich die jetzt weiterwerfen, muesste ich mir bei
      // der anschliessenden Abfrage nach der Fehlerquelle in
      // meinem HBCI-Job durch einen Stapel von ineinander
      // verpackte HBCI_Exceptions wuehlen, um diese hier
      // wiederzufinden. Das ist mir zu aufwaendig. Deswegen
      // teile ich der Factory gleich selbst mit, dass der
      // User die Aktion selbst abgebrochen hat.
      if (session != null) // kann er u.U. abbrechen, bevor die Session existierte
        session.cancel();
      throw oce;
    }
    catch (Throwable t)
    {
      if (t instanceof SWTException) // von SWT verpackt
        t = ((SWTException) t).throwable;

      // Siehe oben. Wir wollen sichergehen, dass die OperationCanceledException
      // nicht nochmal verpackt ist.
      Throwable th = HBCIProperties.getCause(t,OperationCanceledException.class);
      if (th != null)
      {
        session.cancel();
        throw (OperationCanceledException) th;
      }
     
      // Ansonsten durchwerfen
      if (t instanceof RuntimeException)
View Full Code Here


  protected void status(String text)
  {
    Logger.info(text);
   
    BeanService service = Application.getBootLoader().getBootable(BeanService.class);
    SynchronizeSession session = service.get(HBCISynchronizeBackend.class).getCurrentSession();

    if (session != null)
    {
      ProgressMonitor monitor = session.getProgressMonitor();
      monitor.log(text + "\n");
    }
  }
View Full Code Here

TOP

Related Classes of de.willuhn.jameica.hbci.synchronize.SynchronizeSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.