use of com.axelor.apps.bankpayment.ebics.client.EbicsSession 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);
}
}
use of com.axelor.apps.bankpayment.ebics.client.EbicsSession 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);
}
}
use of com.axelor.apps.bankpayment.ebics.client.EbicsSession in project axelor-open-suite by axelor.
the class EbicsService method sendFULRequest.
/**
* Sends a file to the ebics bank sever
*
* @param path the file path to send
* @param userId the user ID that sends the file.
* @param product the application product.
* @throws AxelorException
*/
private void sendFULRequest(EbicsUser transportUser, EbicsUser signatoryUser, EbicsProduct product, File file, String format, File signature) throws AxelorException {
EbicsSession session = new EbicsSession(transportUser, signatoryUser);
boolean test = isTest(transportUser);
if (test) {
session.addSessionParam("TEST", "true");
}
if (file == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, "File is required to send FUL request");
}
EbicsPartner ebicsPartner = transportUser.getEbicsPartner();
if (ebicsPartner.getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS) {
if (signature == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, "Signature file is required to send FUL request");
}
if (signatoryUser == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, "Signatory user is required to send FUL request");
}
}
session.addSessionParam("EBCDIC", "false");
session.addSessionParam("FORMAT", format);
if (product == null) {
product = defaultProduct;
}
session.setProduct(product);
FileTransfer transferManager = new FileTransfer(session);
try {
if (ebicsPartner.getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS) {
transferManager.sendFile(IOUtils.getFileContent(file.getAbsolutePath()), OrderType.FUL, IOUtils.getFileContent(signature.getAbsolutePath()));
} else {
transferManager.sendFile(IOUtils.getFileContent(file.getAbsolutePath()), OrderType.FUL, null);
}
userService.getNextOrderId(transportUser);
} catch (IOException | AxelorException e) {
TraceBackService.trace(e);
throw new AxelorException(e, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR);
}
try {
if (ebicsPartner.getUsePSR()) {
sendFDLRequest(transportUser, product, null, null, ebicsPartner.getpSRBankStatementFileFormat().getStatementFileFormatSelect());
}
} catch (AxelorException e) {
TraceBackService.trace(e);
}
}
use of com.axelor.apps.bankpayment.ebics.client.EbicsSession 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);
}
}
use of com.axelor.apps.bankpayment.ebics.client.EbicsSession 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);
}
}
Aggregations