use of com.axelor.apps.bankpayment.db.EbicsBank in project axelor-open-suite by axelor.
the class CertificateManager method createX002Certificate.
/**
* Creates the authentication certificate.
*
* @param the expiration date of a the certificate.
* @throws GeneralSecurityException
* @throws IOException
*/
public void createX002Certificate(Date end) throws GeneralSecurityException, IOException {
KeyPair keypair = KeyUtil.makeKeyPair(X509Constants.EBICS_KEY_SIZE);
EbicsBank ebicsBank = user.getEbicsPartner().getEbicsBank();
x002Certificate = generator.generateX002Certificate(keypair, user.getDn(), new Date(), end, ebicsBank.getUseX509ExtensionBasicConstraints(), ebicsBank.getUseX509ExtensionSubjectKeyIdentifier(), ebicsBank.getUseX509ExtensionAuthorityKeyIdentifier(), ebicsBank.getUseX509ExtensionExtendedKeyUsage());
x002PrivateKey = keypair.getPrivate();
}
use of com.axelor.apps.bankpayment.db.EbicsBank in project axelor-open-suite by axelor.
the class CertificateManager method createA005Certificate.
/**
* Creates the signature certificate.
*
* @param the expiration date of a the certificate.
* @throws GeneralSecurityException
* @throws IOException
*/
public void createA005Certificate(Date end) throws GeneralSecurityException, IOException {
KeyPair keypair = KeyUtil.makeKeyPair(X509Constants.EBICS_KEY_SIZE);
EbicsBank ebicsBank = user.getEbicsPartner().getEbicsBank();
a005Certificate = generator.generateA005Certificate(keypair, user.getDn(), new Date(), end, ebicsBank.getUseX509ExtensionBasicConstraints(), ebicsBank.getUseX509ExtensionSubjectKeyIdentifier(), ebicsBank.getUseX509ExtensionAuthorityKeyIdentifier(), ebicsBank.getUseX509ExtensionExtendedKeyUsage());
a005PrivateKey = keypair.getPrivate();
}
use of com.axelor.apps.bankpayment.db.EbicsBank in project axelor-open-suite by axelor.
the class HttpRequestSender method send.
/**
* Sends the request contained in the <code>ContentFactory</code>. The <code>ContentFactory</code>
* will deliver the request as an <code>InputStream</code>.
*
* @param request the ebics request
* @return the HTTP return code
* @throws AxelorException
*/
public final int send(ContentFactory request) throws IOException, AxelorException {
EbicsBank bank = session.getUser().getEbicsPartner().getEbicsBank();
String url = bank.getUrl();
if (url == null || !url.startsWith("http://") && !url.startsWith("https://")) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.EBICS_INVALID_BANK_URL));
}
if (bank.getProtocolSelect().equals("ssl")) {
return sendSSL(request, bank);
} else {
return sendTLS(request, bank);
}
}
use of com.axelor.apps.bankpayment.db.EbicsBank 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.EbicsBank in project axelor-open-suite by axelor.
the class EbicsController method confirmCertificates.
private void confirmCertificates(EbicsUser user, X509Certificate[] certificates, ActionResponse response) {
try {
EbicsBank bank = user.getEbicsPartner().getEbicsBank();
response.setView(ActionView.define("Confirm certificates").model("com.axelor.apps.bankpayment.db.EbicsCertificate").add("form", "ebics-certificate-confirmation-form").param("show-toolbar", "false").param("show-confirm", "false").param("popup-save", "false").param("popup", "true").context("ebicsBank", bank).context("url", bank.getUrl()).context("hostId", bank.getHostId()).context("e002Hash", DigestUtils.sha256Hex(certificates[0].getEncoded()).toUpperCase()).context("x002Hash", DigestUtils.sha256Hex(certificates[1].getEncoded()).toUpperCase()).context("certificateE002", Beans.get(EbicsCertificateService.class).convertToPEMString(certificates[0])).context("certificateX002", Beans.get(EbicsCertificateService.class).convertToPEMString(certificates[1])).map());
} catch (Exception e) {
response.setFlash("Error in certificate confirmation ");
}
}
Aggregations