Search in sources :

Example 1 with KeyManagement

use of com.axelor.apps.bankpayment.ebics.client.KeyManagement in project axelor-open-suite by axelor.

the class EbicsService method sendSPRRequest.

/**
 * Sends the SPR order to the bank.
 *
 * @param userId the user ID
 * @param product the session product
 * @throws AxelorException
 */
@Transactional
public void sendSPRRequest(EbicsUser ebicsUser, EbicsProduct product) throws AxelorException {
    EbicsSession session = new EbicsSession(ebicsUser);
    if (product == null) {
        product = defaultProduct;
    }
    session.setProduct(product);
    KeyManagement keyManager = new KeyManagement(session);
    try {
        keyManager.lockAccess();
        ebicsUser.setStatusSelect(EbicsUserRepository.STATUS_WAITING_SENDING_SIGNATURE_CERTIFICATE);
        userService.getNextOrderId(ebicsUser);
        userRepo.save(ebicsUser);
    } catch (Exception e) {
        TraceBackService.trace(e);
        throw new AxelorException(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) KeyManagement(com.axelor.apps.bankpayment.ebics.client.KeyManagement) EbicsSession(com.axelor.apps.bankpayment.ebics.client.EbicsSession) InvalidKeySpecException(java.security.spec.InvalidKeySpecException) JDOMException(org.jdom.JDOMException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Transactional(com.google.inject.persist.Transactional)

Example 2 with KeyManagement

use of com.axelor.apps.bankpayment.ebics.client.KeyManagement in project axelor-open-suite by axelor.

the class EbicsService method sendINIRequest.

/**
 * Sends an INI request to the ebics bank server
 *
 * @param userId the user ID
 * @param product the application product
 * @throws AxelorException
 * @throws JDOMException
 * @throws IOException
 */
@Transactional
public void sendINIRequest(EbicsUser ebicsUser, EbicsProduct product) throws AxelorException {
    if (ebicsUser.getStatusSelect() != EbicsUserRepository.STATUS_WAITING_SENDING_SIGNATURE_CERTIFICATE) {
        return;
    }
    try {
        userService.getNextOrderId(ebicsUser);
        EbicsSession session = new EbicsSession(ebicsUser);
        if (product == null) {
            product = defaultProduct;
        }
        session.setProduct(product);
        KeyManagement keyManager = new KeyManagement(session);
        keyManager.sendINI();
        ebicsUser.setStatusSelect(EbicsUserRepository.STATUS_WAITING_AUTH_AND_ENCRYPT_CERTIFICATES);
        userRepo.save(ebicsUser);
    } catch (Exception e) {
        TraceBackService.trace(e);
        throw new AxelorException(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) KeyManagement(com.axelor.apps.bankpayment.ebics.client.KeyManagement) EbicsSession(com.axelor.apps.bankpayment.ebics.client.EbicsSession) InvalidKeySpecException(java.security.spec.InvalidKeySpecException) JDOMException(org.jdom.JDOMException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Transactional(com.google.inject.persist.Transactional)

Example 3 with KeyManagement

use of com.axelor.apps.bankpayment.ebics.client.KeyManagement in project axelor-open-suite by axelor.

the class EbicsService method sendHPBRequest.

/**
 * Sends a HPB request to the ebics server.
 *
 * @param userId the user ID.
 * @param product the application product.
 * @throws AxelorException
 */
@Transactional
public X509Certificate[] sendHPBRequest(EbicsUser user, EbicsProduct product) throws AxelorException {
    EbicsSession session = new EbicsSession(user);
    if (product == null) {
        product = defaultProduct;
    }
    session.setProduct(product);
    KeyManagement keyManager = new KeyManagement(session);
    try {
        return keyManager.sendHPB();
    } catch (Exception e) {
        TraceBackService.trace(e);
        throw new AxelorException(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) KeyManagement(com.axelor.apps.bankpayment.ebics.client.KeyManagement) EbicsSession(com.axelor.apps.bankpayment.ebics.client.EbicsSession) InvalidKeySpecException(java.security.spec.InvalidKeySpecException) JDOMException(org.jdom.JDOMException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Transactional(com.google.inject.persist.Transactional)

Example 4 with KeyManagement

use of com.axelor.apps.bankpayment.ebics.client.KeyManagement in project axelor-open-suite by axelor.

the class EbicsService method sendHIARequest.

/**
 * Sends a HIA request to the ebics server.
 *
 * @param userId the user ID.
 * @param product the application product.
 * @throws AxelorException
 */
@Transactional
public void sendHIARequest(EbicsUser ebicsUser, EbicsProduct product) throws AxelorException {
    if (ebicsUser.getStatusSelect() != EbicsUserRepository.STATUS_WAITING_AUTH_AND_ENCRYPT_CERTIFICATES) {
        return;
    }
    userService.getNextOrderId(ebicsUser);
    EbicsSession session = new EbicsSession(ebicsUser);
    if (product == null) {
        product = defaultProduct;
    }
    session.setProduct(product);
    KeyManagement keyManager = new KeyManagement(session);
    try {
        keyManager.sendHIA();
        ebicsUser.setStatusSelect(EbicsUserRepository.STATUS_ACTIVE_CONNECTION);
        userRepo.save(ebicsUser);
    } catch (IOException | AxelorException | JDOMException e) {
        TraceBackService.trace(e);
        throw new AxelorException(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) KeyManagement(com.axelor.apps.bankpayment.ebics.client.KeyManagement) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException) EbicsSession(com.axelor.apps.bankpayment.ebics.client.EbicsSession) Transactional(com.google.inject.persist.Transactional)

Aggregations

EbicsSession (com.axelor.apps.bankpayment.ebics.client.EbicsSession)4 KeyManagement (com.axelor.apps.bankpayment.ebics.client.KeyManagement)4 AxelorException (com.axelor.exception.AxelorException)4 Transactional (com.google.inject.persist.Transactional)4 IOException (java.io.IOException)4 JDOMException (org.jdom.JDOMException)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)3