Compare commits

...

2 Commits

Author SHA1 Message Date
Lucio Lelii 5392f31651 changelog modified 2022-06-10 18:33:54 +02:00
Lucio Lelii 90d2d7eb17 porting to smartgears 4 2022-06-10 18:07:03 +02:00
8 changed files with 60 additions and 32 deletions

View File

@ -27,7 +27,6 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">

View File

@ -3,7 +3,9 @@ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.source=1.8

View File

@ -2,6 +2,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for org.gcube.data.transfer.data-transfer-plugin-framework # Changelog for org.gcube.data.transfer.data-transfer-plugin-framework
## [v3.0.0-SNAPSHOT] 2022-06-10
### Features
- porting to smartgears 4
## [v2.0.7] 2020-09-07 ## [v2.0.7] 2020-09-07
### Fixes ### Fixes

View File

@ -9,7 +9,7 @@
</parent> </parent>
<groupId>org.gcube.data.transfer</groupId> <groupId>org.gcube.data.transfer</groupId>
<artifactId>data-transfer-service</artifactId> <artifactId>data-transfer-service</artifactId>
<version>2.0.7</version> <version>3.0.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>DataTransferService</name> <name>DataTransferService</name>
@ -33,7 +33,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>gcube-smartgears-bom</artifactId> <artifactId>gcube-smartgears-bom</artifactId>
<version>2.0.0</version> <version>3.0.0-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

View File

@ -5,7 +5,6 @@ import java.util.HashSet;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.gcube.common.resources.gcore.GCoreEndpoint;
import org.gcube.data.transfer.model.PluginDescription; import org.gcube.data.transfer.model.PluginDescription;
import org.gcube.data.transfer.model.TransferCapabilities; import org.gcube.data.transfer.model.TransferCapabilities;
import org.gcube.data.transfer.model.options.HttpDownloadOptions; import org.gcube.data.transfer.model.options.HttpDownloadOptions;
@ -48,7 +47,7 @@ public class CapabilitiesProviderImpl implements CapabilitiesProvider {
ContainerConfiguration configuration=context.container().configuration(); ContainerConfiguration configuration=context.container().configuration();
String hostName=configuration.hostname(); String hostName=configuration.hostname();
String id=context.profile(GCoreEndpoint.class).id(); String id=context.id();
Integer port=configuration.port(); Integer port=configuration.port();
HashSet<TransferOptions> meansOfTransfer=new HashSet<TransferOptions>(); HashSet<TransferOptions> meansOfTransfer=new HashSet<TransferOptions>();

View File

@ -77,12 +77,12 @@ public class PersistenceProviderImpl implements PersistenceProvider {
if(persistenceId.equalsIgnoreCase(Destination.DEFAULT_PERSISTENCE_ID)){ if(persistenceId.equalsIgnoreCase(Destination.DEFAULT_PERSISTENCE_ID)){
log.debug("Persistence ID is default"); log.debug("Persistence ID is default");
ApplicationContext context=ContextProvider.get(); ApplicationContext context=ContextProvider.get();
toReturn=new File(context.persistence().location()); toReturn=new File(context.persistence().getLocation());
}else{ }else{
for(ApplicationConfiguration config:ContextProvider.get().container().configuration().apps()){ for(ApplicationConfiguration config:ContextProvider.get().container().configuration().apps()){
if(config.context().equals(persistenceId)||config.context().equals("/"+persistenceId)){ if(config.context().equals(persistenceId)||config.context().equals("/"+persistenceId)){
log.debug("Found persistence ID {}",persistenceId); log.debug("Found persistence ID {}",persistenceId);
toReturn= new File(config.persistence().location()); toReturn= new File(config.persistence().getLocation());
break; break;
} }
} }

View File

@ -1,11 +1,8 @@
package org.gcube.data.transfer.service.transfers.engine.impl; package org.gcube.data.transfer.service.transfers.engine.impl;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import org.gcube.common.authorization.client.exceptions.ObjectNotFound; import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
import org.gcube.common.authorization.library.AuthorizationEntry; import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.security.secrets.Secret;
import org.gcube.common.scope.api.ScopeProvider;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -24,30 +21,21 @@ public class TokenUtils {
// return ScopeProvider.instance.get(); // return ScopeProvider.instance.get();
// } // }
String scope=ScopeProvider.instance.get(); Secret secret = SecretManagerProvider.instance.get();
if(scope!=null) { if(secret!=null) {
log.debug("Found scope provider {}, skipping token",scope); log.debug("Found valid secret");
return scope; return secret.getContext();
}else{ }else
try{ throw new RuntimeException("SecretProvider not set");
log.debug("Scope provider not set, reverting to token");
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){
throw new RuntimeException("Unable to evaluate scope ",e);
}
}
} }
public static String getCurrentUser() throws ObjectNotFound, Exception { public static String getCurrentUser() throws ObjectNotFound, Exception {
String token=SecurityTokenProvider.instance.get(); Secret secret = SecretManagerProvider.instance.get();
return authorizationService().get(token).getClientInfo().getId(); return secret.getOwner().getId();
} }
} }

View File

@ -1,13 +1,47 @@
package org.gcube.data.transfer.service; package org.gcube.data.transfer.service;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import java.util.Collections;
import java.util.Map;
import org.gcube.common.security.Owner;
import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.security.secrets.Secret;
import org.gcube.data.transfer.service.transfers.engine.AccountingManager; import org.gcube.data.transfer.service.transfers.engine.AccountingManager;
import org.gcube.data.transfer.service.transfers.engine.impl.AccountingManagerImpl; import org.gcube.data.transfer.service.transfers.engine.impl.AccountingManagerImpl;
public class Accountingtests { public class Accountingtests {
public static void main(String[] args) { public static void main(String[] args) {
SecurityTokenProvider.instance.set("feda0617-cd9d-4841-b6f0-e047da5d32ed-98187548"); SecretManagerProvider.instance.set(new Secret() {
@Override
public boolean isRefreshable() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isExpired() {
// TODO Auto-generated method stub
return false;
}
@Override
public Owner getOwner() {
return new Owner("guest", Collections.emptyList(), false);
}
@Override
public Map<String, String> getHTTPAuthorizationHeaders() {
return Collections.emptyMap();
}
@Override
public String getContext() {
return "/gcube";
}
});
AccountingManager manager=AccountingManagerImpl.get(); AccountingManager manager=AccountingManagerImpl.get();
String id=manager.createNewRecord(); String id=manager.createNewRecord();
manager.setSuccessful(id, true); manager.setSuccessful(id, true);