Skip to content

Commit

Permalink
Unterstützung für die SCA (PSD2). Noch nicht ganz fertig. Initiale Ei…
Browse files Browse the repository at this point in the history
…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
willuhn committed Aug 16, 2019
1 parent 4282abc commit 500f075
Show file tree
Hide file tree
Showing 25 changed files with 2,455 additions and 1,034 deletions.
51 changes: 35 additions & 16 deletions src/main/java/org/kapott/hbci/GV/GVTAN2Step.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,41 @@ public GVTAN2Step(HBCIHandler handler)
{
super(handler,getLowlevelName(),new GVRSaldoReq());

int version = 5;
try
{
version = Integer.parseInt(this.getSegVersion());
}
catch (Exception e)
{
HBCIUtils.log(e);
}

addConstraint("process","process",null, LogFilter.FILTER_NONE);
addConstraint("ordersegcode", "ordersegcode","", LogFilter.FILTER_NONE);
addConstraint("orderaccount.bic","OrderAccount.bic",null, LogFilter.FILTER_MOST);
addConstraint("orderaccount.iban","OrderAccount.iban",null, LogFilter.FILTER_IDS);
addConstraint("orderaccount.number","OrderAccount.number",null, LogFilter.FILTER_IDS);
addConstraint("orderaccount.subnumber","OrderAccount.subnumber","", LogFilter.FILTER_MOST);
addConstraint("orderaccount.blz","OrderAccount.KIK.blz",null, LogFilter.FILTER_MOST);
addConstraint("orderaccount.country","OrderAccount.KIK.country","DE", LogFilter.FILTER_NONE);
addConstraint("orderhash","orderhash","", LogFilter.FILTER_NONE);
addConstraint("orderref","orderref","", LogFilter.FILTER_NONE);
addConstraint("listidx","listidx","", LogFilter.FILTER_NONE);

if (version < 6)
addConstraint("listidx","listidx","", LogFilter.FILTER_NONE);

addConstraint("notlasttan","notlasttan","N", LogFilter.FILTER_NONE);
addConstraint("info","info","", LogFilter.FILTER_NONE);

if (version <= 1) // Gabs nur in HKTAN 1
addConstraint("info","info","", LogFilter.FILTER_NONE);

addConstraint("storno","storno","", LogFilter.FILTER_NONE);
// willuhn 2011-05-17 wird noch nicht genutzt
// addConstraint("smsaccount.number","SMSAccount.number",null, LogFilter.FILTER_IDS);
// addConstraint("smsaccount.subnumber","SMSAccount.subnumber","", LogFilter.FILTER_MOST);
// addConstraint("smsaccount.blz","SMSAccount.KIK.blz",null, LogFilter.FILTER_MOST);
// addConstraint("smsaccount.country","SMSAccount.KIK.country","DE", LogFilter.FILTER_NONE);
addConstraint("challengeklass","challengeklass","", LogFilter.FILTER_NONE);
addConstraint("ChallengeKlassParam1", "ChallengeKlassParams.param1","", LogFilter.FILTER_IDS);
addConstraint("ChallengeKlassParam2", "ChallengeKlassParams.param2","", LogFilter.FILTER_IDS);
Expand All @@ -68,21 +95,13 @@ public GVTAN2Step(HBCIHandler handler)
addConstraint("ChallengeKlassParam9", "ChallengeKlassParams.param9","", LogFilter.FILTER_IDS);

addConstraint("tanmedia", "tanmedia","", LogFilter.FILTER_IDS);

addConstraint("HHDUCAnswer", "HHDUCAnswer.atc","", LogFilter.FILTER_IDS);
addConstraint("HHDUCAnswer", "HHDUCAnswer.appcrypto_ac","", LogFilter.FILTER_IDS);
addConstraint("HHDUCAnswer", "HHDUCAnswer.ef_id_data","", LogFilter.FILTER_IDS);
addConstraint("HHDUCAnswer", "HHDUCAnswer.cvr","", LogFilter.FILTER_IDS);
addConstraint("HHDUCAnswer", "HHDUCAnswer.versioninfo","", LogFilter.FILTER_IDS);

addConstraint("ordersegcode", "ordersegcode","", LogFilter.FILTER_NONE);

addConstraint("orderaccount.bic","OrderAccount.bic",null, LogFilter.FILTER_MOST);
addConstraint("orderaccount.iban","OrderAccount.iban",null, LogFilter.FILTER_IDS);
addConstraint("orderaccount.number","OrderAccount.number",null, LogFilter.FILTER_IDS);
addConstraint("orderaccount.subnumber","OrderAccount.subnumber","", LogFilter.FILTER_MOST);
addConstraint("orderaccount.blz","OrderAccount.KIK.blz",null, LogFilter.FILTER_MOST);
addConstraint("orderaccount.country","OrderAccount.KIK.country","DE", LogFilter.FILTER_NONE);

// willuhn 2011-05-17 wird noch nicht genutzt
// addConstraint("smsaccount.number","SMSAccount.number",null, LogFilter.FILTER_IDS);
// addConstraint("smsaccount.subnumber","SMSAccount.subnumber","", LogFilter.FILTER_MOST);
// addConstraint("smsaccount.blz","SMSAccount.KIK.blz",null, LogFilter.FILTER_MOST);
// addConstraint("smsaccount.country","SMSAccount.KIK.country","DE", LogFilter.FILTER_NONE);
}

public void setParam(String paramName, String value)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kapott/hbci/datatypes/SyntaxCtr.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static String getName(String x)
} else if (x.equals("978")) {
ret="EU";
} else {
HBCIUtils.log("unable to determine country code for: \"" + x + "\", fallback to DE",HBCIUtils.LOG_WARN);
HBCIUtils.log("unable to determine country code for: \"" + x + "\", fallback to DE",HBCIUtils.LOG_DEBUG);
ret = "DE";
}

Expand Down
157 changes: 157 additions & 0 deletions src/main/java/org/kapott/hbci/dialog/AbstractRawHBCIDialog.java
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();
}
}
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"));
}

}
Loading

0 comments on commit 500f075

Please sign in to comment.