From fdd5eb8f516d5524bf6e4a1eb91f41abb385398c Mon Sep 17 00:00:00 2001 From: Shrikant Garg1 Date: Fri, 1 Jul 2022 15:46:29 +0530 Subject: [PATCH 1/3] added keycloak change --- provider/indexer-ibm/pom.xml | 2 +- .../osdu/indexer/ibm/util/KeyCloakProvider.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/provider/indexer-ibm/pom.xml b/provider/indexer-ibm/pom.xml index 1c1c36c0..02197ee1 100644 --- a/provider/indexer-ibm/pom.xml +++ b/provider/indexer-ibm/pom.xml @@ -31,7 +31,7 @@ jar - 0.15.2 + 0.16.0-rc1 diff --git a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/KeyCloakProvider.java b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/KeyCloakProvider.java index 6a2d2918..7f1056cc 100644 --- a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/KeyCloakProvider.java +++ b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/KeyCloakProvider.java @@ -42,8 +42,18 @@ public class KeyCloakProvider { @Value("${ibm.keycloak.client_secret}") private String clientSecret; + @Value("${partition.keycloak.accept_http:false}") + private boolean accept_kc_http; + + public String getToken(String user, String password) throws IOException { String endpoint = String.format("https://%s/auth/realms/%s/protocol/openid-connect/token", url, realm); + if(accept_kc_http) + { + endpoint = String.format("http://%s/auth/realms/%s/protocol/openid-connect/token", url, realm); + + } + URL url = new URL(endpoint); HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); con.setRequestMethod("POST"); -- GitLab From ef8a923e5530272cb58e5d152e3b4ab6c12b0786 Mon Sep 17 00:00:00 2001 From: Shrikant Garg1 Date: Fri, 1 Jul 2022 16:22:10 +0530 Subject: [PATCH 2/3] review comment added --- .../org/opengroup/osdu/indexer/ibm/util/KeyCloakProvider.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/KeyCloakProvider.java b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/KeyCloakProvider.java index 7f1056cc..b3a35928 100644 --- a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/KeyCloakProvider.java +++ b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/KeyCloakProvider.java @@ -13,7 +13,7 @@ import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; -import javax.net.ssl.HttpsURLConnection; +import java.net.HttpURLConnection; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -55,7 +55,7 @@ public class KeyCloakProvider { } URL url = new URL(endpoint); - HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); + HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); -- GitLab From 9714bd63f844ec851f4b6a62432f366bbe6b7fc8 Mon Sep 17 00:00:00 2001 From: Shrikant Garg1 Date: Fri, 1 Jul 2022 16:32:40 +0530 Subject: [PATCH 3/3] reverting pom changes --- provider/indexer-ibm/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provider/indexer-ibm/pom.xml b/provider/indexer-ibm/pom.xml index 02197ee1..1c1c36c0 100644 --- a/provider/indexer-ibm/pom.xml +++ b/provider/indexer-ibm/pom.xml @@ -31,7 +31,7 @@ jar - 0.16.0-rc1 + 0.15.2 -- GitLab