package me.teridax.jcash.gui.login; import me.teridax.jcash.banking.management.BankingManagementSystem; import me.teridax.jcash.banking.management.Profile; import java.util.Optional; /** * Wrapper class for a {@link BankingManagementSystem} */ public class LoginData { private final BankingManagementSystem bms; public LoginData(BankingManagementSystem bms) { this.bms = bms; } /** * authenticate the specified account with the provided pin. * @param blz the bank identifier * @param iban the account identifier * @param pin the pin for the account to authenticate with * @return an optional wrapping the specified account if authentication was successful */ public Optional authenticateAccount(String blz, int iban, int pin) { var optionalBank = bms.getBank(blz); if (optionalBank.isEmpty()) return Optional.empty(); var profile = optionalBank.get().getAccount(iban); return profile.filter(value -> value.getPrimaryAccount().getPin() == pin); } public BankingManagementSystem getBms() { return bms; } }