diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0d1db47..d239b0f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,7 +4,8 @@
* removed slf4j implementations, added slf4j-simple;
* Discovering serviceEndpoint with category Storage
* moved version from 3.1.0-SNAPSHOT to 4.0.0-SNAPSHOT
-
+ * upgrade to gcube-bom 3 and ScopeProvider removed
+ * removed environment variable scope
## [v3.0.1-SNAPSHOT]
* removed http protocol;
diff --git a/pom.xml b/pom.xml
index a3f7be1..02dc130 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,14 +15,16 @@
https://code-repo.d4science.org/gCubeSystem/${project.artifactId}
- ${project.basedir}/distro
+ ${project.basedir}/distro
+ 1.8
+ 1.8
org.gcube.distribution
gcube-bom
- 2.0.1
+ 3.0.0-SNAPSHOT
pom
import
diff --git a/src/main/java/org/gcube/common/scope/impl/ServiceMapScannerMediator.java b/src/main/java/org/gcube/common/scope/impl/ServiceMapScannerMediator.java
index db25f91..2a38ae7 100644
--- a/src/main/java/org/gcube/common/scope/impl/ServiceMapScannerMediator.java
+++ b/src/main/java/org/gcube/common/scope/impl/ServiceMapScannerMediator.java
@@ -2,35 +2,15 @@ package org.gcube.common.scope.impl;
import java.util.Set;
-import org.gcube.common.scope.api.ScopeProvider;
+
/**
- * Check the validity of a given scope
+ * Utility class
* @author Roberto Cirillo (ISTI-CNR)
*
*/
public class ServiceMapScannerMediator {
-
- /**
- * The validation has been removed
- * @param scope
- * @return
- */
- @Deprecated
- public static boolean isValid(String scope){
-// log.debug("validating scope "+scope);
- String currentScope=ScopeProvider.instance.get();
- ScopeProvider.instance.set(scope);
- try{
- new ScopedServiceMap().scope();
- }catch(Exception e){
- return false;
- }finally{
- ScopeProvider.instance.set(currentScope);
- }
- return true;
- }
public static Set getScopeKeySet(){
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/URIs.java b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/URIs.java
deleted file mode 100644
index ed835fc..0000000
--- a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/URIs.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package org.gcube.contentmanager.storageclient.model.protocol;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.List;
-//import org.gcube.common.core.scope.GCUBEScope;
-//import org.gcube.common.core.scope.GCUBEScopeManager;
-import org.gcube.contentmanager.storageclient.model.protocol.smp.Handler;
-
-/**
- * Utility methods for content URI creation and manipulation.
- * @author Fabio Simeoni (University of Strathclyde)
- * @author Roberto Cirillo (ISTI-CNR)
- *
- */
-public class URIs {
-
- static {
- Handler.activateProtocol();
- }
-
- /**Scheme of cms URIs.*/
- public static final String PROTOCOL="smp";
-
- /**
- * Indicates whether a URI is a valid content URI.
- * @param uri the URI.
- * @throws URISyntaxException if the URI fails validation.
- */
- public static void validate(URI uri) throws URISyntaxException {
- if (!PROTOCOL.equals(uri.getScheme()) ||
- uri.getAuthority()==null ||
- uri.getPath()==null ||
- uri.getPath().length()<2)
- throw new IllegalArgumentException(new URISyntaxException(uri.toString(),"uri is not a well-formed content URI"));
- }
-
- /**
- * Constructs a content URI from a collection identifiers and one or more node identifiers.
- * @param collectionID the collection identifier.
- * @param identifiers the node identifiers.
- * @return the URI.
- * @throws IllegalArgumentException if the input is null
or empty.
- */
- public static URI make(String collectionID, String ... identifiers) throws IllegalArgumentException {
-
- if (collectionID==null || identifiers==null || identifiers.length==0)
- throw new IllegalArgumentException("null or empty input");
-
- StringBuilder path = new StringBuilder();
- for (Object id : identifiers)
- path.append("/"+id.toString());
-
- URI uri = null;
- try {
- uri = new URI(PROTOCOL,collectionID,path.toString(),null);
- }
- catch(URISyntaxException e) {
- throw new RuntimeException("error in generation uri with "+PROTOCOL+","+collectionID+","+path,e);
- }
- return uri;
- }
-
- /**
- * Returns the collection identifier in a sm
URI.
- * @param uri the URI.
- * @return the identifier.
- * @throws URISyntaxException if the URI is not a content URI.
- */
- public static String collectionID(URI uri) throws URISyntaxException {
- validate(uri);
- return uri.getAuthority();
- }
-
- /**
- * Returns the document identifier in a content URI.
- * @param uri the URI.
- * @return the identifier.
- * @throws URISyntaxException if the URI is not a content URI.
- */
- public static String documentID(URI uri) throws URISyntaxException {
- validate(uri);
- String p = uri.getPath().substring(1);
- if (p.endsWith("/"))
- p = p.substring(0,p.length()-1);
- int index = p.indexOf("/");
- return p.substring(0,index>0?index:p.length());
- }
-
- /**
- * Returns the identifier of the node identified by a content URI.
- * @param uri the URI.
- * @return the identifier.
- * @throws URISyntaxException if the URI is not a content URI.
- */
- public static String nodeID(URI uri) throws URISyntaxException {
- validate(uri);
- return uri.getPath().substring(uri.getPath().lastIndexOf("/")+1);
- }
-
- /**
- * Returns the identifiers in a content URI.
- * @param uri the URI.
- * @return the identifiers.
- * @throws URISyntaxException if the URI is not a content URI.
- */
- public static String[] nodeIDs(URI uri) throws URISyntaxException {
- validate(uri);
- List ids = new ArrayList();
- for (String s : uri.getPath().substring(1).split("/")) //will be validated here
- ids.add(s);
- return ids.toArray(new String[0]);
- }
-
- /**
- * Returns a content URI for the parent of the node identified by another content URI.
- * @param uri the input URI.
- * @return the parent URI.
- * @throws URISyntaxException if the input URI is not a content URL.
- */
- public static URI parentURI(URI uri) throws URISyntaxException {
- validate(uri);
- String u = uri.getPath();
- return make(uri.getAuthority(),u.substring(1,u.lastIndexOf("/")).split("/"));
- }
-
- /**
- * Returns a content URI for the document of the node identified by another content URI.
- * @param uri the input URI.
- * @return the document URI.
- * @throws URISyntaxException if the input URI is not a content URI.
- */
- public static URI documentURI(URI uri) throws URISyntaxException {
- validate(uri);
- return make(uri.getAuthority(),documentID(uri));
- }
-
- /**
- * Returns a URL connection in a given scope.
- * @param uri a content URI.
- * @param scope the scope.
- * @return the connection.
- * @throws IOException if the connections could not be established.
- * @throws URISyntaxException if the URI is not a content URI or if the protocol handler for the smp
scheme is not active.
- * @deprecated since 2.3.1. Use {@link URLConnection} normally in current scope.
- */
- public static URLConnection connection(URI uri, String scope) throws IOException, URISyntaxException {
- validate(uri);
- URLConnection connection = uri.toURL().openConnection();
- return connection;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/Handler.java b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/Handler.java
deleted file mode 100644
index c4d9b77..0000000
--- a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/Handler.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package org.gcube.contentmanager.storageclient.model.protocol.smp;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
-
-/**
- * A handler for the smp
protocol.
- * @author Fabio Simeoni (University of Strathclyde)
- * @author Roberto Cirillo (ISTI-CNR)
- *
- */
-public class Handler extends URLStreamHandler {
-
- /**{@inheritDoc}*/
- @Override
- protected URLConnection openConnection(URL u) throws IOException {
- return SMPURLConnectionFactory.getSmp(u);
- }
-
- /**
- * Registers the protocol with the JVM.
- */
- public static void activateProtocol() {
-
- String pkgs_name="java.protocol.handler.pkgs";
- String pkgs = System.getProperty(pkgs_name);
- String pkg = "org.gcube.contentmanager.storageclient.model.protocol";
- if (pkgs==null)
- pkgs = pkg ;
- else if (!pkgs.contains(pkg))
- pkgs = pkgs+"|"+pkg;
- System.setProperty(pkgs_name, pkgs);
- }
-
-
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPConnection.java b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPConnection.java
deleted file mode 100644
index fe7cef5..0000000
--- a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPConnection.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package org.gcube.contentmanager.storageclient.model.protocol.smp;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-
-import org.gcube.common.scope.api.ScopeProvider;
-import org.gcube.contentmanager.storageclient.wrapper.ISClientConnector;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * An extension of URLConnection used for smp url
- * @author Roberto Cirillo (ISTI-CNR)
- *
- */
-public abstract class SMPConnection extends URLConnection {
-
- Logger logger= LoggerFactory.getLogger(SMPURLConnection.class);
-
- public SMPConnection(URL url) {
- super(url);
- }
-
- public abstract URLConnection init(URL url);
-
- /**{@inheritDoc}*/
- @Override
- public synchronized void connect() throws IOException {
- connected=true;
- }
-
- @Override
- public abstract InputStream getInputStream() throws IOException;
-
-
- protected abstract InputStream storageClient(String url) throws Exception;
-
- /**
- * This method has been moved in Configuration class
- * @param rootScope
- * @return
- * @throws Exception
- * @see org.gcube.contentmanager.storageclient.wrapper.Configuration
- *
- */
- @Deprecated
- protected String retrieveEncryptionPhrase() throws Exception {
- String currentScope=ScopeProvider.instance.get();
- logger.debug("retrieve encryption prhase on scope: "+currentScope);
- String encryptedKey=null;
- ISClientConnector isclient=new ISClientConnector();
- encryptedKey=isclient.retrievePropertyValue("PassPhrase", currentScope);
- String decryptString=org.gcube.common.encryption.StringEncrypter.getEncrypter().decrypt(encryptedKey);
- return decryptString;
- }
-
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnection.java b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnection.java
deleted file mode 100644
index 51f93de..0000000
--- a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnection.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.gcube.contentmanager.storageclient.model.protocol.smp;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.net.URLConnection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
-*
-* This is invoked by the platform with a URL of the right protocol.
-* @author Fabio Simeoni (University of Strathclyde), @author Roberto Cirillo (ISTI-CNR)
-* @deprecated this class will be deleted and will be changed with the factory class invocation: SMPURLConnectionFactory
-* @see SMPURLConnectionFactory
-*/
-@Deprecated
-public class SMPURLConnection extends URLConnection {
-
- SMPConnection smp;
- Logger logger= LoggerFactory.getLogger(SMPURLConnection.class);
- /**
- * Constructs a new instance for a given sm
URL.
- * @deprecated reason this method is deprecated
- * {will be removed in next version}
- * use {@link #SMPURLConnectionFactory.getSmp(url)}
- * @param url the URL.
- */
- @Deprecated
- public SMPURLConnection(URL url) {
- super(url);
- this.smp=SMPURLConnectionFactory.getSmp(url);
- }
-
- /**{@inheritDoc}*/
- @Override
- public synchronized void connect() throws IOException {
- connected=true;
- }
-
- /**{@inheritDoc}*/
- @Override
- public synchronized InputStream getInputStream() throws IOException {
- return smp.getInputStream();
- }
-}
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnectionById.java b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnectionById.java
deleted file mode 100644
index d0f9660..0000000
--- a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnectionById.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package org.gcube.contentmanager.storageclient.model.protocol.smp;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.apache.commons.codec.binary.Base64;
-import org.gcube.common.scope.api.ScopeProvider;
-import org.gcube.contentmanagement.blobstorage.service.IClient;
-import org.gcube.contentmanagement.blobstorage.service.operation.GetHttpUrl;
-import org.gcube.contentmanagement.blobstorage.service.operation.GetUrl;
-import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
-import org.gcube.contentmanager.storageclient.wrapper.AccessType;
-import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
-import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This is invoked by the platform with a URL of the smp protocol with new format (>= 2.2.0 version) .
-* @author Roberto Cirillo (ISTI-CNR)
- *
- * Example: smp://data.gcube.org?uhdnfounhcfnshfnrhbvyaeegytf6dfawiuawgcyg
- */
-@Deprecated
-public class SMPURLConnectionById extends SMPConnection {
-
- private Logger logger= LoggerFactory.getLogger(SMPURLConnectionOld.class);
- private String serviceClass="Storage-manager";
- private String serviceName="resolver-uri";
- private String owner="storage-manager";
-
- /**
- * Constructs a new instance for a given sm
URL.
- * @param url the URL.
- */
- public SMPURLConnectionById(URL url) {
- super(url);
- }
-
- public SMPConnection init(URL url){
- return new SMPURLConnectionById(url);
- }
-
- /**{@inheritDoc}
- * internal handler implementation
- * */
- @Override
- public synchronized InputStream getInputStream() throws IOException {
- if (!connected)
- this.connect();
- try {
- return storageClient(this.url.toString());
- }
- catch(Exception e) {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
-
-
- /**
- * Get a StorageManager instance from url
- */
-
- protected InputStream storageClient(String url) throws Exception {
- logger.info("url :" + url);
- String [] urlParam=url.split(Costants.URL_SEPARATOR);
- String protocol=urlParam[0];
- protocol=protocol.substring(0, protocol.length()-1);
- logger.debug("protocol is "+protocol);
- if(ScopeProvider.instance.get() == null){
- throw new RuntimeException("Scope not set");
- }
- String encrypted=retrieveStringEncrypted(urlParam);
- MemoryType memory=null;
- if(encrypted.contains(Costants.VOLATILE_URL_IDENTIFICATOR)){
- memory=MemoryType.VOLATILE;
- encrypted=encrypted.replace(Costants.VOLATILE_URL_IDENTIFICATOR, "");
- }
- logger.debug("String encrypted "+encrypted);
- String phrase=retrieveEncryptionPhrase();
- String location=null;
- if(Base64.isBase64(encrypted) && (protocol.equalsIgnoreCase("http"))){
- byte[] valueDecoded= Base64.decodeBase64(encrypted);
- String encryptedID = new String(valueDecoded);
- location=new StringDecrypter("DES", phrase).decrypt(encryptedID);
- }else{
- location=new StringDecrypter("DES", phrase).decrypt(encrypted);
- }
- IClient client=null;
- if(memory!=null)
- client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, memory).getClient();
- else
- client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED).getClient();
- InputStream is=null;
- is=client.get().RFileAsInputStream(location);
- return is;
- }
-
- private String retrieveStringEncrypted(String[] urlParam) {
- String encrypted=urlParam[3];
- int i=4;
- while(i < urlParam.length){
- encrypted=encrypted+Costants.URL_SEPARATOR+urlParam[i];
- i++;
- }
- return encrypted;
- }
-
-
-
-
-}
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnectionFactory.java b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnectionFactory.java
deleted file mode 100644
index 5ea3a8e..0000000
--- a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnectionFactory.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package org.gcube.contentmanager.storageclient.model.protocol.smp;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ServiceLoader;
-
-import org.gcube.common.resources.gcore.ServiceEndpoint;
-import org.gcube.common.scope.api.ScopeProvider;
-import org.gcube.common.scope.impl.ScopeBean;
-import org.gcube.common.scope.impl.ScopeBean.Type;
-import org.gcube.contentmanagement.blobstorage.service.operation.GetUrl;
-import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
-import org.gcube.contentmanager.storageclient.protocol.utils.Utils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Factory class used to determine the right smp url protocol: old format(<2.2.0 version), new format (>= 2.2.0-SNAPSHOT)
- * @author Roberto Cirillo (ISTI-CNR)
- *
- */
-@Deprecated
-public class SMPURLConnectionFactory {
-
- static Logger logger=LoggerFactory.getLogger(SMPURLConnectionFactory.class);
-
- public static SMPConnection getSmp(URL url) {
- String urlString=url.toString();
- Utils.checkScopeProvider();
- if(isNewSmpFormat(urlString)|| isIntermediateType(urlString)){
- logger.info("detected new smp format "+url);
- SMPConnection connection=load(url);
- if (connection!= null)
- return connection;
- return new SMPURLConnectionById(url);
- }else{
- logger.info("detected old smp format "+url);
- return new SMPURLConnectionOld(url);
- }
- }
-
-
- /**
- * patch method for a particular smp uri: smp://data.gcube.org/8TFLhJ991DF1M/Ae8rGamC3CgCjAXlnVGmbP5+HKCzc=
- * @param urlString
- * @return
- */
- private static boolean isIntermediateType(String urlString) {
- String [] urlParam=urlString.split(Costants.URL_SEPARATOR);
- String infraHost=urlParam[2];
- if(Utils.isScopeProviderMatch(infraHost))
- return true;
- String infra=Utils.getInfraFromResolverHost(infraHost);
- String rootScope="/"+infra;
- ScopeBean scope=new ScopeBean(rootScope);
- if(scope.is(Type.INFRASTRUCTURE)){
- return Utils.validationScope2(rootScope);
- }else{
- return false;
- }
- }
-
- private static boolean isNewSmpFormat(String urlString) {
- logger.debug("check format: "+urlString);
- String httpString=urlString;
- httpString=httpString.replace("smp://", "https://");
- logger.debug("httpsUrl conversion: "+httpString);
- URL httpsUrl=null;
- try {
- httpsUrl=new URL(httpString);
- } catch (MalformedURLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- List services=Utils.queryServiceEndpoint(Utils.URI_RESOLVER_RESOURCE_CATEGORY, Utils.URI_RESOLVER_RESOURCE_NAME);
- String host=null;
- if(services != null && services.size()>0){
- host=Utils.getResolverHost(services.get(0));
- }
- logger.debug("uri-resolver host: "+host+" in scope: "+ScopeProvider.instance.get());
- if((host!=null) && (host.equals(httpsUrl.getHost()))){
- return true;
- }else{
- return false;
- }
- }
-
-
- /**
- * Load a backend driver from classpath
- * @param url
- * @return
- */
- private static SMPConnection load(URL url){
- ServiceLoader loader = ServiceLoader.load(SMPConnection.class);
- Iterator iterator = loader.iterator();
- List impls = new ArrayList();
- while(iterator.hasNext())
- impls.add(iterator.next());
- int implementationCounted=impls.size();
-// System.out.println("size: "+implementationCounted);
- if(implementationCounted==0){
- logger.info(" 0 implementation found. Load default implementation of SMPConnection");
- return null;
- }else if(implementationCounted>0){
- SMPConnection connection = impls.get(0);
- logger.info("1 implementation of TransportManager found. ");
- connection.init(url);
- return connection;
- }else{
- return null;
- }
- }
-
-
-
-}
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnectionOld.java b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnectionOld.java
deleted file mode 100644
index 3d28785..0000000
--- a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPURLConnectionOld.java
+++ /dev/null
@@ -1,147 +0,0 @@
-package org.gcube.contentmanager.storageclient.model.protocol.smp;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import org.gcube.common.scope.api.ScopeProvider;
-import org.gcube.contentmanagement.blobstorage.service.IClient;
-import org.gcube.contentmanager.storageclient.wrapper.AccessType;
-import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
-import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
-*
-* This is invoked by the platform with a URL of the right protocol.
-* @author Fabio Simeoni (University of Strathclyde), @author Roberto Cirillo (ISTI-CNR)
-*
-*/
-@Deprecated
-public class SMPURLConnectionOld extends SMPConnection{
-
-
- Logger logger= LoggerFactory.getLogger(SMPURLConnectionOld.class);
- /**
- * Constructs a new instance for a given sm
URL.
- * @param url the URL.
- */
- public SMPURLConnectionOld(URL url) {
- super(url);
- }
-
- public SMPConnection init(URL url){
- return new SMPURLConnectionOld(url);
- }
-
- /**{@inheritDoc}*/
- @Override
- public synchronized InputStream getInputStream() throws IOException {
- if (!connected)
- this.connect();
- try {
- return storageClient(this.url.toString());
- }
- catch(Exception e) {
- IOException ioe = new IOException();
- ioe.initCause(e);
- throw ioe;
- }
- }
-
-
- protected InputStream storageClient(String url) throws Exception {
- logger.info("url :" + url);
- String [] urlParam=url.split("\\?");
- logger.info("String encrypted "+urlParam[1]);
- String param=new StringDecrypter("DES", retrieveEncryptionPhrase()).decrypt(urlParam[1]);
- logger.info("String decrypted: "+param);
- String [] getParam=param.split("\\&");
- String serviceClass=null;
- String serviceName=null;
- String owner=null;
- String accessType=null;
- String memoryType=null;
- String scopeType=null;
- AccessType type = null;
- MemoryType mType = null;
- String server= null;
- String [] par1;
- for(String par : getParam){
- if(par.contains("ServiceClass")){
- par1=par.split("=");
- serviceClass=par1[1];
- }else if(par.contains("ServiceName")){
- par1=par.split("=");
- serviceName=par1[1];
- }else if(par.contains("owner")){
- par1=par.split("=");
- owner=par1[1];
- }else if(par.contains("scope")){
- par1=par.split("=");
- scopeType=par1[1];
- }else if(par.contains("server")){
- par1=par.split("=");
- server=par1[1];
- }else if(par.contains("AccessType")){
- par1=par.split("=");
- accessType=par1[1];
- if(accessType.equalsIgnoreCase("public")){
- type=AccessType.PUBLIC;
- }else if(accessType.equalsIgnoreCase("shared")){
- type=AccessType.SHARED;
- }
- }else if(par.contains("MemoryType")){
- par1=par.split("=");
- memoryType=par1[1];
- if(memoryType.equalsIgnoreCase("VOLATILE")){
- mType=MemoryType.VOLATILE;
- }else{
- mType=MemoryType.PERSISTENT;
- }
- }
- }
- // throw an exception if one or more uri parameters are invalid
- if((serviceName==null) || (serviceClass==null) || (owner == null) || (scopeType==null) || (type == null)){
- logger.error("Bad Parameter in URI");
- if (type == null){
- logger.error("URI generated from a private file");
- throw new MalformedURLException("The uri is generated from a private file. It cannot be accessed");
- }
- if (serviceName==null) throw new MalformedURLException("The uri generated has an invalid serviceName");
- if (serviceClass==null) throw new MalformedURLException("The uri generated has an invalid serviceClass");
- if (owner==null) throw new MalformedURLException("The uri generated has an invalid owner");
- if (scopeType==null) throw new MalformedURLException("The uri is generated has an invalid scopeType.");
- }
- String location=extractLocation(urlParam[0]);
- logger.info("Parameters from URI "+serviceClass+" "+serviceName+" "+owner+" "+type+" "+mType +" location: "+urlParam[0]+" scope: "+scopeType);
- IClient client=null;
- String currentScope=ScopeProvider.instance.get();
- logger.info("current scope used: "+currentScope+". scope found on url is: "+ scopeType);
-// ScopeProvider.instance.set(scopeType);
- if(mType != null){
- if(server!=null)
- client=new StorageClient(serviceClass, serviceName, owner, type, mType, server).getClient();
- else
- client=new StorageClient(serviceClass, serviceName, owner, type, mType).getClient();
- }else{
- if (server != null)
- client=new StorageClient(serviceClass, serviceName, owner, server, type ).getClient();
- else
- client=new StorageClient(serviceClass, serviceName, owner, type).getClient();
- }
- InputStream is=null;
- is=client.get().RFileAsInputStream(location);
-// ScopeProvider.instance.set(currentScope);
- return is;
- }
-
- private String extractLocation(String url) {
- String [] loc=url.split("//");
- logger.info("url extracted: "+loc[1]);
- return loc[1];
- }
-
-}
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPUrl.java b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPUrl.java
deleted file mode 100644
index e674dda..0000000
--- a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/SMPUrl.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package org.gcube.contentmanager.storageclient.model.protocol.smp;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URLConnection;
-import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPURLConnectionFactory;
-
-/**
- * Allow to the end user to manage a smp url as an url with a configured stream handler
- * @author Roberto Cirillo (ISTI-CNR)
- *
- */
-@Deprecated
-public class SMPUrl extends java.net.URLStreamHandler{
-
- private java.net.URL url;
-
- /**
- * map a url string as a normal url
- * @param u url string
- * @throws MalformedURLException
- */
- public SMPUrl(String u) throws MalformedURLException{
- this.url=new java.net.URL(null, u, this);
- }
-
- public URLConnection openConnection() throws IOException{
- return this.openConnection(url);
- }
-
- @Override
- protected URLConnection openConnection(java.net.URL u) throws IOException {
- if(u.getProtocol().equalsIgnoreCase("smp")){
- return SMPURLConnectionFactory.getSmp(u);
- }else{
- return new java.net.URL(null, u.toString()).openConnection();
- }
-
- }
-
- public String getHost(){
- return this.url.getHost();
- }
-
- /**
- * Gets the path part of this URL
.
- *
- * @return the path part of this URL
, or an
- * empty string if one does not exist
- * @since 1.3
- */
- public String getPath() {
- return url.getPath();
- }
-
- /**
- * Gets the userInfo part of this URL
.
- *
- * @return the userInfo part of this URL
, or
- * null
if one does not exist
- * @since 1.3
- */
- public String getUserInfo() {
- return url.getUserInfo();
- }
-
- /**
- * Gets the authority part of this URL
.
- *
- * @return the authority part of this URL
- * @since 1.3
- */
- public String getAuthority() {
- return url.getAuthority();
- }
-
- /**
- * Gets the port number of this URL
.
- *
- * @return the port number, or -1 if the port is not set
- */
- public int getPort() {
- return url.getPort();
- }
-
- /**
- * Gets the default port number of the protocol associated
- * with this URL
. If the URL scheme or the URLStreamHandler
- * for the URL do not define a default port number,
- * then -1 is returned.
- *
- * @return the port number
- * @since 1.4
- */
- public int getDefaultPort() {
- return url.getDefaultPort();
- }
-
- /**
- * Gets the protocol name of this URL
.
- *
- * @return the protocol of this URL
.
- */
- public String getProtocol() {
- return url.getProtocol();
- }
-
-
-
- /**
- * Gets the file name of this URL
.
- * The returned file portion will be
- * the same as getPath()
, plus the concatenation of
- * the value of getQuery()
, if any. If there is
- * no query portion, this method and getPath()
will
- * return identical results.
- *
- * @return the file name of this URL
,
- * or an empty string if one does not exist
- */
- public String getFile() {
- return url.getFile();
- }
-
- /**
- * Gets the anchor (also known as the "reference") of this
- * URL
.
- *
- * @return the anchor (also known as the "reference") of this
- * URL
, or null
if one does not exist
- */
- public String getRef() {
- return url.getRef();
- }
-
-
-}
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/StringDecrypter.java b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/StringDecrypter.java
index 603338a..773798d 100644
--- a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/StringDecrypter.java
+++ b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/StringDecrypter.java
@@ -97,7 +97,7 @@ public class StringDecrypter {
{
SecretKey key = keyFactory.generateSecret( keySpec );
cipher.init( Cipher.DECRYPT_MODE, key );
- return org.gcube.common.encryption.StringEncrypter.getEncrypter().decrypt(encryptedString, key);
+ return org.gcube.common.encryption.encrypter.StringEncrypter.getEncrypter().decrypt(encryptedString, key);
}
catch (Exception e)
{
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/StringEncrypter.java b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/StringEncrypter.java
index 3642180..6c8b9a5 100644
--- a/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/StringEncrypter.java
+++ b/src/main/java/org/gcube/contentmanager/storageclient/model/protocol/smp/StringEncrypter.java
@@ -98,7 +98,7 @@ public class StringEncrypter {
{
SecretKey key = keyFactory.generateSecret( keySpec );
cipher.init( Cipher.ENCRYPT_MODE, key );
- return org.gcube.common.encryption.StringEncrypter.getEncrypter().encrypt(unencryptedString, key);
+ return org.gcube.common.encryption.encrypter.StringEncrypter.getEncrypter().encrypt(unencryptedString, key);
}
catch (Exception e)
{
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/protocol/utils/Utils.java b/src/main/java/org/gcube/contentmanager/storageclient/protocol/utils/Utils.java
index b7bae6a..657e837 100644
--- a/src/main/java/org/gcube/contentmanager/storageclient/protocol/utils/Utils.java
+++ b/src/main/java/org/gcube/contentmanager/storageclient/protocol/utils/Utils.java
@@ -9,10 +9,8 @@ import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import org.gcube.common.resources.gcore.ServiceEndpoint;
-import org.gcube.common.scope.api.ScopeProvider;
-import org.gcube.common.scope.impl.ScopeBean;
-import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.common.scope.impl.ServiceMapScannerMediator;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
@@ -36,47 +34,9 @@ public class Utils {
public static final String URI_RESOLVER_RESOURCE_NAME="HTTP-URI-Resolver";
private static final Logger logger = LoggerFactory.getLogger(Utils.class);
-
-
- public static boolean validationScope2(String scope){
- ScopeBean scopeBean=new ScopeBean(scope);
- if((scopeBean.is(Type.VRE)))
- scope=scopeBean.enclosingScope().toString();
- return ServiceMapScannerMediator.isValid(scope);
- }
-
- public static ArrayList getVOScopes(String scope){
- ArrayList vos=new ArrayList();
- ScopeBean scopeBean=new ScopeBean(scope);
- //retrieve INFRA scope
- while(!scopeBean.is(Type.INFRASTRUCTURE)){
- logger.debug("the scope "+scope+" is not an INFRA scope ");
- scopeBean=new ScopeBean(scopeBean.enclosingScope().toString());
- }
- scope=scopeBean.toString();
- if(scopeBean.is(Type.INFRASTRUCTURE)){
- Set scopeSet=ServiceMapScannerMediator.getScopeKeySet();
- for(String scopeItem : scopeSet){
- //retrieve all Vo scopes
- logger.debug("scope scanned: "+scopeItem);
- if(scopeItem.contains(scope) && (new ScopeBean(scopeItem).is(Type.VO))){
- logger.debug("found vo scope: "+scopeItem);
- vos.add(scopeItem);
- }
- }
- }
- return vos;
- }
-
- public static String extractInfrastructureNewVersion(String urlParam){
- logger.debug("urlParam: "+urlParam);
- String infra= checkVarEnv(INFRASTRUCTURE_ENV_VARIABLE_NAME);
- if (infra != null)
- return infra;
- else
- //only for test return the infra from the uri. In prod will be throws a runtime exception
- return getInfraFromResolverHost(urlParam);
- }
+
+
+
public static String getInfraFromResolverHost(String resolverHost) {
if(resolverHost.equals(GCUBE_RESOLVER_HOST)){
@@ -86,48 +46,6 @@ public class Utils {
}else return resolverHost;
}
- public static String checkVarEnv(String name){
- Map env = System.getenv();
- TreeSet keys = new TreeSet(env.keySet());
- Iterator iter = keys.iterator();
- String value=null;
- while(iter.hasNext())
- {
- String key = iter.next();
- if(key.equalsIgnoreCase(name)){
- value=env.get(key);
- break;
- }
- }
- return value;
- }
-
- public static boolean isScopeProviderMatch(String infraHost) {
- String currentScope=ScopeProvider.instance.get();
- if(currentScope != null){
- //get vo scope
- String voScope=Utils.getVOScope(currentScope);
- // get the uri resolver host
- List services=queryServiceEndpoint(URI_RESOLVER_RESOURCE_CATEGORY, URI_RESOLVER_RESOURCE_NAME);
- String host=null;
- if(services != null && services.size()>0){
- host=getResolverHost(services.get(0));
- if(host!=null){
- if(infraHost.equalsIgnoreCase(host)){
- return true;
- }
- }
- }
- }
- return false;
- }
-
- private static String getVOScope(String currentScope) {
- ScopeBean scopeBean=new ScopeBean(currentScope);
- if((scopeBean.is(Type.VRE)))
- currentScope=scopeBean.enclosingScope().toString();
- return currentScope;
- }
public static List queryServiceEndpoint(String category, String name){
SimpleQuery query = queryFor(ServiceEndpoint.class);
@@ -136,25 +54,6 @@ public class Utils {
List resources = client.submit(query);
return resources;
}
-
- /**
- * if the scope provider is not set then check if the env variable: SCOPE is set and set the scopeProvider
- */
- public static void checkScopeProvider(){
- String scopeProvided=ScopeProvider.instance.get();
- logger.info("check scope: scope found "+scopeProvided);
- if ((scopeProvided==null) || (scopeProvided.isEmpty())){
- logger.debug("scope not correctly set on ScopeProvider");
- logger.info("scope: check variable");
- scopeProvided=Utils.checkVarEnv("SCOPE");
- if (scopeProvided != null){
- ScopeProvider.instance.set(scopeProvided);
- }else{
- throw new RuntimeException("Scope not set ");
- }
- }
- }
-
public static String getResolverHost(ServiceEndpoint serviceEndpoint) {
return serviceEndpoint.profile().runtime().hostedOn();
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/wrapper/Configuration.java b/src/main/java/org/gcube/contentmanager/storageclient/wrapper/Configuration.java
index bb0d588..b5f52e9 100644
--- a/src/main/java/org/gcube/contentmanager/storageclient/wrapper/Configuration.java
+++ b/src/main/java/org/gcube/contentmanager/storageclient/wrapper/Configuration.java
@@ -7,9 +7,7 @@ import java.util.Objects;
import java.util.TreeSet;
import org.gcube.common.resources.gcore.ServiceEndpoint;
-import org.gcube.common.scope.api.ScopeProvider;
-import org.gcube.common.scope.impl.ScopeBean;
-import org.gcube.common.scope.impl.ScopeBean.Type;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.service.impl.ServiceEngine;
import org.gcube.contentmanager.storageclient.protocol.utils.Utils;
import org.slf4j.Logger;
@@ -108,16 +106,14 @@ public class Configuration {
*/
public void getConfiguration(){
String[] newServer=null;
- String currentScope=ScopeProvider.instance.get();
+ String currentScope;
+ currentScope = SecretManagerProvider.instance.get().getContext();
logger.debug("Scope found on ScopeProvider instance is "+currentScope);
- if(RRScope == null){
- RRScope=currentScope;
- }
- logger.debug("RuntimeResource scope "+RRScope);
+ logger.debug("Manually scope was set to"+RRScope+" it doesn't take effect");
//if a specific backend is not passed as input param then take the default one
if (Objects.isNull(getBackendType()))
setBackendType(DEFAULT_BACKEND_TYPE);
- ServiceEndpoint resource=getISClient(getBackendType()).getStorageEndpoint(RRScope);
+ ServiceEndpoint resource=getISClient(getBackendType()).getStorageEndpoint();
if(resource ==null )
throw new IllegalStateException("the storage resource is not present on IS in scope: "+RRScope);
List resolverResource =getISClient(getBackendType()).getServiceEndpoint(Utils.URI_RESOLVER_RESOURCE_CATEGORY, Utils.URI_RESOLVER_RESOURCE_NAME);
@@ -179,21 +175,7 @@ public class Configuration {
logger.debug("Configuration parameters retrieved: host: "+getPersistentHosts()+" user: "+getUser());
}
-
-
-// /**
-// * Retrieve a valid configuration from IS for instantiating the engine
-// */
-// public void getConfiguration2(){
-// String currentScope=ScopeProvider.instance.get();
-// ServiceEndpoint resource=getISClient().getStorageEndpoint(currentScope);
-// if((getMemoryType() != null) && ((getMemoryType().equals(MemoryType.VOLATILE.toString()) || (getMemoryType().equals(MemoryType.BOTH.toString()))))){
-// setVolatileHost(isclient.getVolatileHost(resource));
-// }
-// }
-//
-
-
+
private void setServerHosts(String[] newServer, ISClientConnector isclient, ServiceEndpoint resource) {
if((getMemoryType() != null) && ((getMemoryType().equals(MemoryType.VOLATILE.toString()) || (getMemoryType().equals(MemoryType.BOTH.toString()))))){
@@ -224,7 +206,7 @@ public class Configuration {
private String getHomeLibraryContext(){
String area=null;
- String scope=ScopeProvider.instance.get();
+ String scope= SecretManagerProvider.instance.get().getContext();
String context=null;
if (scope.startsWith("/gcube"))
context= HL_CONTEXT_DEV;
@@ -242,18 +224,18 @@ public class Configuration {
}
- protected void getOptionalPropertiesFromRR( String currentScope, ServiceEngine engine) {
+ protected void getOptionalPropertiesFromRR( ServiceEngine engine) {
String write=null;
String read=null;
String [] dbNames=null;
String dbString=null;
// check optional properties only if it is not a volatile storage instance
if((getMemoryType() != null) && (!(getMemoryType().equals(MemoryType.VOLATILE.toString())))){
- write=getISClient(getBackendType()).retrievePropertyValue(WRITE_CONCERN_PROPERTY_NAME, currentScope);
+ write=getISClient(getBackendType()).retrievePropertyValue(WRITE_CONCERN_PROPERTY_NAME);
logger.debug("read preference: read from service endpoint");
- read=getISClient(getBackendType()).retrievePropertyValue(READ_PREFERENCE_PROPERTY_NAME, currentScope);
+ read=getISClient(getBackendType()).retrievePropertyValue(READ_PREFERENCE_PROPERTY_NAME);
logger.debug(" write preference: read from service endpoint");
- dbString=getISClient(getBackendType()).retrievePropertyValue(DB_PROPERTY_NAME, currentScope);
+ dbString=getISClient(getBackendType()).retrievePropertyValue(DB_PROPERTY_NAME);
if((write!=null) && (read!=null)){
engine.setWriteConcern(write);
engine.setReadConcern(read);
@@ -272,7 +254,7 @@ public class Configuration {
}
// added db check also on volatile are
}else if((getMemoryType().equals(MemoryType.VOLATILE.toString()))){
- dbString=getISClient(getBackendType()).retrievePropertyValue(DB_PROPERTY_NAME, currentScope);
+ dbString=getISClient(getBackendType()).retrievePropertyValue(DB_PROPERTY_NAME);
if(dbString!=null){
if (dbString.contains(DB_STRING_SEPARATOR)){
logger.debug("more than one collection read from ServiceEnpoint");
@@ -386,26 +368,26 @@ public class Configuration {
@Deprecated
public String retrieveEncryptionPhrase() throws Exception {
- String currentScope=ScopeProvider.instance.get();
+ String currentScope=SecretManagerProvider.instance.get().getContext();
logger.debug("retrieve encryption prhase on scope: "+currentScope);
String encryptedKey=null;
// ISClientConnector isclient=getISClient();
logger.info("retrieve encryption phrase from scope "+currentScope);
- encryptedKey=getISClient(getBackendType()).retrievePropertyValue("PassPhrase", currentScope);
+ encryptedKey=getISClient(getBackendType()).retrievePropertyValue("PassPhrase");
logger.info("encrypted prhase is "+encryptedKey);
- String decryptString=org.gcube.common.encryption.StringEncrypter.getEncrypter().decrypt(encryptedKey);
+ String decryptString=org.gcube.common.encryption.encrypter.StringEncrypter.getEncrypter().decrypt(encryptedKey);
return decryptString;
}
public String retrieveEncryptionField(String fieldName) throws Exception {
- String currentScope=ScopeProvider.instance.get();
+ String currentScope=SecretManagerProvider.instance.get().getContext();
logger.debug("retrieve encryption prhase on scope: "+currentScope);
String encryptedKey=null;
// ISClientConnector isclient=getISClient();
logger.info("retrieve encryption phrase from scope "+currentScope);
- encryptedKey=getISClient(getBackendType()).retrievePropertyValue(fieldName, currentScope);
+ encryptedKey=getISClient(getBackendType()).retrievePropertyValue(fieldName);
logger.info("encrypted prhase is "+encryptedKey);
- String decryptString=(!Objects.isNull(encryptedKey))?org.gcube.common.encryption.StringEncrypter.getEncrypter().decrypt(encryptedKey):null;
+ String decryptString=(!Objects.isNull(encryptedKey))?org.gcube.common.encryption.encrypter.StringEncrypter.getEncrypter().decrypt(encryptedKey):null;
return decryptString;
}
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/wrapper/ISClientConnector.java b/src/main/java/org/gcube/contentmanager/storageclient/wrapper/ISClientConnector.java
index a67fe9e..0d3f9bf 100644
--- a/src/main/java/org/gcube/contentmanager/storageclient/wrapper/ISClientConnector.java
+++ b/src/main/java/org/gcube/contentmanager/storageclient/wrapper/ISClientConnector.java
@@ -10,12 +10,13 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
-import org.gcube.common.encryption.StringEncrypter;
+import org.gcube.common.encryption.encrypter.StringEncrypter;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
-import org.gcube.common.scope.api.ScopeProvider;
+
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
@@ -67,31 +68,21 @@ public class ISClientConnector {
return resources;
}
- public ServiceEndpoint getStorageEndpoint(String scope) {
+ public ServiceEndpoint getStorageEndpoint() {
//if the serviceEndpoint has been already discovered and selected, I'm going to use that
// otherwise I'm going to discovered it from IS
if(getStorageResource() == null){
logger.debug("discovering service endpoint");
- String savedScope=null;
- if(scope!=null){
- savedScope=ScopeProvider.instance.get();
- logger.debug("set scopeProvider to scope "+scope+" scope provider scope is "+savedScope);
- ScopeProvider.instance.set(scope);
- }
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Category/text() eq '"+CATEGORY+"' and $resource/Profile/Name eq '"+NAME+"' ");
DiscoveryClient client = clientFor(ServiceEndpoint.class);
List resources = client.submit(query);
- if(scope!=null){
- logger.debug("reset scopeProvider to scope "+scope);
- ScopeProvider.instance.set(savedScope);
- }
if (resources.size()>0){
ServiceEndpoint storageResource = getPriorityResource(resources);
setStorageResource(storageResource);
return storageResource;
}else
- throw new RuntimeException("Storage ServiceEndpoint not found under scope: "+scope);
+ throw new RuntimeException("Storage ServiceEndpoint not found under scope: "+SecretManagerProvider.instance.get().getContext());
}else{
logger.debug("service endpoint already discovered");
return getStorageResource();
@@ -207,8 +198,8 @@ public class ISClientConnector {
}
- public String retrievePropertyValue(String name, String scope) {
- ServiceEndpoint res = getStorageEndpoint(scope);
+ public String retrievePropertyValue(String name) {
+ ServiceEndpoint res = getStorageEndpoint();
Iterator it= res.profile().accessPoints().iterator();
String value=null;
while(it.hasNext()){
diff --git a/src/main/java/org/gcube/contentmanager/storageclient/wrapper/StorageClient.java b/src/main/java/org/gcube/contentmanager/storageclient/wrapper/StorageClient.java
index 73e4df3..4be9e84 100644
--- a/src/main/java/org/gcube/contentmanager/storageclient/wrapper/StorageClient.java
+++ b/src/main/java/org/gcube/contentmanager/storageclient/wrapper/StorageClient.java
@@ -1,13 +1,12 @@
package org.gcube.contentmanager.storageclient.wrapper;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanager.storageclient.wrapper.BackendType;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
//import org.gcube.contentmanagement.blobstorage.resource.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import java.util.Objects;
-
-import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.service.impl.ServiceEngine;
import org.gcube.contentmanagement.blobstorage.transport.backend.util.Costants;
@@ -41,53 +40,20 @@ public class StorageClient {
private static final String DEFAULT_SERVICE_NAME="Default";
private static final MemoryType DEFAULT_MEMORY_TYPE=MemoryType.PERSISTENT;
- /**
- * Constructor without optional argument created for gcube infrastructure internal use
- * @param ServiceClass
- * @param ServiceName
- * @param owner
- * @param typeAccess
- * @param scope scope identifier
- * @param forceScope if true the scope used is the scope specified in scope parameter, else the scope specified in the parameter scope is used only for discovering the RuntimeResource
- */
- @Deprecated
- public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, String scope, boolean forceScope){
- checkScopeProvider();
- if(forceScope){
- this.currentScope=ScopeProvider.instance.get();
- ScopeProvider.instance.set(scope);
- this.scopeString=ScopeProvider.instance.get();
- }else{
- this.RRScope=scope;
- this.scopeString=ScopeProvider.instance.get();
- }
- String id=owner;
- this.owner=owner;
- if(accessType!=null)
- this.typeAccess=accessType;
- else throw new RuntimeException("AccessType parameter must be not null");
- this.memoryType=MemoryType.BOTH;
- this.serviceClass=serviceClass;
- this.serviceName=serviceName;
- setClientId(serviceClass, serviceName, id);
-
- }
/**
* Constructor without optional argument created for gcube infrastructure internal use
- * @param ServiceClass
- * @param ServiceName
+ * @param serviceClass
+ * @param serviceName
* @param owner
- * @param typeAccess
- * @param scope
+ * @param accessType
*/
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType){
- checkScopeProvider();
String id=owner;
this.owner=owner;
- this.scopeString=ScopeProvider.instance.get();
+ this.scopeString=SecretManagerProvider.instance.get().getContext();
if(accessType!=null)
this.typeAccess=accessType;
else throw new RuntimeException("AccessType parameter must be not null");
@@ -103,17 +69,15 @@ public class StorageClient {
* New constructor with another optional argument created for gcube infrastructure internal use.
* Available in v1.6.0
* It's possible to specify a specific backend.
- * @param ServiceClass
- * @param ServiceName
+ * @param serviceClass
+ * @param serviceName
* @param owner
- * @param typeAccess
- * @param scope
+ * @param accessType
*/
- public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, BackendType backend){
- checkScopeProvider();
+ public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, BackendType backend){;
String id=owner;
this.owner=owner;
- this.scopeString=ScopeProvider.instance.get();
+ this.scopeString=SecretManagerProvider.instance.get().getContext();
if(accessType!=null)
this.typeAccess=accessType;
else throw new RuntimeException("AccessType parameter must be not null");
@@ -130,15 +94,13 @@ public class StorageClient {
/**
* Constructor created for external use
* @param owner
- * @param typeAccess
+ * @param accessType
* @param memory defines the kind of memory: VOLATILE or PERSISTENT
- * @param scope
*/
public StorageClient(String owner, AccessType accessType, MemoryType memory){
- checkScopeProvider();
String id=owner;
this.owner=owner;
- this.scopeString=ScopeProvider.instance.get();
+ this.scopeString=SecretManagerProvider.instance.get().getContext();
if(accessType!=null)
this.typeAccess=accessType;
else throw new RuntimeException("AccessType parameter must be not null");
@@ -153,18 +115,16 @@ public class StorageClient {
/**
* Constructor with optional argument server
- * @param ServiceClass
- * @param ServiceName
+ * @param serviceClass
+ * @param serviceName
* @param owner
- * @param typeAccess
- * @param scope
+ * @param accessType
* @param server: define the mongoDBserver
*/
public StorageClient(String serviceClass, String serviceName, String owner, String server, AccessType accessType){
- checkScopeProvider();
String id=owner;
this.owner=owner;
- this.scopeString=ScopeProvider.instance.get();
+ this.scopeString=SecretManagerProvider.instance.get().getContext();
if(accessType!=null)
this.typeAccess=accessType;
else throw new RuntimeException("AccessType parameter must be not null");
@@ -179,18 +139,16 @@ public class StorageClient {
/**
* Constructor with optional argument memoryType
- * @param ServiceClass
- * @param ServiceName
+ * @param serviceClass
+ * @param serviceName
* @param owner
- * @param typeAccess
+ * @param accessType
* @param memory defines the kind of memory: VOLATILE or PERSISTENT
- * @param scope
*/
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, MemoryType memory){
- checkScopeProvider();
String id=owner;
this.owner=owner;
- this.scopeString=ScopeProvider.instance.get();
+ this.scopeString=SecretManagerProvider.instance.get().getContext();
if(accessType!=null)
this.typeAccess=accessType;
else throw new RuntimeException("AccessType parameter must be not null");
@@ -206,19 +164,17 @@ public class StorageClient {
/**
* Available in v1.6.0
* It's possible to specify a specific backend.
- * @param ServiceClass
- * @param ServiceName
+ * @param serviceClass
+ * @param serviceName
* @param owner
- * @param typeAccess
+ * @param accessType
* @param backend: specify mongodb (default) or s3
* @param memory defines the kind of memory: VOLATILE or PERSISTENT
- * @param scope
*/
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, MemoryType memory, BackendType backend){
- checkScopeProvider();
String id=owner;
this.owner=owner;
- this.scopeString=ScopeProvider.instance.get();
+ this.scopeString=SecretManagerProvider.instance.get().getContext();
if(accessType!=null)
this.typeAccess=accessType;
else throw new RuntimeException("AccessType parameter must be not null");
@@ -235,19 +191,17 @@ public class StorageClient {
/**
* Constructor with optional arguments server and memory
- * @param ServiceClass
- * @param ServiceName
+ * @param serviceClass
+ * @param serviceName
* @param owner
- * @param typeAccess
+ * @param accessType
* @param memory defines the kind of memory: VOLATILE or PERSISTENT
* @param server: define the mongoDBserver
- * @param scope
*/
public StorageClient(String serviceClass, String serviceName, String owner, AccessType accessType, MemoryType memory, String server){
- checkScopeProvider();
String id=owner;
this.owner=owner;
- this.scopeString=ScopeProvider.instance.get();
+ this.scopeString=SecretManagerProvider.instance.get().getContext();
if(accessType!=null)
this.typeAccess=accessType;
else throw new RuntimeException("AccessType parameter must be not null");
@@ -289,11 +243,13 @@ public class StorageClient {
}
if(getMemoryType() !=null)
engine.setGcubeMemoryType(getMemoryType().toString());
- engine.setGcubeScope(ScopeProvider.instance.get());
+ engine.setGcubeScope(SecretManagerProvider.instance.get().getContext());
engine.setOwnerGcube(owner);
- cfg.getOptionalPropertiesFromRR( getCurrentScope(), engine);
- if(getCurrentScope()!=null)
- ScopeProvider.instance.set(getCurrentScope());
+ cfg.getOptionalPropertiesFromRR(engine);
+ if(getCurrentScope()!=null){
+ if(!getCurrentScope().equals(SecretManagerProvider.instance.get().getContext()))
+ logger.warn("scope force to "+getCurrentScope()+"doesn't take effect. The current scope is set to"+SecretManagerProvider.instance.get().getContext());
+ }
return engine;
}
@@ -310,23 +266,6 @@ public class StorageClient {
}
}
-
- /**
- * if the scope provider is not set then check if the env variable: SCOPE is set and set the scopeProvider
- */
- private void checkScopeProvider(){
- String scopeProvided=ScopeProvider.instance.get();
- if (scopeProvided==null){
- scopeProvided=Utils.checkVarEnv("SCOPE");
- if (scopeProvided != null){
- ScopeProvider.instance.set(scopeProvided);
- }else{
- throw new RuntimeException("Scope not set ");
- }
- }else setCurrentScope(scopeProvided);
- }
-
-
public String getClientID() {
return clientID;
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/CopyDirTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/CopyDirTest.java
index dc16078..93b45df 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/CopyDirTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/CopyDirTest.java
@@ -3,7 +3,7 @@ package org.gcube.contentmanager.storageclient.test;
import static org.junit.Assert.*;
import java.io.File;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
@@ -37,7 +37,7 @@ public class CopyDirTest {
@BeforeClass
public static void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/CopyTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/CopyTest.java
index 4d688c3..8357ecb 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/CopyTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/CopyTest.java
@@ -1,18 +1,19 @@
package org.gcube.contentmanager.storageclient.test;
+import static org.gcube.contentmanager.storageclient.test.utils.Costants.*;
import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -38,10 +39,9 @@ public class CopyTest {
@Before
public void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
-
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
- client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
+ client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
} catch (Exception e) {
// TODO Auto-generated catch block
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/CountingTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/CountingTest.java
index 9b79b96..24b7e8c 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/CountingTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/CountingTest.java
@@ -1,8 +1,9 @@
package org.gcube.contentmanager.storageclient.test;
+import static org.gcube.contentmanager.storageclient.test.utils.Costants.DEFAULT_SCOPE_STRING;
import static org.junit.Assert.*;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
@@ -25,7 +26,7 @@ public class CountingTest {
@Before
public void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.PUBLIC, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/DownloadsTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/DownloadsTest.java
index c6a912f..36f3886 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/DownloadsTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/DownloadsTest.java
@@ -9,7 +9,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import org.bson.types.ObjectId;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@@ -42,7 +42,7 @@ public class DownloadsTest {
@BeforeClass
public static void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
// ScopeProvider.instance.set(scope);
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE, Costants.BACKEND_TYPE).getClient();
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/DuplicateTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/DuplicateTest.java
index 81b37dc..d18e74d 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/DuplicateTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/DuplicateTest.java
@@ -9,7 +9,7 @@ import java.io.File;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@@ -43,7 +43,7 @@ public class DuplicateTest {
@Before
public void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/ForceCloseTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/ForceCloseTest.java
index dd585fc..973591b 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/ForceCloseTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/ForceCloseTest.java
@@ -3,7 +3,8 @@ package org.gcube.contentmanager.storageclient.test;
import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@@ -36,7 +37,7 @@ public class ForceCloseTest {
@Before
public void getClient(){
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/FwsQueryTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/FwsQueryTest.java
index da8a75c..754a776 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/FwsQueryTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/FwsQueryTest.java
@@ -1,5 +1,6 @@
package org.gcube.contentmanager.storageclient.test;
+import static org.gcube.contentmanager.storageclient.test.utils.Costants.DEFAULT_SCOPE_STRING;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import static org.junit.Assert.assertNotNull;
import static org.gcube.resources.discovery.icclient.ICFactory.*;
@@ -8,7 +9,8 @@ import java.util.List;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.utils.XPathHelper;
-import org.gcube.common.scope.api.ScopeProvider;
+
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
import org.gcube.contentmanager.storageclient.wrapper.ISClientConnector;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
@@ -21,12 +23,11 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class FwsQueryTest {
-
- String scope=Costants.DEFAULT_SCOPE_STRING;//"/gcube/devsec";
+
@Before
public void setscope(){
- ScopeProvider.instance.set(scope);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));;
}
// @Test
@@ -93,7 +94,7 @@ public class FwsQueryTest {
public void getRR() throws Exception{
System.out.println("retrieve server from RuntimeResource");
ISClientConnector isConnector= new ISClientConnector();
- ServiceEndpoint resource = isConnector.getStorageEndpoint(scope);
+ ServiceEndpoint resource = isConnector.getStorageEndpoint();
assertNotNull(resource);
String[] server=isConnector.retrieveConnectionInfo(resource);
for(int j=0; j getHTTPAuthorizationHeaders() {
+ return Collections.emptyMap();
+ }
+
+ @Override
+ public boolean isExpired() {
+ return false;
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/LinkTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/LinkTest.java
index a45f960..cac2889 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/LinkTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/LinkTest.java
@@ -5,7 +5,7 @@ import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@@ -32,7 +32,7 @@ public class LinkTest {
@Before
public void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/LockTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/LockTest.java
index 12b9c7f..cb43189 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/LockTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/LockTest.java
@@ -1,5 +1,6 @@
package org.gcube.contentmanager.storageclient.test;
+import static org.gcube.contentmanager.storageclient.test.utils.Costants.DEFAULT_SCOPE_STRING;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -7,7 +8,7 @@ import static org.junit.Assert.assertTrue;
import java.io.File;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@@ -37,7 +38,7 @@ public class LockTest {
@Before
public void getClient(){
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/MoveDirTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/MoveDirTest.java
index b82d8c0..7762404 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/MoveDirTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/MoveDirTest.java
@@ -4,7 +4,8 @@ import static org.junit.Assert.*;
import java.io.File;
-import org.gcube.common.scope.api.ScopeProvider;
+
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
@@ -33,7 +34,7 @@ public class MoveDirTest {
@BeforeClass
public static void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/MoveTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/MoveTest.java
index c2d83ed..a66164c 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/MoveTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/MoveTest.java
@@ -3,7 +3,8 @@ package org.gcube.contentmanager.storageclient.test;
import static org.junit.Assert.*;
import java.io.File;
-import org.gcube.common.scope.api.ScopeProvider;
+
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
@@ -29,7 +30,7 @@ public class MoveTest {
@Before
public void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/PropertiesTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/PropertiesTest.java
index dc02809..3ae700b 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/PropertiesTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/PropertiesTest.java
@@ -1,11 +1,12 @@
package org.gcube.contentmanager.storageclient.test;
+import static org.gcube.contentmanager.storageclient.test.utils.Costants.DEFAULT_SCOPE_STRING;
import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.RequestObject;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
@@ -34,7 +35,7 @@ public class PropertiesTest {
@BeforeClass
public static void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.PUBLIC, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/RemoveTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/RemoveTest.java
index 9b81766..343d130 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/RemoveTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/RemoveTest.java
@@ -5,7 +5,7 @@ import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@@ -33,7 +33,7 @@ public class RemoveTest {
@Before
public void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/RemoveVolatileArea.java b/src/test/java/org/gcube/contentmanager/storageclient/test/RemoveVolatileArea.java
index 235dde6..16bde67 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/RemoveVolatileArea.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/RemoveVolatileArea.java
@@ -7,7 +7,7 @@ import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@@ -33,8 +33,7 @@ public class RemoveVolatileArea {
@Before
public void getClient() throws RemoteBackendException{
-// ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
- ScopeProvider.instance.set(scope);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/ReplaceFileTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/ReplaceFileTest.java
index 2bbe6c8..eb8a089 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/ReplaceFileTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/ReplaceFileTest.java
@@ -3,12 +3,14 @@
*/
package org.gcube.contentmanager.storageclient.test;
+import static org.gcube.contentmanager.storageclient.test.utils.Costants.DEFAULT_SCOPE_STRING;
import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@@ -42,7 +44,7 @@ public class ReplaceFileTest {
@Before
public void getClient(){
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/SoftCopyTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/SoftCopyTest.java
index 5d128da..57fefa3 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/SoftCopyTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/SoftCopyTest.java
@@ -8,7 +8,7 @@ import static org.junit.Assert.*;
import java.io.File;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@@ -47,7 +47,7 @@ public class SoftCopyTest {
@BeforeClass
public static void getClient() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/UploadsTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/UploadsTest.java
index db8c1ae..7e926db 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/UploadsTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/UploadsTest.java
@@ -10,7 +10,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
@@ -39,7 +39,7 @@ public class UploadsTest {
@BeforeClass
public static void getClient(){
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client=new StorageClient(serviceClass, serviceName, owner, AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
assertNotNull(client);
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverByIdTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverByIdTest.java
index d255aa4..831e14e 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverByIdTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverByIdTest.java
@@ -10,14 +10,12 @@ import java.net.URL;
import java.net.URLConnection;
import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
-import org.gcube.contentmanager.storageclient.model.protocol.smp.Handler;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
-import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.junit.After;
import org.junit.Before;
@@ -45,7 +43,7 @@ public class UrlResolverByIdTest {
@Before
public void init() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client = new StorageClient(serviceClass, serviceName, owner , AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
} catch (Exception e) {
@@ -65,12 +63,6 @@ public class UrlResolverByIdTest {
String url=client.getHttpsUrl(true).RFile(id);
System.out.println("httpsUrl generated: "+url);
assertNotNull(url);
-// id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
-
-
-// System.out.println("id retrieved: "+id);
-// client.moveFile().from(remotePath).to(newPath);
- verifyUrl(url);
}
@@ -84,7 +76,6 @@ public class UrlResolverByIdTest {
assertNotNull(url);
System.out.println("id retrieved: "+id);
client.moveFile().from(remotePath).to(newPath);
- verifyUrl(url);
client.moveFile().from(newPath).to(remotePath);
}
@@ -98,47 +89,8 @@ public class UrlResolverByIdTest {
System.out.println("id encrypted: "+id);
client.get().RFileAsInputStream(remotePath);
client.moveFile().from(remotePath).to(newPath);
- verifyUrl(url);
client.moveFile().from(newPath).to(remotePath);
}
-
-
- /**
- * download the file and verify if the file exist
- * @param url
- */
- @Deprecated
- private void verifyUrl(String url) {
- Handler.activateProtocol();
- URL smsHome = null;
- try {
- smsHome = new URL(url);
- } catch (MalformedURLException e1) {
- e1.printStackTrace();
- }
- URLConnection uc = null;
- File f=null;
- try {
- uc = ( URLConnection ) smsHome.openConnection ( );
- InputStream is=uc.getInputStream();
- f=new File(localNewPath);
- FileOutputStream out=new FileOutputStream(f);
- byte buf[]=new byte[1024];
- int len=0;
- System.out.println("InputStream "+is);
- while((len=is.read(buf))>0){
- out.write(buf,0,len);
- }
- out.close();
- is.close();
- }catch(Exception e ){
- e.printStackTrace();
- assertTrue(false);
- }
- assertTrue(f.exists());
- }
-
-
@After
@@ -146,9 +98,6 @@ public class UrlResolverByIdTest {
String id=client.remove().RFile(remotePath);
List list=client.showDir().RDir("Uritest/img");
assertTrue(list.isEmpty());
-// String id2=client.remove().RFile(newPath);
-// List list2=client.showDir().RDir("Uritest/img5");
-// assertTrue(list.isEmpty());
removeLocalFiles();
}
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverTest.java
index 8745e33..6344806 100644
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverTest.java
+++ b/src/test/java/org/gcube/contentmanager/storageclient/test/UrlResolverTest.java
@@ -1,19 +1,14 @@
package org.gcube.contentmanager.storageclient.test;
-import static org.junit.Assert.*;
import java.io.File;
-import java.util.List;
-import org.gcube.common.scope.api.ScopeProvider;
-import org.gcube.contentmanagement.blobstorage.resource.StorageObject;
+import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanager.storageclient.test.utils.Costants;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
-import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -31,7 +26,7 @@ public class UrlResolverTest {
@Before
public void init() throws RemoteBackendException{
- ScopeProvider.instance.set(Costants.DEFAULT_SCOPE_STRING);
+ SecretManagerProvider.instance.set(new ICSecret(Costants.DEFAULT_SCOPE_STRING));
try {
client = new StorageClient(serviceClass, serviceName, owner , AccessType.SHARED, Costants.DEFAULT_MEMORY_TYPE).getClient();
} catch (Exception e) {
@@ -41,13 +36,7 @@ public class UrlResolverTest {
setLocalResources();
String id=client.put(true).LFile(absoluteLocalPath).RFile(remotePath);
}
-
-
- @Test
- public void getUrl() throws RemoteBackendException {
- String url=client.getUrl().RFile(remotePath);
- System.out.println("url generated: "+url);
- }
+
@Test
public void getHttpsUrl() throws RemoteBackendException {
diff --git a/src/test/java/org/gcube/contentmanager/storageclient/test/scopeValidationTest.java b/src/test/java/org/gcube/contentmanager/storageclient/test/scopeValidationTest.java
deleted file mode 100644
index 934baa9..0000000
--- a/src/test/java/org/gcube/contentmanager/storageclient/test/scopeValidationTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.gcube.contentmanager.storageclient.test;
-
-import static org.junit.Assert.*;
-
-import org.gcube.common.scope.impl.ServiceMapScannerMediator;
-import org.gcube.contentmanager.storageclient.test.utils.Costants;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class scopeValidationTest {
-
- static ServiceMapScannerMediator scanner;
-// String scope="/gcube";
-
- @BeforeClass
- public static void init(){
- scanner=new ServiceMapScannerMediator();
- }
-
-
- @Test
- public void test() {
- assertTrue(scanner.isValid(Costants.DEFAULT_SCOPE_STRING));
- }
-
-}