Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong bank public key digest at fetchFile #26

Open
cyrilfr opened this issue Oct 27, 2021 · 0 comments
Open

Wrong bank public key digest at fetchFile #26

cyrilfr opened this issue Oct 27, 2021 · 0 comments

Comments

@cyrilfr
Copy link

cyrilfr commented Oct 27, 2021

The bank public key digest retrieved from the configuration file is wrong when calling fetchFile() from EbicsClient for C54 (actually Z54) order type. In order to fix it, I had to add a very nasty call to bank.setDigests() using KeyUtil.getKeyDigest() to fix the digest on the fly in the method:

public void fetchFile(File file, User user, Product product, OrderType orderType,
    boolean isTest, Date start, Date end) throws IOException, EbicsException {
    FileTransfer transferManager;
    EbicsSession session = createSession(user, product);
    // ### FIX THE WRONG BANK PUBLIC KEYS DIGEST ###
    EbicsBank bank = session.getUser().getPartner().getBank();
    bank.setDigests(KeyUtil.getKeyDigest(bank.getE002Key()), KeyUtil.getKeyDigest(bank.getX002Key()));
    // #############################################
    session.addSessionParam("FORMAT", "pain.xxx.cfonb160.dct");
    if (isTest) {
        session.addSessionParam("TEST", "true");
    }
    transferManager = new FileTransfer(session);
    
    configuration.getTraceManager().setTraceDirectory(
        configuration.getTransferTraceDirectory(user));

    try {
        transferManager.fetchFile(orderType, start, end, file);
    } catch (NoDownloadDataAvailableException e) {
        // don't log this exception as an error, caller can decide how to handle
        throw e;
    } catch (Exception e) {
        configuration.getLogger().error(
            Messages.getString("download.file.error", Constants.APPLICATION_BUNDLE_NAME), e);
        throw e;
    }
}

It would be great to have a better solution if possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant