diff --git a/.classpath b/.classpath index 32f3561..604f936 100644 --- a/.classpath +++ b/.classpath @@ -13,15 +13,16 @@ - - - - - + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index da3b103..ec55441 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,6 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=11 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index cd2a88f..70af49f 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,6 +1,15 @@ + + - + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index f4bf050..54a5299 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,5 +1,5 @@ - + diff --git a/CHANGELOG.md b/CHANGELOG.md index df22c33..c8b0b37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,9 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v2.1.1] - [2022-12-06] +## [v3.0.0-SNAPSHOT] - [2022-05-13] -solved a bug on removeContext +porting to new IAM ## [v2.1.0] - [2022-02-04] diff --git a/distro/LICENSE b/distro/LICENSE deleted file mode 100644 index 2d9616a..0000000 --- a/distro/LICENSE +++ /dev/null @@ -1 +0,0 @@ -${gcube.license} \ No newline at end of file diff --git a/distro/README b/distro/README deleted file mode 100644 index bd2025c..0000000 --- a/distro/README +++ /dev/null @@ -1,66 +0,0 @@ -The gCube System - ${name} --------------------------------------------------- - -${description} - -${gcube.description} - -${gcube.funding} - - -Version --------------------------------------------------- - -${version} (${buildDate}) - -Please see the file named "changelog.xml" in this directory for the release notes. - - -Authors --------------------------------------------------- - -* Fabio Simeoni (fabio.simeoni@fao.org), FAO of the UN, Italy -* Lucio Lelii (lucio.lelii@isti.cnr.it), CNR, Italy - - -Maintainers ------------ - -* Lucio Lelii (lucio.lelii@isti.cnr.it), CNR, Italy - - -Download information --------------------------------------------------- - -Source code is available from SVN: - ${scm.url} - -Binaries can be downloaded from the gCube website: - ${gcube.website} - - -Installation --------------------------------------------------- - -Installation documentation is available on-line in the gCube Wiki: - ${gcube.wikiRoot}/Smartgears - - -Documentation --------------------------------------------------- - -Documentation is available on-line in the gCube Wiki: - ${gcube.wikiRoot}/Smartgears - - -Support --------------------------------------------------- - -Bugs and support requests can be reported in the gCube issue tracking tool: - ${gcube.issueTracking} - - -Licensing --------------------------------------------------- - -This software is licensed under the terms you may find in the file named "LICENSE" in this directory. \ No newline at end of file diff --git a/distro/changelog.xml b/distro/changelog.xml deleted file mode 100644 index 9f1044a..0000000 --- a/distro/changelog.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - Chaching for proxing of AppManager objects added - - - Added support for initialization using security token - - - First Release - - \ No newline at end of file diff --git a/distro/descriptor.xml b/distro/descriptor.xml deleted file mode 100644 index e395580..0000000 --- a/distro/descriptor.xml +++ /dev/null @@ -1,32 +0,0 @@ - - servicearchive - - tar.gz - - / - - - ${distroDirectory} - / - true - - README - LICENSE - changelog.xml - profile.xml - - 755 - true - - - - - target/${build.finalName}.${project.packaging} - /${artifactId} - - - - \ No newline at end of file diff --git a/distro/profile.xml b/distro/profile.xml deleted file mode 100644 index 91c49e4..0000000 --- a/distro/profile.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - Service - - ${description} - Common - ${artifactId} - 1.0.0 - - - ${artifactId} - ${version} - - ${groupId} - ${artifactId} - ${version} - - - ${build.finalName}.jar - - - - - - diff --git a/pom.xml b/pom.xml index 89ebe96..a43dbd1 100644 --- a/pom.xml +++ b/pom.xml @@ -11,14 +11,15 @@ org.gcube.core common-smartgears-app - 2.1.1 + + 3.0.0-SNAPSHOT Smartgears Application - distro - 1.8 - 1.8 + UTF-8 + 11 + 11 @@ -27,6 +28,18 @@ https://code-repo.d4science.org/gCubeSystem/common-smartgears-app + + + + org.gcube.distribution + gcube-smartgears-bom + 3.0.0-SNAPSHOT + pom + import + + + + @@ -39,7 +52,6 @@ org.reflections reflections - 0.9.10 @@ -59,10 +71,14 @@ org.gcube.core common-smartgears - [3.0.0-SNAPSHOT,4.0.0-SNAPSHOT) - provided + + org.gcube.common + common-security + + + junit junit @@ -72,40 +88,4 @@ - - - - - - - org.apache.maven.plugins - maven-resources-plugin - - - copy-profile - install - - copy-resources - - - target - - - ${distroDirectory} - true - - profile.xml - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/java/org/gcube/smartgears/ApplicationManagerProvider.java b/src/main/java/org/gcube/smartgears/ApplicationManagerProvider.java index 6877106..b5bcae3 100644 --- a/src/main/java/org/gcube/smartgears/ApplicationManagerProvider.java +++ b/src/main/java/org/gcube/smartgears/ApplicationManagerProvider.java @@ -32,16 +32,19 @@ public abstract class ApplicationManagerProvider { protected static synchronized void init(ApplicationContext appcontext) { if (!initialized) { - if (appcontext.container().configuration().mode()== Mode.offline) + if (appcontext.container().configuration().mode()== Mode.offline) instance = new OfflineProvider(); + else instance = new OnlineProvider(); + initialized =true; } } public static synchronized ApplicationManager get(final Class applicationManagerClass){ if (!initialized) throw new RuntimeException("ApplicationManagerProvider not yet initialized"); + logger.debug("retrieveing application manager of {} ",applicationManagerClass.getCanonicalName()); Object obj = instance.getApplicationManagerObject(applicationManagerClass); return applicationManagerClass.cast(obj); } @@ -56,16 +59,17 @@ public abstract class ApplicationManagerProvider { logger.trace("getting object {} from cache ",_class.getCanonicalName()); return obj; } else { - obj = _class.newInstance(); + obj = _class.getDeclaredConstructor().newInstance(); classProxyObjetMap.put(_class.getCanonicalName(), obj); } - + + logger.debug("proxy created for {} ",applicationManagerClass.getCanonicalName()); } catch (Exception e) { throw new RuntimeException("error creating proxy ", e); } - ((ProxyObject)obj).setHandler(getMethdoHandler(applicationManagerClass)); + ((ProxyObject)obj).setHandler(this.getMethodHandler(applicationManagerClass)); return obj; } @@ -108,7 +112,7 @@ public abstract class ApplicationManagerProvider { } protected abstract Future retrieveFuture(Class applicationManagerClass); - protected abstract MethodHandler getMethdoHandler(Class applicationManagerClass); + protected abstract MethodHandler getMethodHandler(Class applicationManagerClass); protected abstract AppManagerObserver getObserver(); } diff --git a/src/main/java/org/gcube/smartgears/ContextListener.java b/src/main/java/org/gcube/smartgears/ContextListener.java index 343f66c..44df785 100644 --- a/src/main/java/org/gcube/smartgears/ContextListener.java +++ b/src/main/java/org/gcube/smartgears/ContextListener.java @@ -4,12 +4,10 @@ import java.net.URL; import java.util.Collection; import java.util.HashSet; import java.util.Set; - import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import javax.servlet.annotation.WebListener; -import org.gcube.smartgears.Constants; import org.gcube.smartgears.annotations.ManagedBy; import org.gcube.smartgears.application.manager.AppManagerObserver; import org.gcube.smartgears.context.application.ApplicationContext; @@ -61,15 +59,14 @@ public class ContextListener implements ServletContextListener { Set> managers = new HashSet>(); for (Class initializer: toInitialize ){ ManagedBy manageBy = initializer.getAnnotation(ManagedBy.class); - log.info("ApplicationManager added {} @ {}", manageBy.value().getSimpleName(), context.name()); + log.info("ApplicationManager added {} to {} @ {}", manageBy.value().getSimpleName(), initializer.getSimpleName(), context.name()); managers.add(manageBy.value()); } if (managers.size()>0){ observer = ApplicationManagerProvider.instance.getObserver(); - observer.setStartingTokens(context.configuration().startTokens()); + observer.setAuthorizationProvider(context.container().authorizationProvider()); observer.setApplicationManagerClasses(managers); observer.register(); - context.events().subscribe(observer); } } diff --git a/src/main/java/org/gcube/smartgears/ContextProvider.java b/src/main/java/org/gcube/smartgears/ContextProvider.java index 4398a32..a893f5e 100644 --- a/src/main/java/org/gcube/smartgears/ContextProvider.java +++ b/src/main/java/org/gcube/smartgears/ContextProvider.java @@ -8,7 +8,8 @@ import org.gcube.smartgears.context.Properties; import org.gcube.smartgears.context.application.ApplicationContext; import org.gcube.smartgears.context.container.ContainerContext; import org.gcube.smartgears.lifecycle.application.ApplicationLifecycle; -import org.gcube.smartgears.persistence.Persistence; +import org.gcube.smartgears.persistence.PersistenceWriter; +import org.gcube.smartgears.security.AuthorizationProvider; /** * Embedded in an application, makes available its context as a gCube resource. @@ -56,12 +57,7 @@ public class ContextProvider { public ApplicationConfiguration configuration() { return delegate.configuration(); } - - @Override - public T profile(Class type) { - return delegate.profile(type); - } - + @Override public ApplicationLifecycle lifecycle() { return delegate.lifecycle(); @@ -71,12 +67,7 @@ public class ContextProvider { public Hub events() { return delegate.events(); } - - @Override - public Persistence persistence() { - return delegate.persistence(); - } - + @Override public ServletContext application() { return delegate.application(); @@ -96,6 +87,16 @@ public class ContextProvider { public String id() { return delegate.id(); } + + @Override + public PersistenceWriter persistence() { + return delegate.persistence(); + } + + @Override + public AuthorizationProvider authorizationProvider() { + return delegate.authorizationProvider(); + } } } diff --git a/src/main/java/org/gcube/smartgears/ManagerPair.java b/src/main/java/org/gcube/smartgears/ManagerPair.java index 2fd896a..cd5bf92 100644 --- a/src/main/java/org/gcube/smartgears/ManagerPair.java +++ b/src/main/java/org/gcube/smartgears/ManagerPair.java @@ -23,4 +23,8 @@ public class ManagerPair { } +<<<<<<< HEAD } +======= +} +>>>>>>> refs/remotes/origin/feature/22955 diff --git a/src/main/java/org/gcube/smartgears/application/manager/AppManagerObserver.java b/src/main/java/org/gcube/smartgears/application/manager/AppManagerObserver.java index 13c1844..693d0cd 100644 --- a/src/main/java/org/gcube/smartgears/application/manager/AppManagerObserver.java +++ b/src/main/java/org/gcube/smartgears/application/manager/AppManagerObserver.java @@ -1,10 +1,10 @@ package org.gcube.smartgears.application.manager; -import java.util.Collection; import java.util.Set; import org.gcube.smartgears.ApplicationManager; import org.gcube.smartgears.context.application.ApplicationContext; +import org.gcube.smartgears.security.AuthorizationProvider; public interface AppManagerObserver { @@ -16,7 +16,7 @@ public interface AppManagerObserver { void unregister(); - void setStartingTokens(Collection startingTokens); + public void setAuthorizationProvider(AuthorizationProvider authProvider); void setApplicationManagerClasses(Set> managersClasses); diff --git a/src/main/java/org/gcube/smartgears/application/manager/OfflineObserver.java b/src/main/java/org/gcube/smartgears/application/manager/OfflineObserver.java index bd65043..e2ec55f 100644 --- a/src/main/java/org/gcube/smartgears/application/manager/OfflineObserver.java +++ b/src/main/java/org/gcube/smartgears/application/manager/OfflineObserver.java @@ -1,6 +1,5 @@ package org.gcube.smartgears.application.manager; -import java.util.Collection; import java.util.Set; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -13,6 +12,7 @@ import org.gcube.common.events.Observes.Kind; import org.gcube.smartgears.ApplicationManager; import org.gcube.smartgears.Constants; import org.gcube.smartgears.context.application.ApplicationContext; +import org.gcube.smartgears.security.AuthorizationProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -79,7 +79,7 @@ public class OfflineObserver implements AppManagerObserver { @Override public ApplicationManager call() throws Exception { - ApplicationManager manager = managerClass.newInstance(); + ApplicationManager manager = managerClass.getDeclaredConstructor().newInstance(); try { log.info("calling on onInit of {}",manager.getClass().getCanonicalName()); manager.onInit(); @@ -109,13 +109,15 @@ public class OfflineObserver implements AppManagerObserver { } } - @Override - public void setStartingTokens(Collection startingTokens) { - } + @Override public void setApplicationManagerClasses(Set> managerClasses) { this.managerClasses = managerClasses; } + + @Override + public void setAuthorizationProvider(AuthorizationProvider authProvider) { + } } diff --git a/src/main/java/org/gcube/smartgears/application/manager/OfflineProvider.java b/src/main/java/org/gcube/smartgears/application/manager/OfflineProvider.java index 49f915f..22f947a 100644 --- a/src/main/java/org/gcube/smartgears/application/manager/OfflineProvider.java +++ b/src/main/java/org/gcube/smartgears/application/manager/OfflineProvider.java @@ -27,7 +27,7 @@ public class OfflineProvider extends ApplicationManagerProvider { } @Override - protected MethodHandler getMethdoHandler(Class applicationManagerClass) { + protected MethodHandler getMethodHandler(Class applicationManagerClass) { MethodHandler handler = new MethodHandler() { @Override public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { diff --git a/src/main/java/org/gcube/smartgears/application/manager/OnlineObserver.java b/src/main/java/org/gcube/smartgears/application/manager/OnlineObserver.java index fd66ecf..1d7a34d 100644 --- a/src/main/java/org/gcube/smartgears/application/manager/OnlineObserver.java +++ b/src/main/java/org/gcube/smartgears/application/manager/OnlineObserver.java @@ -1,9 +1,6 @@ package org.gcube.smartgears.application.manager; -import static org.gcube.common.authorization.client.Constants.authorizationService; - import java.util.ArrayList; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -13,15 +10,15 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.gcube.common.authorization.client.exceptions.ObjectNotFound; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.events.Observes; import org.gcube.common.events.Observes.Kind; -import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.common.security.providers.SecretManagerProvider; +import org.gcube.common.security.secrets.Secret; import org.gcube.smartgears.ApplicationManager; import org.gcube.smartgears.Constants; import org.gcube.smartgears.ManagerPair; import org.gcube.smartgears.context.application.ApplicationContext; +import org.gcube.smartgears.security.AuthorizationProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +32,11 @@ public class OnlineObserver implements AppManagerObserver{ private OnlineProvider provider; +<<<<<<< HEAD private Collection startingTokens; +======= + private AuthorizationProvider authProvider; +>>>>>>> refs/remotes/origin/feature/22955 private Set> managersClasses; @@ -45,21 +46,30 @@ public class OnlineObserver implements AppManagerObserver{ } public void register() { - for (String startingToken : startingTokens ) - this.onRegistration(startingToken); + for (String context : authProvider.getContexts()) { + this.onRegistration(context); + } } @Observes(value=Constants.token_registered, kind=Kind.safe) +<<<<<<< HEAD public synchronized void onRegistration(final String securityToken){ log.info("token registered called with token {}", securityToken); +======= + public synchronized void onRegistration(String context){ + log.info("registration called in context {}", context); +>>>>>>> refs/remotes/origin/feature/22955 List futureList = new ArrayList(); try { - final String context = authorizationService().get(securityToken).getContext(); + + Secret secret = authProvider.getSecretForContext(context); for (Class appManager: managersClasses){ - Future appManagerFuture = service.submit(new InitAppManager(securityToken, context, appManager)); - log.info("intializing app in context {} with token {} ",context, securityToken); + + + Future appManagerFuture = service.submit(new InitAppManager(secret, appManager)); + log.info("intializing app using manager {} in context {}",appManager.getClass().getCanonicalName(),context); futureList.add(new ManagerPair(appManager, appManagerFuture)); if (provider.getAppmanagerMap().containsKey(appManager.getCanonicalName())) @@ -72,21 +82,18 @@ public class OnlineObserver implements AppManagerObserver{ } if (!futureList.isEmpty()) instanciatedManagerPerScope.put(context, futureList); - } catch (ObjectNotFound e1) { - log.error("it should never happen (token has just been created)",e1); - throw new RuntimeException("it should never happen (token has just been created",e1); } catch (Exception e1) { - log.error("something failed getting token",e1); - throw new RuntimeException("something failed getting token",e1); + log.error("something failed getting authorization",e1); + throw new RuntimeException("something failed getting authorization",e1); } } @Observes(value=Constants.token_removed, kind=Kind.critical) - public synchronized void onRemove(final String securityToken){ + public synchronized void onRemove(String context){ try { - final String context = authorizationService().get(securityToken).getContext(); +<<<<<<< HEAD if(instanciatedManagerPerScope.get(context) != null ) { for (ManagerPair manager: instanciatedManagerPerScope.get(context)){ service.execute(new ShutDownAppManager(securityToken, context, manager.getFuture())); @@ -94,11 +101,26 @@ public class OnlineObserver implements AppManagerObserver{ } instanciatedManagerPerScope.remove(context); } +======= + Secret secret = authProvider.getSecretForContext(context); +>>>>>>> refs/remotes/origin/feature/22955 +<<<<<<< HEAD SecurityTokenProvider.instance.reset(); } catch (ObjectNotFound e1) { log.error("it should never happen (token has just been created)",e1); throw new RuntimeException("it should never happen (token has just been created",e1); +======= + if(instanciatedManagerPerScope.get(context) != null ) { + for (ManagerPair manager: instanciatedManagerPerScope.get(context)){ + service.execute(new ShutDownAppManager(secret, manager.getFuture())); + provider.getAppmanagerMap().get(manager.getImplementationClass().getCanonicalName()).remove(context); + } + instanciatedManagerPerScope.remove(context); + } + + instanciatedManagerPerScope.remove(context); +>>>>>>> refs/remotes/origin/feature/22955 } catch (Exception e1) { log.error("something failed getting token",e1); throw new RuntimeException("something failed getting token",e1); @@ -107,6 +129,7 @@ public class OnlineObserver implements AppManagerObserver{ public synchronized void onStop(ApplicationContext appContext){ +<<<<<<< HEAD for (String token :appContext.configuration().startTokens()){ try { String context = authorizationService().get(token).getContext(); @@ -114,7 +137,12 @@ public class OnlineObserver implements AppManagerObserver{ for (ManagerPair manager: instanciatedManagerPerScope.get(context)){ try{ log.info("stoppping {} in context {} ",appContext.name(), context); +======= + for (String context :appContext.authorizationProvider().getContexts()) + this.onRemove(context); +>>>>>>> refs/remotes/origin/feature/22955 +<<<<<<< HEAD SecurityTokenProvider.instance.set(token); ScopeProvider.instance.set(context); try { @@ -138,6 +166,8 @@ public class OnlineObserver implements AppManagerObserver{ log.error("something failed getting token {}",token,e1); } } +======= +>>>>>>> refs/remotes/origin/feature/22955 unregister(); } @@ -148,28 +178,27 @@ public class OnlineObserver implements AppManagerObserver{ public class InitAppManager implements Callable{ private Class managerClass; - private String securityToken; - private String context; + private Secret secret; - public InitAppManager(String securityToken, String context, Class managerClass){ + public InitAppManager(Secret secret, Class managerClass){ this.managerClass = managerClass; - this.securityToken = securityToken; - this.context = context; + this.secret = secret; + } @Override public ApplicationManager call() throws Exception { - SecurityTokenProvider.instance.set(securityToken); - ScopeProvider.instance.set(context); - ApplicationManager manager = managerClass.newInstance(); + log.info("on init called"); + SecretManagerProvider.instance.set(secret); + ApplicationManager manager = null; try { - log.info("calling on onInit of {} on token {}",manager.getClass().getCanonicalName(), securityToken); + manager = managerClass.getDeclaredConstructor().newInstance(); + log.info("calling on onInit on manager {} with secret {}",manager.getClass().getCanonicalName(),secret); manager.onInit(); } catch (Exception e) { - log.warn("error on onInit of {} on token {}",manager.getClass().getCanonicalName(), securityToken, e); + log.warn("error on onInit of {} on context {}",manager.getClass().getCanonicalName(), secret.getContext(), e); } finally{ - ScopeProvider.instance.reset(); - SecurityTokenProvider.instance.reset(); + SecretManagerProvider.instance.reset(); } return manager; } @@ -178,34 +207,35 @@ public class OnlineObserver implements AppManagerObserver{ public class ShutDownAppManager implements Runnable{ private Future appManager; - private String securityToken; - private String context; + private Secret secret; - public ShutDownAppManager(String securityToken, String context, Future appManager){ + public ShutDownAppManager(Secret secret, Future appManager){ this.appManager = appManager; - this.securityToken = securityToken; - this.context = context; + } @Override public void run() { - SecurityTokenProvider.instance.set(securityToken); - ScopeProvider.instance.set(context); + SecretManagerProvider.instance.set(secret); try { - log.info("calling on ShutDown of {} on token {}",appManager.getClass().getCanonicalName(), securityToken); + log.info("calling on ShutDown of {} on context {}",appManager.getClass().getCanonicalName(), secret.getContext()); appManager.get().onShutdown(); } catch (Exception e) { - log.warn("error on onShutdown of {} on token {}",appManager.getClass().getCanonicalName(), securityToken, e); + log.warn("error on onShutdown of {} on context {}",appManager.getClass().getCanonicalName(), secret.getContext(), e); } finally{ - ScopeProvider.instance.reset(); - SecurityTokenProvider.instance.reset(); + SecretManagerProvider.instance.reset(); } } } @Override +<<<<<<< HEAD public void setStartingTokens(Collection startingTokens) { this.startingTokens = startingTokens; +======= + public void setAuthorizationProvider(AuthorizationProvider authProvider) { + this.authProvider = authProvider; +>>>>>>> refs/remotes/origin/feature/22955 } diff --git a/src/main/java/org/gcube/smartgears/application/manager/OnlineProvider.java b/src/main/java/org/gcube/smartgears/application/manager/OnlineProvider.java index 91f034b..6266646 100644 --- a/src/main/java/org/gcube/smartgears/application/manager/OnlineProvider.java +++ b/src/main/java/org/gcube/smartgears/application/manager/OnlineProvider.java @@ -5,7 +5,8 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.Future; -import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.common.security.providers.SecretManagerProvider; +import org.gcube.common.security.secrets.Secret; import org.gcube.smartgears.ApplicationManager; import org.gcube.smartgears.ApplicationManagerProvider; import org.slf4j.Logger; @@ -25,15 +26,18 @@ public class OnlineProvider extends ApplicationManagerProvider { @Override protected Future retrieveFuture(Class applicationManagerClass) { - return appManagerMap.get(applicationManagerClass.getCanonicalName()).get(ScopeProvider.instance.get()); + Secret secret = SecretManagerProvider.instance.get(); + String context = secret.getContext(); + logger.debug("retrieving appManager {} in context {}",applicationManagerClass.getCanonicalName(), context); + return appManagerMap.get(applicationManagerClass.getCanonicalName()).get(context); } @Override - protected MethodHandler getMethdoHandler(Class applicationManagerClass) { + protected MethodHandler getMethodHandler(Class applicationManagerClass) { MethodHandler handler = new MethodHandler() { @Override public Object invoke(Object self, Method thisMethod, Method proceed, Object[] args) throws Throwable { - if (ScopeProvider.instance.get()==null) throw new RuntimeException("error invoking application manager method, scope is not set in this thread"); + if (SecretManagerProvider.instance.get()==null) throw new Exception("error invoking application manager method, secret is not set in this thread"); logger.debug("applicationManagerClass is {}",applicationManagerClass.getCanonicalName()); Future appManagerFuture = retrieveFuture(applicationManagerClass); logger.debug("appmanager future is null? {}", appManagerFuture==null); diff --git a/src/test/java/org/gcube/smartgears/stateful/ResourceBinder.java b/src/test/java/org/gcube/smartgears/stateful/ResourceBinder.java deleted file mode 100644 index aef5694..0000000 --- a/src/test/java/org/gcube/smartgears/stateful/ResourceBinder.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.gcube.smartgears.stateful; - -import org.junit.Test; - -public class ResourceBinder { - - @Test - public void bind() throws Exception{ - - } - -}