use of com.axelor.apps.bankpayment.db.EbicsCertificate in project axelor-open-suite by axelor.
the class BatchEbicsCertificate method process.
@Override
protected void process() {
Template template = templateRepo.find(bankPaymentBatch.getTemplate().getId());
List<EbicsUser> users = Beans.get(EbicsUserRepository.class).all().filter("self.a005Certificate != null OR self.e002Certificate != null OR self.x002Certificate != null").fetch();
Set<EbicsCertificate> certificatesSet = new HashSet<>();
LocalDate today = Beans.get(AppBaseService.class).getTodayDate(bankPaymentBatch.getCompany());
LocalDate commingDay = today.plusDays(bankPaymentBatch.getDaysNbr());
for (EbicsUser user : users) {
if (user.getA005Certificate() != null && user.getA005Certificate().getValidTo().isBefore(commingDay)) {
certificatesSet.add(user.getA005Certificate());
}
if (user.getE002Certificate() != null && user.getE002Certificate().getValidTo().isBefore(commingDay)) {
certificatesSet.add(user.getE002Certificate());
}
if (user.getX002Certificate() != null && user.getX002Certificate().getValidTo().isBefore(commingDay)) {
certificatesSet.add(user.getX002Certificate());
}
}
certificatesSet.addAll(Beans.get(EbicsCertificateRepository.class).all().filter("self.ebicsBank != null AND self.validTo <= ?1", commingDay).fetch());
for (EbicsCertificate certificate : certificatesSet) {
certificate.addBatchSetItem(batchRepo.find(batch.getId()));
try {
templateMessageService.generateMessage(certificate, template);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | AxelorException | IOException e) {
e.printStackTrace();
}
}
}
use of com.axelor.apps.bankpayment.db.EbicsCertificate in project axelor-open-suite by axelor.
the class EbicsUserImport method importEbicsUser.
public Object importEbicsUser(Object bean, Map<String, Object> context) {
assert bean instanceof EbicsUser;
EbicsUser user = (EbicsUser) bean;
updateCertificate(user.getA005Certificate());
updateCertificate(user.getE002Certificate());
updateCertificate(user.getX002Certificate());
EbicsPartner partner = user.getEbicsPartner();
if (partner != null) {
EbicsBank ebicsBank = partner.getEbicsBank();
if (ebicsBank.getVersion() == 0) {
for (EbicsCertificate cert : ebicsBank.getEbicsCertificateList()) {
updateCertificate(cert);
}
Bank bank = ebicsBank.getBank();
if (bank.getVersion() == 0) {
bankService.computeFullName(bank);
bankService.splitBic(bank);
}
}
}
return user;
}
use of com.axelor.apps.bankpayment.db.EbicsCertificate in project axelor-open-suite by axelor.
the class UserSignatureVerify method loadCertificate.
public void loadCertificate() {
EbicsCertificate certificate = user.getA005Certificate();
this.modulus = certificate.getPublicKeyModulus();
this.exponent = certificate.getPublicKeyExponent();
}
use of com.axelor.apps.bankpayment.db.EbicsCertificate in project axelor-open-suite by axelor.
the class CertificateManager method updateCertificate.
private EbicsCertificate updateCertificate(X509Certificate certificate, EbicsCertificate cert, byte[] privateKey, String type) throws CertificateEncodingException, IOException {
if (cert == null) {
cert = new EbicsCertificate();
cert.setTypeSelect(type);
}
EbicsCertificateService certificateService = Beans.get(EbicsCertificateService.class);
cert = certificateService.updateCertificate(certificate, cert, true);
cert.setPrivateKey(privateKey);
return cert;
}
use of com.axelor.apps.bankpayment.db.EbicsCertificate in project axelor-open-suite by axelor.
the class EbicsCertificateService method createCertificate.
@Transactional
public EbicsCertificate createCertificate(X509Certificate certificate, EbicsBank bank, String type) throws CertificateEncodingException, IOException {
EbicsCertificate cert = getEbicsCertificate(bank, type);
if (cert == null) {
log.debug("Creating bank certicate for bank: {}, type: {}", bank.getName(), type);
cert = new EbicsCertificate();
cert.setEbicsBank(bank);
cert.setTypeSelect(type);
}
cert = updateCertificate(certificate, cert, true);
return certRepo.save(cert);
}
Aggregations