diff --git a/.classpath b/.classpath index 002ad57..f0e9804 100644 --- a/.classpath +++ b/.classpath @@ -9,6 +9,7 @@ + @@ -22,9 +23,10 @@ + - + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 2f5cc74..2af1e7b 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,8 +1,8 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 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 +org.eclipse.jdt.core.compiler.source=11 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2af0d0c..53c404b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm # Changelog for org.gcube.data-access.sh-fuse-integration +## [v3.0.0-SNAPSHOT] 2023-05-23 + +- porting to gcube-bom 4.0.0 + ## [v2.0.1] 2021-02-09 ### Fix diff --git a/pom.xml b/pom.xml index c0f9add..9eb484e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,22 +4,19 @@ 4.0.0 org.gcube.data-access sh-fuse-integration - 2.0.1 + 3.0.0-SNAPSHOT SHFuseIntegration - maven-parent org.gcube.tools - 1.1.0 + 1.2.0 - scm:git:https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration.git scm:git:https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration.git https://code-repo.d4science.org/gCubeSystem/sh-fuse-integration - central @@ -27,44 +24,46 @@ https://jcenter.bintray.com - + + 17 + 17 + org.gcube.distribution gcube-bom - 2.0.1 + 4.0.0 pom import - com.github.serceman jnr-fuse - 0.5.4 + 0.5.8 org.gcube.common gxJRS - org.gcube.common - common-authorization + common-security + + + org.gcube.common.security + gcube-secrets - org.gcube.common storagehub-client-library - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) org.gcube.common storagehub-model - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) org.gcube.core @@ -79,7 +78,6 @@ org.slf4j slf4j-api - junit junit @@ -91,39 +89,28 @@ logback-classic - - - - org.apache.maven.plugins - maven-assembly-plugin - - - package - - single - - - - - org.gcube.data.access.storagehub.fs.StorageHubFuseLauncher - - - - - jar-with-dependencies - - - - - - - maven-compiler-plugin - - 1.8 - 1.8 - - - - + + + org.apache.maven.plugins + maven-shade-plugin + 3.4.1 + + + package + + shade + + + + + org.gcube.data.access.storagehub.fs.StorageHubFuseLauncher + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/data/access/storagehub/fs/StorageHubFS.java b/src/main/java/org/gcube/data/access/storagehub/fs/StorageHubFS.java index 41d38d1..8e2b700 100644 --- a/src/main/java/org/gcube/data/access/storagehub/fs/StorageHubFS.java +++ b/src/main/java/org/gcube/data/access/storagehub/fs/StorageHubFS.java @@ -9,9 +9,11 @@ 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.AccessTokenProvider; -import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.common.security.AuthorizedTasks; +import org.gcube.common.security.providers.SecretManagerProvider; +import org.gcube.common.security.secrets.GCubeSecret; +import org.gcube.common.security.secrets.Secret; +import org.gcube.common.security.secrets.UmaTokenSecret; import org.gcube.common.storagehub.client.dsl.ContainerType; import org.gcube.common.storagehub.client.dsl.FileContainer; import org.gcube.common.storagehub.client.dsl.FolderContainer; @@ -43,9 +45,7 @@ public class StorageHubFS extends FuseStubFS { StorageHubClient client; - String token; - - String scope; + Secret secret; HashMap tempFiles = new HashMap<>(); @@ -58,16 +58,15 @@ public class StorageHubFS extends FuseStubFS { private FolderContainer rootDirectory; - public StorageHubFS(String token, String scope) { + public StorageHubFS(String token) { super(); - this.token = token; - this.scope = scope; + this.secret = new GCubeSecret(token); - logger.debug("using token {} in scope {}", token , scope); + logger.debug("using token {}", token); + + SecretManagerProvider.set(secret); - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); client = new StorageHubClient(); rootDirectory = client.getWSRoot(); cache = new Cache2kBuilder>() {} @@ -83,9 +82,8 @@ public class StorageHubFS extends FuseStubFS { */ @Override public synchronized int write(String path, Pointer buf, long size, long offset, FuseFileInfo fi) { - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); - + SecretManagerProvider.set(secret); + logger.trace("{}) calling write {} - {} ",Thread.currentThread().getName(), size , offset); SHFile file = tempFiles.get(path); @@ -112,8 +110,7 @@ public class StorageHubFS extends FuseStubFS { */ @Override public synchronized int create(final String path, @mode_t long mode, FuseFileInfo fi) { - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); + SecretManagerProvider.set(secret); logger.trace(Thread.currentThread().getName()+" ) calling create "+path); if (pathUtils.getPath(path) != null) { @@ -165,8 +162,7 @@ public class StorageHubFS extends FuseStubFS { @Override public int getattr(String path, FileStat stat) { - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); + SecretManagerProvider.set(secret); logger.trace(Thread.currentThread().getName()+" ) calling getattr "+path); if (Objects.equals(path, "/") || path.contains("Trash") || path.equals("/"+VREFOLDERS_NAME)) { @@ -228,9 +224,8 @@ public class StorageHubFS extends FuseStubFS { @Override public int mkdir(String path, @mode_t long mode) { - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); - + SecretManagerProvider.set(secret); + logger.trace(Thread.currentThread().getName()+" ) calling mkdir"); ItemContainer parentContainer; @@ -258,9 +253,8 @@ 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); - AccessTokenProvider.instance.set(token); - + SecretManagerProvider.set(secret); + logger.trace("!!! read called in path {} with size {} and offset {} and pointer address {}",path, size, offset, buf.address()); SHFile fileDownload = null; @@ -326,9 +320,8 @@ public class StorageHubFS extends FuseStubFS { @Override public int readdir(String path, Pointer buf, FuseFillDir filter, @off_t long offset, FuseFileInfo fi) { logger.trace("readdir called"); - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); - + SecretManagerProvider.set(secret); + logger.trace(Thread.currentThread().getName()+" ) calling readdir "+path); if (path.contains(".Trash")) return 0; @@ -419,9 +412,8 @@ public class StorageHubFS extends FuseStubFS { @Override public int rename(String path, String newName) { - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); - + SecretManagerProvider.set(secret); + ItemContainer folder = pathUtils.getPath(path); if (folder == null) { return -ErrorCodes.ENOENT(); @@ -457,9 +449,8 @@ public class StorageHubFS extends FuseStubFS { if (path.equals("/"+VREFOLDERS_NAME)) return -ErrorCodes.EACCES(); - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); - + SecretManagerProvider.set(secret); + ItemContainer folder = pathUtils.getPath(path); if (folder == null) { return -ErrorCodes.ENOENT(); @@ -467,8 +458,9 @@ public class StorageHubFS extends FuseStubFS { if (folder.getType()!=ContainerType.FOLDER) { return -ErrorCodes.ENOTDIR(); } - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); + + SecretManagerProvider.set(secret); + try { checkSpecialFolderRemove(path); @@ -496,9 +488,10 @@ public class StorageHubFS extends FuseStubFS { */ @Override public int unlink(String path) { - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); - + + SecretManagerProvider.set(secret); + + ItemContainer file = pathUtils.getPath(path); if (file == null) { return -ErrorCodes.ENOENT(); @@ -506,8 +499,9 @@ public class StorageHubFS extends FuseStubFS { if (file.getType()!=ContainerType.FILE) { return -ErrorCodes.EISDIR(); } - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); + + SecretManagerProvider.set(secret); + try { file.delete(); cache.remove(path); @@ -542,8 +536,8 @@ public class StorageHubFS extends FuseStubFS { public int truncate(String path, long size) { logger.info("truncate called {} ",path); - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(token); + SecretManagerProvider.set(secret); + cache.remove(path); uploadFile(path); return 0; diff --git a/src/main/java/org/gcube/data/access/storagehub/fs/StorageHubFuseLauncher.java b/src/main/java/org/gcube/data/access/storagehub/fs/StorageHubFuseLauncher.java index ff4bdd2..cf5ec2f 100644 --- a/src/main/java/org/gcube/data/access/storagehub/fs/StorageHubFuseLauncher.java +++ b/src/main/java/org/gcube/data/access/storagehub/fs/StorageHubFuseLauncher.java @@ -7,10 +7,9 @@ public class StorageHubFuseLauncher { public static void main(String ...args) { String token = args[0]; - String scope = args[1]; - String path = args[2]; + String path = args[1]; - StorageHubFS shFS= new StorageHubFS(token, scope); + StorageHubFS shFS= new StorageHubFS(token); shFS.mount(Paths.get(path), true, true); } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 3058778..b901a05 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -1,17 +1,20 @@ - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{0}: %msg%n - - - - - - + + ./fuse.log + true + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger: %msg%n + + + + + + + + + + + - - - - \ No newline at end of file diff --git a/src/test/java/org/gcube/data/access/storagehub/fuse/FuseTest.java b/src/test/java/org/gcube/data/access/storagehub/fuse/FuseTest.java index b080282..39f29d0 100644 --- a/src/test/java/org/gcube/data/access/storagehub/fuse/FuseTest.java +++ b/src/test/java/org/gcube/data/access/storagehub/fuse/FuseTest.java @@ -11,7 +11,7 @@ public class FuseTest { @Test public void mount() { - StorageHubFS memfs = new StorageHubFS("AccessToken","/gcube"); + StorageHubFS memfs = new StorageHubFS("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548"); try { String path; switch (Platform.getNativePlatform().getOS()) { @@ -20,7 +20,7 @@ public class FuseTest { path = "J:\\"; break; default: - path = "/home/lucio/java/mnt"; + path = "/Users/lucio/java/mnt"; } memfs.mount(Paths.get(path), true, true); } finally {