IAM integration
This commit is contained in:
parent
cff290aa28
commit
a616a97e07
23
.project
23
.project
|
@ -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>
|
|
|
@ -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
|
# 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
|
##[v1.2.3] 2020-12-01
|
||||||
|
|
||||||
* Deletion method
|
* Deletion method
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -8,7 +8,7 @@
|
||||||
</parent>
|
</parent>
|
||||||
<groupId>org.gcube.data.transfer</groupId>
|
<groupId>org.gcube.data.transfer</groupId>
|
||||||
<artifactId>data-transfer-library</artifactId>
|
<artifactId>data-transfer-library</artifactId>
|
||||||
<version>1.2.3</version>
|
<version>1.3.0-SNAPSHOT</version>
|
||||||
<name>DataTransfer-library</name>
|
<name>DataTransfer-library</name>
|
||||||
<description>Data Transfer Service client library</description>
|
<description>Data Transfer Service client library</description>
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.distribution</groupId>
|
<groupId>org.gcube.distribution</groupId>
|
||||||
<artifactId>gcube-bom</artifactId>
|
<artifactId>gcube-bom</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>2.0.1</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -1,40 +1,17 @@
|
||||||
package org.gcube.data.transfer.library.utils;
|
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 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 class ScopeUtils {
|
||||||
|
|
||||||
public static String getCurrentScope(){
|
public static String getCurrentScope(){
|
||||||
try{
|
return ScopeProvider.instance.get();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static String getCurrentCaller(){
|
public static String getCurrentCaller(){
|
||||||
try{
|
return AuthorizationProvider.instance.get().getClient().getId();
|
||||||
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";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,21 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class TestClientCalls {
|
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="/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 Client client;
|
||||||
static long testRun=System.currentTimeMillis();
|
static long testRun=System.currentTimeMillis();
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void init() throws ServiceNotFoundException{
|
public static void init() throws ServiceNotFoundException{
|
||||||
TokenSetter.set(scope);
|
TokenSetter.set(scope);
|
||||||
|
// String hostname=
|
||||||
|
// new URL(SDIAbstractPlugin.management().build().getConfiguration().getByEngine(Engine.TH_ENGINE).get(0).getBaseEndpoint()).getHost();
|
||||||
client=new Client(hostname);
|
client=new Client(hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue