This Java Client library offers various Services you can use in order to submit requests towards the Ibanity Platform.
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.
You can perform custom http calls to Ibanity using the IbanityHttpClient. It can be accessed by calling :
IbanityHttpClient ibanityHttpClient = ibanityService.ibanityHttpClient();
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();
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);
}
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"));
- Java 8 (or above)
- Maven (for compilation)
https://golb.hplar.ch/2017/10/JCE-policy-changes-in-Java-SE-8u151-and-8u152.html