forked from hbci4j/hbci4java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unterstützung für die SCA (PSD2). Noch nicht ganz fertig. Initiale Ei…
…nrichtung des Bankzugangs und Abruf der UPD und TAN-Medien funktioniert. Beim Abrufen der Umsätze meckert aber noch die Bank, dass angeblich keine TAN gesendet wurde. Obwohl die in den BPD selbst gesagt haben, dass sie keine haben wollen. Könnte auch ein Fehler der Bank sein. Untersuche ich noch näher.
- Loading branch information
Showing
25 changed files
with
2,455 additions
and
1,034 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
src/main/java/org/kapott/hbci/dialog/AbstractRawHBCIDialog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
/********************************************************************** | ||
* | ||
* Copyright (c) 2019 Olaf Willuhn | ||
* All rights reserved. | ||
* | ||
* This software is copyrighted work licensed under the terms of the | ||
* Jameica License. Please consult the file "LICENSE" for details. | ||
* | ||
**********************************************************************/ | ||
|
||
package org.kapott.hbci.dialog; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
import org.kapott.hbci.exceptions.HBCI_Exception; | ||
import org.kapott.hbci.manager.HBCIKernelImpl; | ||
import org.kapott.hbci.manager.HBCIUtils; | ||
import org.kapott.hbci.passport.HBCIPassportInternal; | ||
import org.kapott.hbci.status.HBCIMsgStatus; | ||
|
||
/** | ||
* Abstrakte Basis-Klasse fuer "rohe" HBCI-Dialoge. | ||
*/ | ||
public abstract class AbstractRawHBCIDialog implements RawHBCIDialog | ||
{ | ||
private KnownDialogTemplate template = null; | ||
private AtomicInteger executions = new AtomicInteger(0); | ||
|
||
/** | ||
* ct. | ||
* @param template das zu verwendende Template. | ||
*/ | ||
AbstractRawHBCIDialog(KnownDialogTemplate template) | ||
{ | ||
this.template = template; | ||
} | ||
|
||
/** | ||
* @see org.kapott.hbci.dialog.RawHBCIDialog#execute(org.kapott.hbci.dialog.DialogContext) | ||
*/ | ||
public final HBCIMsgStatus execute(final DialogContext ctx) | ||
{ | ||
HBCIMsgStatus status = null; | ||
|
||
do | ||
{ | ||
// Sicherstellen, dass das Flag false ist, wenn wir starten. Kann von einem Event wieder aktiviert werden | ||
ctx.setRepeat(false); | ||
|
||
// Checken, ob ein Neustart noch moeglich ist: | ||
if (this.executions.get() > 2) | ||
{ | ||
HBCIUtils.log("dialog loop detected for " + this.getTemplate() + ", id " + ctx.getDialogId() + ", message number: " + ctx.getMsgNum() + ", execution count: " + this.executions.get(),HBCIUtils.LOG_ERR); | ||
throw new HBCI_Exception("dialog loop detected for " + this.getTemplate()); | ||
} | ||
|
||
ctx.setDialogInit(this); | ||
|
||
final HBCIPassportInternal p = ctx.getPassport(); | ||
final HBCIKernelImpl k = ctx.getKernel(); | ||
|
||
/////////////////////////////////////////////////////// | ||
// Erstellung der Nachricht | ||
p.onDialogEvent(DialogEvent.MSG_CREATE,ctx); | ||
final String dialog = this.getActualTemplate(ctx); | ||
HBCIUtils.log("creating dialog " + dialog + ", id " + ctx.getDialogId() + ", message number: " + ctx.getMsgNum() + ", execution count: " + this.executions.get(),HBCIUtils.LOG_INFO); | ||
k.rawNewMsg(dialog); | ||
this.applyData(ctx); | ||
p.onDialogEvent(DialogEvent.MSG_CREATED,ctx); | ||
// | ||
/////////////////////////////////////////////////////// | ||
|
||
/////////////////////////////////////////////////////// | ||
// Versand der Nachricht | ||
HBCIUtils.log("sending message using dialog " + dialog + ", id " + ctx.getDialogId() + ", message number: " + ctx.getMsgNum(),HBCIUtils.LOG_INFO); | ||
status = this.sendData(ctx); | ||
// | ||
/////////////////////////////////////////////////////// | ||
|
||
|
||
/////////////////////////////////////////////////////// | ||
// Ergebnis-Auswertung | ||
ctx.update(status); | ||
this.executions.incrementAndGet(); | ||
p.onDialogEvent(DialogEvent.MSG_SENT,ctx); | ||
this.checkResult(ctx); | ||
// | ||
/////////////////////////////////////////////////////// | ||
} | ||
while (ctx.isRepeat()); | ||
|
||
return status; | ||
} | ||
|
||
/** | ||
* Default-Implementierung fuer den Versand. Verschluesselung und Signierung findet nur statt, wenn es kein anonymer Dialog ist. | ||
* @param ctx der Kontext. | ||
* @return die Ergebnis-Daten. | ||
*/ | ||
protected HBCIMsgStatus sendData(final DialogContext ctx) | ||
{ | ||
final boolean a = ctx.isAnonymous(); | ||
return ctx.getKernel().rawDoIt(!a && HBCIKernelImpl.SIGNIT, | ||
!a && HBCIKernelImpl.CRYPTIT, | ||
!a && HBCIKernelImpl.NEED_CRYPT); | ||
} | ||
|
||
/** | ||
* Befuellt die Daten fuer die Nachricht. | ||
* @param ctx der Kontext. | ||
*/ | ||
protected void applyData(final DialogContext ctx) | ||
{ | ||
final HBCIKernelImpl k = ctx.getKernel(); | ||
|
||
k.rawSet("MsgHead.dialogid",ctx.getDialogId()); | ||
k.rawSet("MsgHead.msgnum",Integer.toString(ctx.getMsgNum())); | ||
k.rawSet("MsgTail.msgnum",Integer.toString(ctx.getMsgNum())); | ||
} | ||
|
||
/** | ||
* Kann implementiert werden, um das Ergebnis des Dialogs zu pruefen. | ||
* @param ctx der Kontext. | ||
*/ | ||
protected void checkResult(final DialogContext ctx) | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @see org.kapott.hbci.dialog.RawHBCIDialog#getTemplate() | ||
*/ | ||
@Override | ||
public KnownDialogTemplate getTemplate() | ||
{ | ||
return this.template; | ||
} | ||
|
||
/** | ||
* @see org.kapott.hbci.dialog.RawHBCIDialog#setTemplate(org.kapott.hbci.dialog.KnownDialogTemplate) | ||
*/ | ||
@Override | ||
public void setTemplate(KnownDialogTemplate t) | ||
{ | ||
this.template = t; | ||
} | ||
|
||
/** | ||
* Liefert das tatsaechlich zu verwendende Message-Template basierend auf dem Kontext. | ||
* @param ctx der Kontext. | ||
* @return template das zu verwendende Message-Template. | ||
*/ | ||
protected String getActualTemplate(final DialogContext ctx) | ||
{ | ||
return this.getTemplate().getName(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/org/kapott/hbci/dialog/AbstractRawHBCIDialogInit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/********************************************************************** | ||
* | ||
* Copyright (c) 2019 Olaf Willuhn | ||
* All rights reserved. | ||
* | ||
* This software is copyrighted work licensed under the terms of the | ||
* Jameica License. Please consult the file "LICENSE" for details. | ||
* | ||
**********************************************************************/ | ||
|
||
package org.kapott.hbci.dialog; | ||
|
||
import org.kapott.hbci.manager.HBCIKernelImpl; | ||
import org.kapott.hbci.manager.HBCIUtils; | ||
import org.kapott.hbci.passport.HBCIPassportInternal; | ||
|
||
/** | ||
* Abstrakte Basis-Klasse fuer "rohe" HBCI-Init-Dialoge. | ||
*/ | ||
public abstract class AbstractRawHBCIDialogInit extends AbstractRawHBCIDialog | ||
{ | ||
/** | ||
* ct. | ||
* @param template das Template. | ||
*/ | ||
AbstractRawHBCIDialogInit(KnownDialogTemplate template) | ||
{ | ||
super(template); | ||
} | ||
|
||
/** | ||
* @see org.kapott.hbci.dialog.AbstractRawHBCIDialog#applyData(org.kapott.hbci.dialog.DialogContext) | ||
*/ | ||
@Override | ||
protected void applyData(final DialogContext ctx) | ||
{ | ||
super.applyData(ctx); | ||
|
||
final HBCIPassportInternal p = ctx.getPassport(); | ||
final HBCIKernelImpl k = ctx.getKernel(); | ||
|
||
k.rawSet("Idn.KIK.blz", p.getBLZ()); | ||
k.rawSet("Idn.KIK.country", p.getCountry()); | ||
k.rawSet("ProcPrep.BPD", p.getBPDVersion()); | ||
k.rawSet("ProcPrep.UPD", p.getUPDVersion()); | ||
k.rawSet("ProcPrep.lang",p.getLang()); | ||
k.rawSet("ProcPrep.prodName",HBCIUtils.getParam("client.product.name",HBCIUtils.PRODUCT_ID)); | ||
k.rawSet("ProcPrep.prodVersion",HBCIUtils.getParam("client.product.version","3")); | ||
} | ||
|
||
} |
Oops, something went wrong.