use of com.axelor.apps.bankpayment.db.EbicsPartner in project axelor-open-suite by axelor.
the class EbicsUserService method getNextOrderId.
@Transactional
public String getNextOrderId(EbicsUser user) throws AxelorException {
String orderId = user.getNextOrderId();
if (orderId == null) {
EbicsPartner partner = user.getEbicsPartner();
EbicsUser otherUser = ebicsUserRepo.all().filter("self.ebicsPartner = ?1 and self.id != ?2 and self.nextOrderId != null", partner, user.getId()).order("-nextOrderId").fetchOne();
char firstLetter = 'A';
if (otherUser != null) {
String otherOrderId = otherUser.getNextOrderId();
firstLetter = otherOrderId.charAt(0);
firstLetter++;
}
orderId = String.valueOf(firstLetter) + "000";
user.setNextOrderId(orderId);
ebicsUserRepo.save(user);
} else {
orderId = getNextOrderNumber(orderId);
user.setNextOrderId(orderId);
ebicsUserRepo.save(user);
}
return orderId;
}
use of com.axelor.apps.bankpayment.db.EbicsPartner in project axelor-open-suite by axelor.
the class CertificateManager method create.
/**
* Creates the certificates for the user
*
* @throws GeneralSecurityException
* @throws IOException
*/
public void create() throws GeneralSecurityException, IOException {
Calendar calendar;
calendar = Calendar.getInstance();
calendar.add(Calendar.YEAR, user.getEbicsPartner().getEbicsBank().getCertValidityPeriodSelect());
org.apache.xml.security.Init.init();
java.security.Security.addProvider(new BouncyCastleProvider());
EbicsPartner ebicsPartner = user.getEbicsPartner();
if ((user.getUserTypeSelect() == EbicsUserRepository.USER_TYPE_TRANSPORT && ebicsPartner.getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS) || ebicsPartner.getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_T) {
createA005Certificate(new Date(calendar.getTimeInMillis()));
}
createX002Certificate(new Date(calendar.getTimeInMillis()));
createE002Certificate(new Date(calendar.getTimeInMillis()));
setUserCertificates();
}
use of com.axelor.apps.bankpayment.db.EbicsPartner in project axelor-open-suite by axelor.
the class CertificateManager method setUserCertificates.
/**
* Sets the user certificates
*
* @throws IOException
* @throws CertificateEncodingException
*/
private void setUserCertificates() throws IOException, CertificateEncodingException {
EbicsPartner ebicsPartner = user.getEbicsPartner();
if ((user.getUserTypeSelect() == EbicsUserRepository.USER_TYPE_TRANSPORT && ebicsPartner.getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_TS) || ebicsPartner.getEbicsTypeSelect() == EbicsPartnerRepository.EBICS_TYPE_T) {
user.setA005Certificate(updateCertificate(a005Certificate, user.getA005Certificate(), a005PrivateKey.getEncoded(), EbicsCertificateRepository.TYPE_SIGNATURE));
}
user.setX002Certificate(updateCertificate(x002Certificate, user.getX002Certificate(), x002PrivateKey.getEncoded(), EbicsCertificateRepository.TYPE_AUTHENTICATION));
user.setE002Certificate(updateCertificate(e002Certificate, user.getE002Certificate(), e002PrivateKey.getEncoded(), EbicsCertificateRepository.TYPE_ENCRYPTION));
}
use of com.axelor.apps.bankpayment.db.EbicsPartner in project axelor-open-suite by axelor.
the class EbicsPartnerController method getBankStatement.
public void getBankStatement(ActionRequest request, ActionResponse response) {
try {
EbicsPartner ebicsPartner = request.getContext().asType(EbicsPartner.class);
List<BankStatement> bankStatementList = Beans.get(EbicsPartnerService.class).getBankStatements(Beans.get(EbicsPartnerRepository.class).find(ebicsPartner.getId()));
response.setFlash(String.format(I18n.get("%s bank statements get."), bankStatementList.size()));
} catch (Exception e) {
TraceBackService.trace(response, e);
}
response.setReload(true);
}
use of com.axelor.apps.bankpayment.db.EbicsPartner in project axelor-open-suite by axelor.
the class DInitializationRequestElement method buildInitialization.
@Override
public void buildInitialization() throws AxelorException {
EbicsRequest request;
Header header;
Body body;
MutableHeaderType mutable;
StaticHeaderType xstatic;
Product product;
BankPubKeyDigests bankPubKeyDigests;
Authentication authentication;
Encryption encryption;
OrderType orderType;
StaticHeaderOrderDetailsType orderDetails;
mutable = EbicsXmlFactory.createMutableHeaderType("Initialisation", null);
product = EbicsXmlFactory.createProduct(session.getProduct().getLanguage(), session.getProduct().getName());
authentication = EbicsXmlFactory.createAuthentication("X002", "http://www.w3.org/2001/04/xmlenc#sha256", decodeHex(KeyUtil.getKeyDigest(session.getBankX002Key())));
encryption = EbicsXmlFactory.createEncryption("E002", "http://www.w3.org/2001/04/xmlenc#sha256", decodeHex(KeyUtil.getKeyDigest(session.getBankE002Key())));
bankPubKeyDigests = EbicsXmlFactory.createBankPubKeyDigests(authentication, encryption);
orderType = EbicsXmlFactory.createOrderType(type.getOrderType());
EbicsUser ebicsUser = session.getUser();
EbicsPartner ebicsPartner = ebicsUser.getEbicsPartner();
OrderAttribute orderAttribute = new OrderAttribute(type, ebicsPartner.getEbicsTypeSelect());
orderAttribute.build();
if (type.equals(com.axelor.apps.bankpayment.ebics.client.OrderType.FDL)) {
FDLOrderParamsType fDLOrderParamsType;
FileFormatType fileFormat;
fileFormat = EbicsXmlFactory.createFileFormatType(Locale.FRANCE.getCountry().toUpperCase(), session.getSessionParam("FORMAT"));
fDLOrderParamsType = EbicsXmlFactory.createFDLOrderParamsType(fileFormat);
if (startRange != null && endRange != null) {
DateRange range;
range = EbicsXmlFactory.createDateRange(startRange, endRange);
fDLOrderParamsType.setDateRange(range);
}
if (Boolean.getBoolean(session.getSessionParam("TEST"))) {
Parameter parameter;
Value value;
value = EbicsXmlFactory.createValue("String", "TRUE");
parameter = EbicsXmlFactory.createParameter("TEST", value);
fDLOrderParamsType.setParameterArray(new Parameter[] { parameter });
}
orderDetails = EbicsXmlFactory.createStaticHeaderOrderDetailsType(ebicsUser.getNextOrderId(), orderAttribute.getOrderAttributes(), orderType, fDLOrderParamsType);
} else {
StandardOrderParamsType standardOrderParamsType;
standardOrderParamsType = EbicsXmlFactory.createStandardOrderParamsType();
// FIXME Some banks cannot handle OrderID element in download process. Add parameter in
// configuration!!!
orderDetails = EbicsXmlFactory.createStaticHeaderOrderDetailsType(// session.getUser().getPartner().nextOrderId(),
ebicsUser.getNextOrderId(), orderAttribute.getOrderAttributes(), orderType, standardOrderParamsType);
}
xstatic = EbicsXmlFactory.createStaticHeaderType(session.getBankID(), nonce, ebicsPartner.getPartnerId(), product, ebicsUser.getSecurityMedium(), ebicsUser.getUserId(), Calendar.getInstance(), orderDetails, bankPubKeyDigests);
header = EbicsXmlFactory.createEbicsRequestHeader(true, mutable, xstatic);
body = EbicsXmlFactory.createEbicsRequestBody();
request = EbicsXmlFactory.createEbicsRequest(1, "H003", header, body);
document = EbicsXmlFactory.createEbicsRequestDocument(request);
}
Aggregations