using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Security.Cryptography; using Kreta.Core.Configuratiaton; using Kreta.Core.Logic; using Kreta.DataAccessManual.ParameterClasses; using Kreta.Job.Tasks.Core; namespace Kreta.Job.Tasks { public class OtpBankszamlaIgenylesJob : BankszamlaIgenylesJob, IOtpBankszamlaIgenylesJob { private readonly string OTP_IN = "\\OTP_IN\\"; private readonly string OTP_ERROR = "\\OTP_ERROR\\"; private readonly string OTP_OK = "\\OTP_OK\\"; private readonly string OTP_ARCHIVE = "\\OTP_ARCHIVE\\"; public void OtpBankszamlaIgenyles() { RunBankszamlaIgenylesJob(); } protected override string GetArchivePart() { return OTP_ARCHIVE; } protected override string GetErrorPart() { return OTP_ERROR; } protected override string GetInPart() { return OTP_IN; } protected override string GetOkPart() { return OTP_OK; } protected override bool HasRowWithError(List bankszamlaIgenylesPcos) { // NOTE: OTP esetén csak akkor kell küldeni email-t, ha van hibás sor a feldolgozott állományban. return bankszamlaIgenylesPcos.Any(x => x.IsError); } protected override string DecryptEgyediAzonosito(string receivedEgyediAzonosito) { // NOTE: az OTP a titkosított tokent küldi vissza az egyedi azonosítóban, ezért azt decrypt-álni kell var configuration = (OtpBankszamlaIgenylesConfiguration)ConfigurationManager.GetSection(nameof(OtpBankszamlaIgenylesConfiguration)); if (string.IsNullOrWhiteSpace(receivedEgyediAzonosito)) { return ""; } try { return UrlLogic.JweDecrypt(configuration.PrivateKeyFileName, configuration.PrivateKeyFilePassword, receivedEgyediAzonosito); } catch (CryptographicException ex) { return "-"; } catch (ArgumentOutOfRangeException aorex) { return "-"; } } } }