Skip to content

Commit

Permalink
Fix Showcase API Client (#54)
Browse files Browse the repository at this point in the history
* Revert "fix: Add missing state parameter to authorization url"

This reverts commit 29e6a90.

* Revert "Revert "fix: Add missing state parameter to authorization url""

This reverts commit d3f05b2.

* fix: Fix showcase API client not working after swagger update
  • Loading branch information
alexandru-ionut-balan committed Oct 4, 2023
1 parent 072001b commit 3833049
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package com.ing.developer.app.apis.greetings;

import com.ing.developer.common.Utils;
import com.ing.developer.common.clients.Companion;
import com.ing.developer.showcase.client.ApiException;
import com.ing.developer.showcase.client.api.GreetingsApi;
import com.ing.developer.showcase.client.api.ShowcaseApiApi;
import org.springframework.stereotype.Component;

import java.security.PrivateKey;
import java.security.cert.Certificate;

import static com.ing.developer.app.common.GenericAdapterErrorHandler.throwInternalizedException;

@Component
public class GreetingsAdapter {

private final GreetingsApi greetingsApi;
private final ShowcaseApiApi greetingsApi;

public GreetingsAdapter(GreetingsApi greetingsApi) {
public GreetingsAdapter(ShowcaseApiApi greetingsApi) {
this.greetingsApi = greetingsApi;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.ing.developer.common.Utils;
import com.ing.developer.common.clients.Companion;
import com.ing.developer.showcase.client.ApiClient;
import com.ing.developer.showcase.client.api.GreetingsApi;
import com.ing.developer.showcase.client.api.ShowcaseApiApi;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;

Expand Down Expand Up @@ -33,8 +33,8 @@ public GreetingsConfiguration(Environment env) {
}

@Bean
public GreetingsApi greetingsApi() {
return new GreetingsApi(buildClient());
public ShowcaseApiApi greetingsApi() {
return new ShowcaseApiApi(buildClient());
}

private ApiClient buildClient() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.ing.developer.common.clients.Companion;
import com.ing.developer.showcase.client.ApiClient;
import com.ing.developer.showcase.client.ApiException;
import com.ing.developer.showcase.client.api.GreetingsApi;
import com.ing.developer.showcase.client.api.ShowcaseApiApi;

import javax.ws.rs.client.ClientBuilder;

Expand All @@ -23,15 +23,15 @@ public class PremiumShowcaseAPI {
public static void callShowcaseAPI() throws ApiException {
Utils.Pair<PrivateKey, ClientBuilder> trustMaterial = Companion.Utils.createOpenBankingClient(keyStoreFileName, keyStorePassword, false, null, null, false, false);
ApiClient clientAPI = new ApiClient(clientId, trustMaterial.getFirst(), trustMaterial.getSecond());
GreetingsApi greetingsApi = new GreetingsApi(clientAPI);
ShowcaseApiApi greetingsApi = new ShowcaseApiApi(clientAPI);
String greeting = greetingsApi.greetingsSingleGet(null).getMessage();
System.out.println(greeting);
}

public static void callShowcaseAPIMTLSPinning() throws ApiException {
Utils.Pair<PrivateKey, ClientBuilder> trustMaterial = Companion.Utils.createOpenBankingClient(keyStoreFileName, keyStorePassword, false, null, null, false, false);
ApiClient clientAPI = new ApiClient(clientId, trustMaterial.getFirst(), trustMaterial.getSecond()).setMTLSPinning(true);
GreetingsApi greetingsApi = new GreetingsApi(clientAPI);
ShowcaseApiApi greetingsApi = new ShowcaseApiApi(clientAPI);
String greeting = greetingsApi.mtlsOnlyGreetingsGet(null).getMessage();
System.out.println(greeting);
}
Expand All @@ -40,7 +40,7 @@ public static void callShowcaseAPIJWS() throws ApiException {
Utils.Pair<Certificate, PrivateKey> trustMaterial = Companion.Utils.getTrustMaterial(keyStoreFileName, keyStorePassword);
Utils.Pair<PrivateKey, ClientBuilder> openBankingClient = Companion.Utils.createOpenBankingClient(keyStoreFileName, keyStorePassword, false, null, null, false, false);
ApiClient clientAPI = new ApiClient(clientId, trustMaterial.getSecond(), openBankingClient.getSecond(), null, trustMaterial.getFirst()).setMTLSPinning(true).setJwsSigning(true);
GreetingsApi greetingsApi = new GreetingsApi(clientAPI);
ShowcaseApiApi greetingsApi = new ShowcaseApiApi(clientAPI);
String greeting = greetingsApi.signedGreetingsGet(null,null).getMessage();
System.out.println(greeting);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.ing.developer.common.clients.Companion;
import com.ing.developer.showcase.client.ApiClient;
import com.ing.developer.showcase.client.ApiException;
import com.ing.developer.showcase.client.api.GreetingsApi;
import com.ing.developer.showcase.client.api.ShowcaseApiApi;

import javax.ws.rs.client.ClientBuilder;
import java.security.PrivateKey;
Expand All @@ -21,7 +21,7 @@ public static void callShowcaseAPI() throws ApiException {

Utils.Pair<PrivateKey, ClientBuilder> trustMaterial = Companion.Utils.createOpenBankingClient(keyStoreFileName, keyStorePassword, false, null, null, false, false);
ApiClient clientAPI = new ApiClient(clientId, trustMaterial.getFirst(), trustMaterial.getSecond());
GreetingsApi greetingsApi = new GreetingsApi(clientAPI);
ShowcaseApiApi greetingsApi = new ShowcaseApiApi(clientAPI);
String greeting = greetingsApi.greetingsSingleGet(null).getMessage();
System.out.println(greeting);
}
Expand Down

0 comments on commit 3833049

Please sign in to comment.