Git Product home page Git Product logo

ibanity-java's Introduction

Java wrapper for the Ibanity API

Maven Central Build Status License Maintainability Security Reliability

This Java Client library offers various Services you can use in order to submit requests towards the Ibanity Platform.

Quick start

Configure the library using IbanityServiceBuilder.builder().

Minimal configuration values are:

  • The ibanity url
  • Your application private key
  • the passphrase for the private key
  • the application public certificate
    IbanityService ibanityServiceBuilder = IbanityServiceBuilder.builder()
            .ibanityApiEndpoint("https://api.ibanity.com")
            .tlsPrivateKey(myPrivateKey)
            .passphrase("aPassphrase")
            .tlsCertificate(myCertificate)
            .build();

You can then make use of Xs2a services through your IbanityService instance.

CustomerAccessTokenService customerAccessTokensService = ibanityService.xs2aService().customerAccessTokensService();

All services are thread safe and can be configured as singleton if you want to leverage frameworks like Spring.

See ClientSample class for extended examples.

Perform custom request to Ibanity

You can perform custom http calls to Ibanity using the IbanityHttpClient. It can be accessed by calling :

IbanityHttpClient ibanityHttpClient = ibanityService.ibanityHttpClient();

Configure proxy

If you are using a Web application firewall or a proxy, you can configure it in the IbanityServiceBuilder.

public interface OptionalPropertiesBuilder {

...

    OptionalPropertiesBuilder proxyEndpoint(String proxyEndpoint);

}
    IbanityService ibanityServiceBuilder = IbanityServiceBuilder.builder()
            .ibanityApiEndpoint("https://api.ibanity.com")
            .tlsPrivateKey(myPrivateKey)
            .passphrase("aPassphrase")
            .tlsCertificate(myCertificate)
            .proxyEndpoint("https://interal.proxy.com")
            .build();

Use HttpSignatureService

If you want to sign http request, you can use the HttpSignatureService from the library.

Instantiate the implementation class by calling:

IbanityHttpSignatureService = new IbanityHttpSignatureServiceImpl(
                                              privateKey,
                                              certificate,
                                              certificateId);
    public interface IbanityHttpSignatureService {
    
        /**
         * Alias to be used when the request has no payload.
         * @see IbanityHttpSignatureService#getHttpSignatureHeaders(String, URL, Map, String)
         * Allows you to create the needed headers to sign an http request following draft http signature
         * @see <a href="https://tools.ietf.org/html/draft-cavage-http-signatures-09">https://tools.ietf.org/html/draft-cavage-http-signatures-09</a>
         * @param httpMethod the http method of the current request.
         * @param url the url containing host, path and query parameters.
         * @param requestHeaders the headers of the current request. All ibanity-* headers will included in the signature.
         * @return the map with signature related headers: date, digest and signature headers.
         */
        Map<String, String> getHttpSignatureHeaders(String httpMethod, URL url, Map<String, String> requestHeaders);
    
        /**
         * Allows you to create the needed headers to sign an http request following draft http signature
         * @see <a href="https://tools.ietf.org/html/draft-cavage-http-signatures-09">https://tools.ietf.org/html/draft-cavage-http-signatures-09</a>
         * @param httpMethod the http method of the current request.
         * @param url the url containing host, path and query parameters.
         * @param requestHeaders the headers of the current request. All ibanity-* headers will included in the signature.
         * @param payload the payload of the actual request.
         * @return the map with signature related headers: date, digest and signature headers.
         */
        Map<String, String> getHttpSignatureHeaders(String httpMethod, URL url, Map<String, String> requestHeaders, String payload);

        /**
         * Allows you to create the needed headers to sign an http request following draft http signature
         * @see <a href="https://tools.ietf.org/html/draft-cavage-http-signatures-12">https://tools.ietf.org/html/draft-cavage-http-signatures-12</a>
         * @param httpMethod the http method of the current request.
         * @param url the url containing host, path and query parameters.
         * @param requestHeaders the headers of the current request. All ibanity-* headers will included in the signature.
         * @param payload the payload of the actual request as {@link java.io.File}.
         * @return the map with signature related headers: date, digest and signature headers.
         */
        Map<String, String> getHttpSignatureHeaders(String httpMethod, URL url, Map<String, String> requestHeaders, File payload);
    }

Add custom Http Interceptors

The library uses Apache HttpClient.

You can add your own HttpRequestInterceptor and HttpResponseInterceptor.

