integration with AccessTokenProvider
This commit is contained in:
parent
97184640f1
commit
90899ec0cf
|
@ -10,7 +10,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import org.cache2k.Cache;
|
||||
import org.cache2k.Cache2kBuilder;
|
||||
import org.gcube.common.authorization.library.AuthorizedTasks;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.storagehub.client.dsl.ContainerType;
|
||||
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||
|
@ -63,8 +63,11 @@ public class StorageHubFS extends FuseStubFS {
|
|||
super();
|
||||
this.token = token;
|
||||
this.scope = scope;
|
||||
|
||||
logger.debug("using token {} in scope {}", token , scope);
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
client = new StorageHubClient();
|
||||
rootDirectory = client.getWSRoot();
|
||||
cache = new Cache2kBuilder<String, ItemContainer<Item>>() {}
|
||||
|
@ -81,7 +84,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
@Override
|
||||
public synchronized int write(String path, Pointer buf, long size, long offset, FuseFileInfo fi) {
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
|
||||
logger.trace("{}) calling write {} - {} ",Thread.currentThread().getName(), size , offset);
|
||||
SHFile file = tempFiles.get(path);
|
||||
|
@ -110,7 +113,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
@Override
|
||||
public synchronized int create(final String path, @mode_t long mode, FuseFileInfo fi) {
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
|
||||
logger.trace(Thread.currentThread().getName()+" ) calling create "+path);
|
||||
if (pathUtils.getPath(path) != null) {
|
||||
|
@ -163,7 +166,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
public int getattr(String path, FileStat stat) {
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
|
||||
logger.trace(Thread.currentThread().getName()+" ) calling getattr "+path);
|
||||
if (Objects.equals(path, "/") || path.contains("Trash") || path.equals("/"+VREFOLDERS_NAME)) {
|
||||
|
@ -226,7 +229,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
@Override
|
||||
public int mkdir(String path, @mode_t long mode) {
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
|
||||
logger.trace(Thread.currentThread().getName()+" ) calling mkdir");
|
||||
|
||||
|
@ -256,7 +259,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
@Override
|
||||
public int read(String path, Pointer buf, @size_t long size, @off_t long offset, FuseFileInfo fi) {
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
|
||||
logger.trace("!!! read called in path {} with size {} and offset {} and pointer address {}",path, size, offset, buf.address());
|
||||
|
||||
|
@ -324,7 +327,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
public int readdir(String path, Pointer buf, FuseFillDir filter, @off_t long offset, FuseFileInfo fi) {
|
||||
logger.trace("readdir called");
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
|
||||
logger.trace(Thread.currentThread().getName()+" ) calling readdir "+path);
|
||||
if (path.contains(".Trash")) return 0;
|
||||
|
@ -417,7 +420,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
@Override
|
||||
public int rename(String path, String newName) {
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
|
||||
ItemContainer<? extends Item> folder = pathUtils.getPath(path);
|
||||
if (folder == null) {
|
||||
|
@ -455,7 +458,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
return -ErrorCodes.EACCES();
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
|
||||
ItemContainer<? extends Item> folder = pathUtils.getPath(path);
|
||||
if (folder == null) {
|
||||
|
@ -465,7 +468,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
return -ErrorCodes.ENOTDIR();
|
||||
}
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
try {
|
||||
checkSpecialFolderRemove(path);
|
||||
|
||||
|
@ -494,7 +497,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
@Override
|
||||
public int unlink(String path) {
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
|
||||
ItemContainer<? extends Item> file = pathUtils.getPath(path);
|
||||
if (file == null) {
|
||||
|
@ -504,7 +507,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
return -ErrorCodes.EISDIR();
|
||||
}
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
try {
|
||||
file.delete();
|
||||
cache.remove(path);
|
||||
|
@ -540,7 +543,7 @@ public class StorageHubFS extends FuseStubFS {
|
|||
logger.info("truncate called {} ",path);
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(token);
|
||||
AccessTokenProvider.instance.set(token);
|
||||
cache.remove(path);
|
||||
uploadFile(path);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue