Merge pull request '1.3.0' (#1) from 1.3.0 into master

Reviewed-on: #1
This commit is contained in:
Fabio Sinibaldi 2021-05-14 17:26:20 +02:00
commit 6c2fef3870
8 changed files with 43 additions and 54 deletions

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>data-transfer-library</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -2,6 +2,11 @@ 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] 2020-12-01
* Upgraded integration with security layer
* Removed http [#20752]
##[v1.2.3] 2020-12-01
* Deletion method

View File

@ -8,7 +8,7 @@
</parent>
<groupId>org.gcube.data.transfer</groupId>
<artifactId>data-transfer-library</artifactId>
<version>1.2.3</version>
<version>1.3.0</version>
<name>DataTransfer-library</name>
<description>Data Transfer Service client library</description>
@ -30,7 +30,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -60,12 +60,12 @@
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-core</artifactId>
<version>[2.0.0, 3.0.0)</version>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.contentmanagement</groupId>
<artifactId>storage-manager-wrapper</artifactId>
<version>[2.0.0, 3.0.0)</version>
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
</dependency>

View File

@ -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{

View File

@ -1,40 +1,36 @@
package org.gcube.data.transfer.library.utils;
import org.gcube.common.authorization.library.AuthorizationEntry;
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(){
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();
}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";
}
}
}
}

View File

@ -17,7 +17,7 @@ public class Utils {
* given timeout, otherwise <code>false</code>.
*/
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();

View File

@ -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);
}

View File

@ -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,13 +34,16 @@ import org.junit.Test;
public class TransfererTest {
static String hostname="http://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;
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;
@ -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