Compare commits
2 Commits
master
...
smartgears
Author | SHA1 | Date |
---|---|---|
Lucio Lelii | 5392f31651 | |
Lucio Lelii | 90d2d7eb17 |
|
@ -27,7 +27,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
|
|
|
@ -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.compliance=1.8
|
||||
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.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
|
|
|
@ -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
|
||||
|
||||
## [v3.0.0-SNAPSHOT] 2022-06-10
|
||||
|
||||
### Features
|
||||
|
||||
- porting to smartgears 4
|
||||
|
||||
## [v2.0.7] 2020-09-07
|
||||
|
||||
### Fixes
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -9,7 +9,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.data.transfer</groupId>
|
||||
<artifactId>data-transfer-service</artifactId>
|
||||
<version>2.0.7</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>DataTransferService</name>
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-smartgears-bom</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -5,7 +5,6 @@ import java.util.HashSet;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.gcube.common.resources.gcore.GCoreEndpoint;
|
||||
import org.gcube.data.transfer.model.PluginDescription;
|
||||
import org.gcube.data.transfer.model.TransferCapabilities;
|
||||
import org.gcube.data.transfer.model.options.HttpDownloadOptions;
|
||||
|
@ -48,7 +47,7 @@ public class CapabilitiesProviderImpl implements CapabilitiesProvider {
|
|||
ContainerConfiguration configuration=context.container().configuration();
|
||||
|
||||
String hostName=configuration.hostname();
|
||||
String id=context.profile(GCoreEndpoint.class).id();
|
||||
String id=context.id();
|
||||
Integer port=configuration.port();
|
||||
|
||||
HashSet<TransferOptions> meansOfTransfer=new HashSet<TransferOptions>();
|
||||
|
|
|
@ -77,12 +77,12 @@ public class PersistenceProviderImpl implements PersistenceProvider {
|
|||
if(persistenceId.equalsIgnoreCase(Destination.DEFAULT_PERSISTENCE_ID)){
|
||||
log.debug("Persistence ID is default");
|
||||
ApplicationContext context=ContextProvider.get();
|
||||
toReturn=new File(context.persistence().location());
|
||||
toReturn=new File(context.persistence().getLocation());
|
||||
}else{
|
||||
for(ApplicationConfiguration config:ContextProvider.get().container().configuration().apps()){
|
||||
if(config.context().equals(persistenceId)||config.context().equals("/"+persistenceId)){
|
||||
log.debug("Found persistence ID {}",persistenceId);
|
||||
toReturn= new File(config.persistence().location());
|
||||
toReturn= new File(config.persistence().getLocation());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
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.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
@ -24,30 +21,21 @@ public class TokenUtils {
|
|||
// return ScopeProvider.instance.get();
|
||||
// }
|
||||
|
||||
String scope=ScopeProvider.instance.get();
|
||||
if(scope!=null) {
|
||||
log.debug("Found scope provider {}, skipping token",scope);
|
||||
return scope;
|
||||
}else{
|
||||
try{
|
||||
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);
|
||||
}
|
||||
}
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
if(secret!=null) {
|
||||
log.debug("Found valid secret");
|
||||
return secret.getContext();
|
||||
}else
|
||||
throw new RuntimeException("SecretProvider not set");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String getCurrentUser() throws ObjectNotFound, Exception {
|
||||
String token=SecurityTokenProvider.instance.get();
|
||||
return authorizationService().get(token).getClientInfo().getId();
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
return secret.getOwner().getId();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,47 @@
|
|||
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.impl.AccountingManagerImpl;
|
||||
|
||||
public class Accountingtests {
|
||||
|
||||
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();
|
||||
String id=manager.createNewRecord();
|
||||
manager.setSuccessful(id, true);
|
||||
|
|
Loading…
Reference in New Issue