Fabio Sinibaldi 2016-09-08 15:14:08 +00:00
parent 7ac5508a1b
commit d46e112929
2 changed files with 16 additions and 5 deletions

View File

@ -24,4 +24,17 @@ public class ScopeUtils {
}
}
public static String getCurrentCaller(){
try{
String token=SecurityTokenProvider.instance.get();
log.debug("Token is : "+token);
if(token==null) throw new Exception("Security Token is null");
AuthorizationEntry entry = authorizationService().get(token);
return entry.getClientInfo().getId();
}catch(Exception e ){
log.debug("Unable to resolve token, checking scope provider..",e);
return "Unidentified data-transfer user";
}
}
}

View File

@ -4,21 +4,19 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import lombok.extern.slf4j.Slf4j;
import org.bson.types.ObjectId;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanagement.blobstorage.transport.backend.RemoteBackendException;
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class StorageUtils {
public static final IClient getClient(){
return new StorageClient("data-transfer", "data-transfer", "own", AccessType.SHARED, MemoryType.VOLATILE).getClient();
return new StorageClient("data-transfer", "data-transfer-library", ScopeUtils.getCurrentCaller(), AccessType.SHARED, MemoryType.VOLATILE).getClient();
}