Search in sources :

Example 6 with EbicsPartner

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;
}
Also used : EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) EbicsPartner(com.axelor.apps.bankpayment.db.EbicsPartner) Transactional(com.google.inject.persist.Transactional)

Example 7 with EbicsPartner

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();
}
Also used : Calendar(java.util.Calendar) EbicsPartner(com.axelor.apps.bankpayment.db.EbicsPartner) Date(java.util.Date) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider)

Example 8 with EbicsPartner

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));
}
Also used : EbicsPartner(com.axelor.apps.bankpayment.db.EbicsPartner)

Example 9 with EbicsPartner

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);
}
Also used : BankStatement(com.axelor.apps.bankpayment.db.BankStatement) EbicsPartnerService(com.axelor.apps.bankpayment.ebics.service.EbicsPartnerService) EbicsPartner(com.axelor.apps.bankpayment.db.EbicsPartner)

Example 10 with EbicsPartner

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);
}
Also used : EbicsRequest(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest) FileFormatType(com.axelor.apps.account.ebics.schema.h003.FileFormatType) StandardOrderParamsType(com.axelor.apps.account.ebics.schema.h003.StandardOrderParamsType) EbicsUser(com.axelor.apps.bankpayment.db.EbicsUser) FDLOrderParamsType(com.axelor.apps.account.ebics.schema.h003.FDLOrderParamsType) Product(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.Product) StaticHeaderOrderDetailsType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType) StaticHeaderType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType) Encryption(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Encryption) EbicsPartner(com.axelor.apps.bankpayment.db.EbicsPartner) BankPubKeyDigests(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests) MutableHeaderType(com.axelor.apps.account.ebics.schema.h003.MutableHeaderType) DateRange(com.axelor.apps.account.ebics.schema.h003.FDLOrderParamsType.DateRange) OrderType(com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType.OrderType) Header(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header) Authentication(com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Authentication) Value(com.axelor.apps.account.ebics.schema.h003.ParameterDocument.Parameter.Value) OrderAttribute(com.axelor.apps.bankpayment.ebics.client.OrderAttribute) Parameter(com.axelor.apps.account.ebics.schema.h003.ParameterDocument.Parameter) Body(com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)

Aggregations

EbicsPartner (com.axelor.apps.bankpayment.db.EbicsPartner)13 EbicsUser (com.axelor.apps.bankpayment.db.EbicsUser)7 OrderAttribute (com.axelor.apps.bankpayment.ebics.client.OrderAttribute)4 EbicsRequest (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest)3 Body (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Body)3 Header (com.axelor.apps.account.ebics.schema.h003.EbicsRequestDocument.EbicsRequest.Header)3 MutableHeaderType (com.axelor.apps.account.ebics.schema.h003.MutableHeaderType)3 StaticHeaderOrderDetailsType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType)3 OrderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderOrderDetailsType.OrderType)3 StaticHeaderType (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType)3 BankPubKeyDigests (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests)3 Authentication (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Authentication)3 Encryption (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.BankPubKeyDigests.Encryption)3 Product (com.axelor.apps.account.ebics.schema.h003.StaticHeaderType.Product)3 BankStatement (com.axelor.apps.bankpayment.db.BankStatement)3 AxelorException (com.axelor.exception.AxelorException)3 EncryptionPubKeyDigest (com.axelor.apps.account.ebics.schema.h003.DataEncryptionInfoType.EncryptionPubKeyDigest)2 DataTransferRequestType (com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType)2 DataEncryptionInfo (com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType.DataEncryptionInfo)2 SignatureData (com.axelor.apps.account.ebics.schema.h003.DataTransferRequestType.SignatureData)2