Configuring custom interceptors can be done through the IbanityServiceBuilder. They are optional.

public interface OptionalPropertiesBuilder {

...

    OptionalPropertiesBuilder withHttpRequestInterceptors(HttpRequestInterceptor... httpRequestInterceptor);

    OptionalPropertiesBuilder withHttpResponseInterceptors(HttpResponseInterceptor... httpResponseInterceptor);
}
        OptionalPropertiesBuilder ibanityServiceBuilder = IbanityServiceBuilder.builder()
                .ibanityApiEndpoint("https://api.ibanity.com")
                .tlsPrivateKey(privateKey)
                .passphrase(passphrase)
                .tlsCertificate(certificate)
                .withHttpRequestInterceptors((request, context) -> LOGGER.info("This is a HttpRequestInterceptor"))
                .withHttpResponseInterceptors((response, context) -> LOGGER.info("This is a HttpResponseInterceptor"));

Configure Http timeouts

The following Http timeouts can be configured

  • Connect Timeout (default 30 000 milliseconds)
  • Socket Timeout (default 30 000 milliseconds)
  • Connection Request Timeout (default 30 000 milliseconds)
public interface OptionalPropertiesBuilder {

...

    OptionalPropertiesBuilder socketTimeout(int socketTimeout);

    OptionalPropertiesBuilder connectTimeout(int connectTimeout);

    OptionalPropertiesBuilder connectionRequestTimeout(int connectionRequestTimeout);
}
        OptionalPropertiesBuilder ibanityServiceBuilder = IbanityServiceBuilder.builder()
                .ibanityApiEndpoint("https://api.ibanity.com")
                .tlsPrivateKey(privateKey)
                .passphrase(passphrase)
                .tlsCertificate(certificate)
                .connectTimeout(10_000)
                .socketTimeout(60_000)
                .connectionRequestTimeout(10_000);

Requirements

  • Java 8 (or above)
  • Maven (for compilation)

JCE Unlimited Strength Jurisdiction Policy Files

https://golb.hplar.ch/2017/10/JCE-policy-changes-in-Java-SE-8u151-and-8u152.html

ibanity-java's People

Contributors

damienbr avatar cleclefibanity avatar daniel-deluca avatar bramj avatar dependabot[bot] avatar bdusauso avatar detomarco avatar ghooghe avatar cmw0513 avatar thibaultponcelet avatar rjroos avatar

Stargazers

Julien avatar Loïc Mahieu avatar

Watchers

James Cloos avatar  avatar  avatar Jens avatar  avatar Kostas Georgiou avatar

ibanity-java's Issues

Include Request ID in IbanityException

Every request to Ibanity returns with a request ID which is often asked for when there are problems. However, currently there is no way to get this info out without enabling debug logging, which is way too much info for what we need.

It would be nice if you could add the request ID as field in the IbanityException so we easily retrieve and report it.

[Q] Does the SDK take care of Idempotency?

I am using the payment initiation in the SDK and see no option to provide an idempotency key. How is idempotency handled in the SDK?

In our case we have a microservice architecture and have a unique UUID for the payment initiation. An integrator service accepts requests from other services to initiate a payment. Those services behave in an at-least-once fashion in case they were unable to confirm the payment was initiated. In case multiple attempts were made, the idempotency key needs to be passed manually by us instead of a UUID controlled by the SDK. Is that possible currently?

meta authorizationPortal should not be mandatory

According to the API when creating an account information request, the meta/authorizationPortal should not be mandatory: https://documentation.ibanity.com/xs2a/api#create-account-information-access-request

When running my PACT tests, it says it is however: Expected meta={"authorizationPortal":{}} but was missing. Furthermore, it expects it to be inside the attributes object, instead of next to it:
{ "attributes": { "consentReference": "3d9afd39-e0cd-43c4-b0c0-63f5ca247ba7", "redirectUri": "https://some-redirect-uri.com", "allowFinancialInstitutionRedirectUri": false, "meta": { "authorizationPortal": {} }, "requestedAccountReferences": ["BE61732540451517"] }, "type": "accountInformationAccessRequest" }

I see two actions:

  • Please fix so that meta / authorizationPortal is not mandatory
  • Please fix so that meta is next to attributes and not inside attributes

Create Sample Client to manage IBanity API Sandbox Data

Through the IBanity APIs, there is the possibility to manage the various data such as Financial Institutions, Accounts, Transactions, Users
We need to create a Sample Client class that shows how to manage those resources

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.