From a616a97e0759a1d949cd9b640c36a73a2faf34be Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Mon, 10 May 2021 15:18:14 +0200 Subject: [PATCH 1/5] IAM integration --- .project | 23 --------------- CHANGELOG.md | 4 +++ pom.xml | 4 +-- .../transfer/library/utils/ScopeUtils.java | 29 ++----------------- .../transfer/library/TestClientCalls.java | 11 +++++-- 5 files changed, 17 insertions(+), 54 deletions(-) delete mode 100644 .project diff --git a/.project b/.project deleted file mode 100644 index cdb05cd..0000000 --- a/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - data-transfer-library - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f4d4fc..628ce97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm # Changelog for org.gcube.data.transfer.data-transfer-library +##[v1.3.0-SNAPSHOT] 2020-12-01 +* Upgraded integration with security layer + + ##[v1.2.3] 2020-12-01 * Deletion method diff --git a/pom.xml b/pom.xml index 545ab22..002e4a6 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ org.gcube.data.transfer data-transfer-library - 1.2.3 + 1.3.0-SNAPSHOT DataTransfer-library Data Transfer Service client library @@ -30,7 +30,7 @@ org.gcube.distribution gcube-bom - 2.0.0 + 2.0.1 pom import diff --git a/src/main/java/org/gcube/data/transfer/library/utils/ScopeUtils.java b/src/main/java/org/gcube/data/transfer/library/utils/ScopeUtils.java index ffad458..0905635 100644 --- a/src/main/java/org/gcube/data/transfer/library/utils/ScopeUtils.java +++ b/src/main/java/org/gcube/data/transfer/library/utils/ScopeUtils.java @@ -1,40 +1,17 @@ package org.gcube.data.transfer.library.utils; -import org.gcube.common.authorization.library.AuthorizationEntry; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; +import org.gcube.common.authorization.library.provider.AuthorizationProvider; import org.gcube.common.scope.api.ScopeProvider; -import static org.gcube.common.authorization.client.Constants.authorizationService; -import lombok.extern.slf4j.Slf4j; - -@Slf4j public class ScopeUtils { public static String getCurrentScope(){ - try{ - String token=SecurityTokenProvider.instance.get(); - log.debug("Token is : "+token); - if(token==null) throw new Exception("Security Token is null"); - AuthorizationEntry entry = authorizationService().get(token); - return entry.getContext(); - }catch(Exception e ){ - log.debug("Unable to resolve token, checking scope provider..",e); - return ScopeProvider.instance.get(); - } + return ScopeProvider.instance.get(); } public static String getCurrentCaller(){ - try{ - String token=SecurityTokenProvider.instance.get(); - log.debug("Token is : "+token); - if(token==null) throw new Exception("Security Token is null"); - AuthorizationEntry entry = authorizationService().get(token); - return entry.getClientInfo().getId(); - }catch(Exception e ){ - log.debug("Unable to resolve token, checking scope provider..",e); - return "Unidentified data-transfer user"; - } + return AuthorizationProvider.instance.get().getClient().getId(); } } diff --git a/src/test/java/org/gcube/data/transfer/library/TestClientCalls.java b/src/test/java/org/gcube/data/transfer/library/TestClientCalls.java index f31c84b..6ad4ab2 100644 --- a/src/test/java/org/gcube/data/transfer/library/TestClientCalls.java +++ b/src/test/java/org/gcube/data/transfer/library/TestClientCalls.java @@ -29,16 +29,21 @@ import org.junit.Test; public class TestClientCalls { -// static String scope="/pred4s/preprod/preVRE"; -// static String hostname="https://thredds-pre-d4s.d4science.org"; - static String hostname="https://geoserver1.dev.d4science.org"; + static String scope="/gcube/devsec/devVRE"; + +// static String scope="/pred4s/preprod/preVRE"; + static String hostname="https://thredds.dev.d4science.org"; +// static String hostname="https://geona-proto.d4science.org"; +// static String scope="/d4science.research-infrastructures.eu/D4OS/GeoNA-Prototype"; static Client client; static long testRun=System.currentTimeMillis(); @BeforeClass public static void init() throws ServiceNotFoundException{ TokenSetter.set(scope); +// String hostname= +// new URL(SDIAbstractPlugin.management().build().getConfiguration().getByEngine(Engine.TH_ENGINE).get(0).getBaseEndpoint()).getHost(); client=new Client(hostname); } From 2efb5d0d36e3a9b33cdf7de854abd64947c005aa Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Mon, 10 May 2021 15:51:27 +0200 Subject: [PATCH 2/5] Fixes #20752 --- CHANGELOG.md | 1 + .../data/transfer/library/transferers/TransfererBuilder.java | 2 +- .../java/org/gcube/data/transfer/library/utils/Utils.java | 2 +- .../java/org/gcube/data/transfer/library/TransfererTest.java | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 628ce97..1a12c91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ##[v1.3.0-SNAPSHOT] 2020-12-01 * Upgraded integration with security layer +* Removed http [#20752] ##[v1.2.3] 2020-12-01 diff --git a/src/main/java/org/gcube/data/transfer/library/transferers/TransfererBuilder.java b/src/main/java/org/gcube/data/transfer/library/transferers/TransfererBuilder.java index 17ac1ca..5f1f470 100644 --- a/src/main/java/org/gcube/data/transfer/library/transferers/TransfererBuilder.java +++ b/src/main/java/org/gcube/data/transfer/library/transferers/TransfererBuilder.java @@ -75,7 +75,7 @@ public class TransfererBuilder { if(found.isEmpty()) throw new HostingNodeNotFoundException("No Hosting node with the id "+nodeId); - return "http://"+found.get(0).profile().description().name(); + return "https://"+found.get(0).profile().description().name(); } private static String resolveRedirects(String url) throws IOException{ diff --git a/src/main/java/org/gcube/data/transfer/library/utils/Utils.java b/src/main/java/org/gcube/data/transfer/library/utils/Utils.java index 0c7043f..3fe7a8d 100644 --- a/src/main/java/org/gcube/data/transfer/library/utils/Utils.java +++ b/src/main/java/org/gcube/data/transfer/library/utils/Utils.java @@ -17,7 +17,7 @@ public class Utils { * given timeout, otherwise false. */ public static boolean pingURL(String url, int timeout) { - url = url.replaceFirst("^https", "http"); // Otherwise an exception may be thrown on invalid SSL certificates. + // url = url.replaceFirst("^https", "http"); // Otherwise an exception may be thrown on invalid SSL certificates. try { HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); diff --git a/src/test/java/org/gcube/data/transfer/library/TransfererTest.java b/src/test/java/org/gcube/data/transfer/library/TransfererTest.java index 9d22e9e..4527bc1 100644 --- a/src/test/java/org/gcube/data/transfer/library/TransfererTest.java +++ b/src/test/java/org/gcube/data/transfer/library/TransfererTest.java @@ -32,13 +32,13 @@ import org.junit.Test; public class TransfererTest { - static String hostname="http://geoserver1.dev.d4science.org"; + static String hostname="https://geoserver1.dev.d4science.org"; // static String nodeId="462b68c5-463f-4295-86da-37d6c0abc7ea"; static String scope="/gcube/devNext/NextNext"; static DataTransferClient client; - static String link="http://maven.research-infrastructures.eu/nexus/content/groups/gcube-releases-all/org/gcube/data/transfer/data-transfer-model/1.0.0-3.11.0-128236/data-transfer-model-1.0.0-3.11.0-128236-javadoc.jar"; + static String link="https://nexus.d4science.org/nexus/content/groups/gcube-releases-all/org/gcube/data/transfer/data-transfer-model/1.0.0-3.11.0-128236/data-transfer-model-1.0.0-3.11.0-128236-javadoc.jar"; static File tempFile; From 43ad32af0326d79f1fd04cfe7c6734afe84c22e0 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Tue, 11 May 2021 16:48:24 +0200 Subject: [PATCH 3/5] legacy compatibility --- .../transfer/library/utils/ScopeUtils.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/data/transfer/library/utils/ScopeUtils.java b/src/main/java/org/gcube/data/transfer/library/utils/ScopeUtils.java index 0905635..9ca9b90 100644 --- a/src/main/java/org/gcube/data/transfer/library/utils/ScopeUtils.java +++ b/src/main/java/org/gcube/data/transfer/library/utils/ScopeUtils.java @@ -1,9 +1,15 @@ package org.gcube.data.transfer.library.utils; import org.gcube.common.authorization.library.provider.AuthorizationProvider; +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.scope.api.ScopeProvider; +import static org.gcube.common.authorization.client.Constants.authorizationService; + +import lombok.extern.slf4j.Slf4j; + +@Slf4j public class ScopeUtils { public static String getCurrentScope(){ @@ -12,6 +18,19 @@ public class ScopeUtils { public static String getCurrentCaller(){ - return AuthorizationProvider.instance.get().getClient().getId(); + try{ + return AuthorizationProvider.instance.get().getClient().getId(); + }catch(Throwable e ){ + try { + log.warn("Unable to get Client ID from UMA , checking gcube-token.. ",e); + String token=SecurityTokenProvider.instance.get(); + return authorizationService().get(token).getClientInfo().getId(); + }catch(Throwable e1 ){ + log.warn("Unable to resolve gcube-token ",e1); + return "Unidentified data-transfer user"; + } + + + } } } From 98161ad6e9b973a8b93443f9f60832a4814fe566 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Tue, 11 May 2021 18:10:26 +0200 Subject: [PATCH 4/5] Restricted upper limit in storage dependencies range --- pom.xml | 4 ++-- .../gcube/data/transfer/library/TransfererTest.java | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 002e4a6..83b5c7c 100644 --- a/pom.xml +++ b/pom.xml @@ -60,12 +60,12 @@ org.gcube.contentmanagement storage-manager-core - [2.0.0, 3.0.0) + [2.0.0, 3.0.0-SNAPSHOT) org.gcube.contentmanagement storage-manager-wrapper - [2.0.0, 3.0.0) + [2.0.0, 3.0.0-SNAPSHOT) diff --git a/src/test/java/org/gcube/data/transfer/library/TransfererTest.java b/src/test/java/org/gcube/data/transfer/library/TransfererTest.java index 4527bc1..dd772ba 100644 --- a/src/test/java/org/gcube/data/transfer/library/TransfererTest.java +++ b/src/test/java/org/gcube/data/transfer/library/TransfererTest.java @@ -1,5 +1,7 @@ package org.gcube.data.transfer.library; +import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -32,9 +34,12 @@ import org.junit.Test; public class TransfererTest { - static String hostname="https://geoserver1.dev.d4science.org"; +// static String hostname="https://thredds.dev.d4science.org"; +// static String scope="/gcube/devsec/devVRE"; + static String hostname="https://thredds-pre-d4s.d4science.org"; + static String scope="/pred4s/preprod/preVRE"; + // static String nodeId="462b68c5-463f-4295-86da-37d6c0abc7ea"; - static String scope="/gcube/devNext/NextNext"; static DataTransferClient client; @@ -53,6 +58,7 @@ public class TransfererTest { Path file=Files.createTempFile("test", ".jar"); Files.copy(in, file, StandardCopyOption.REPLACE_EXISTING); tempFile=file.toFile(); + assertTrue(tempFile.getTotalSpace()>0); } @Test From 2096414b9a6992e32d2534bc3de4fb5dc8eac9e8 Mon Sep 17 00:00:00 2001 From: Fabio Sinibaldi Date: Fri, 14 May 2021 17:16:05 +0200 Subject: [PATCH 5/5] release --- CHANGELOG.md | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a12c91..301cbe5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm # Changelog for org.gcube.data.transfer.data-transfer-library -##[v1.3.0-SNAPSHOT] 2020-12-01 +##[v1.3.0] 2020-12-01 * Upgraded integration with security layer * Removed http [#20752] diff --git a/pom.xml b/pom.xml index 83b5c7c..54755d4 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ org.gcube.data.transfer data-transfer-library - 1.3.0-SNAPSHOT + 1.3.0 DataTransfer-library Data Transfer Service client library