diff --git a/pom.xml b/pom.xml
index 230fae0..6b41c16 100644
--- a/pom.xml
+++ b/pom.xml
@@ -206,6 +206,11 @@
4.11
test
+
+ ch.qos.logback
+ logback-classic
+ test
+
diff --git a/src/main/java/org/gcube/gcat/configuration/CatalogueConfigurationFactory.java b/src/main/java/org/gcube/gcat/configuration/CatalogueConfigurationFactory.java
index 280637b..fba4714 100644
--- a/src/main/java/org/gcube/gcat/configuration/CatalogueConfigurationFactory.java
+++ b/src/main/java/org/gcube/gcat/configuration/CatalogueConfigurationFactory.java
@@ -3,7 +3,7 @@ package org.gcube.gcat.configuration;
import java.util.HashMap;
import java.util.Map;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
/**
* @author Luca Frosini (ISTI - CNR)
@@ -22,7 +22,7 @@ public class CatalogueConfigurationFactory {
}
public synchronized static ServiceCatalogueConfiguration getInstance() {
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
ServiceCatalogueConfiguration catalogueConfiguration = catalogueConfigurations.get(context);
if(catalogueConfiguration == null) {
catalogueConfiguration = load(context);
@@ -32,7 +32,7 @@ public class CatalogueConfigurationFactory {
}
public synchronized static void renew() {
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
catalogueConfigurations.remove(context);
ServiceCatalogueConfiguration catalogueConfiguration = load(context);
catalogueConfigurations.put(context, catalogueConfiguration);
@@ -40,14 +40,14 @@ public class CatalogueConfigurationFactory {
public synchronized static void purge() {
// Remove the resource from IS
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
catalogueConfigurations.remove(context);
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
gCoreISConfigurationProxy.delete();
}
public synchronized static ServiceCatalogueConfiguration createOrUpdate(ServiceCatalogueConfiguration catalogueConfiguration) throws Exception {
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
catalogueConfigurations.remove(context);
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context, catalogueConfiguration);
catalogueConfiguration = gCoreISConfigurationProxy.createOrUpdateOnIS();
diff --git a/src/main/java/org/gcube/gcat/configuration/GCoreISConfigurationProxy.java b/src/main/java/org/gcube/gcat/configuration/GCoreISConfigurationProxy.java
index acd9f6a..0c3e8a1 100644
--- a/src/main/java/org/gcube/gcat/configuration/GCoreISConfigurationProxy.java
+++ b/src/main/java/org/gcube/gcat/configuration/GCoreISConfigurationProxy.java
@@ -21,7 +21,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
@@ -158,15 +158,9 @@ public class GCoreISConfigurationProxy {
return mapper.treeToValue(node, ServiceCatalogueConfiguration.class);
}
- /**
- * Retrieve endpoints information from IS for DataCatalogue URL
- *
- * @return list of endpoints for ckan data catalogue
- * @throws Exception
- */
private List getServiceEndpoints(String category, String name) {
SimpleQuery query = queryFor(ServiceEndpoint.class);
- query.addCondition("$resource/Scopes/Scope/text() eq '" + SecretManager.instance.get().getContext() + "'");
+ query.addCondition("$resource/Scopes/Scope/text() eq '" + SecretManagerProvider.instance.get().getContext() + "'");
query.addCondition("$resource/Profile/Category/text() eq '" + category + "'");
query.addCondition("$resource/Profile/Name/text() eq '" + name + "'");
DiscoveryClient client = clientFor(ServiceEndpoint.class);
diff --git a/src/main/java/org/gcube/gcat/moderation/thread/FakeModerationThread.java b/src/main/java/org/gcube/gcat/moderation/thread/FakeModerationThread.java
index f12c59f..7f83175 100644
--- a/src/main/java/org/gcube/gcat/moderation/thread/FakeModerationThread.java
+++ b/src/main/java/org/gcube/gcat/moderation/thread/FakeModerationThread.java
@@ -1,6 +1,6 @@
package org.gcube.gcat.moderation.thread;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.gcat.api.moderation.CMItemStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -21,7 +21,7 @@ public class FakeModerationThread extends ModerationThread {
@Override
public void postUserMessage(CMItemStatus cmItemStatus, String userMessage) throws Exception {
logger.info("{} is sending a message to the {} for item '{}' (id={}). ItemStatus={}, Message=\"{}\"",
- SecretManager.instance.get().getUser().getUsername(),
+ SecretManagerProvider.instance.get().getUser().getUsername(),
ModerationThread.class.getSimpleName(), itemName, itemID, cmItemStatus, userMessage);
}
diff --git a/src/main/java/org/gcube/gcat/moderation/thread/zulip/ZulipStream.java b/src/main/java/org/gcube/gcat/moderation/thread/zulip/ZulipStream.java
index 29a9c8c..e951d02 100644
--- a/src/main/java/org/gcube/gcat/moderation/thread/zulip/ZulipStream.java
+++ b/src/main/java/org/gcube/gcat/moderation/thread/zulip/ZulipStream.java
@@ -8,6 +8,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.authorization.utils.secret.Secret;
import org.gcube.gcat.api.moderation.CMItemStatus;
import org.gcube.gcat.api.moderation.Moderated;
@@ -47,13 +48,13 @@ public class ZulipStream extends ModerationThread {
}
protected ZulipRestExecutor getZulipRestExecutor() {
- ZulipAuth zulipAuth = new ZulipAuth(SecretManager.instance.get().getUser().getUsername());
+ ZulipAuth zulipAuth = new ZulipAuth(SecretManagerProvider.instance.get().getUser().getUsername());
return new ZulipRestExecutor(zulipAuth.getEmail(), zulipAuth.getAPIKey(), zulipAuth.getSite());
}
public ZulipRestExecutor getGCatZulipRestExecutor() throws Exception {
if(gCatZulipRestExecutor==null) {
- SecretManager secretManager = SecretManager.instance.get();
+ SecretManager secretManager = SecretManagerProvider.instance.get();
Secret secret = Constants.getCatalogueSecret();
secretManager.startSession(secret);
gCatZulipRestExecutor = getZulipRestExecutor();
diff --git a/src/main/java/org/gcube/gcat/persistence/ckan/CKANOrganization.java b/src/main/java/org/gcube/gcat/persistence/ckan/CKANOrganization.java
index 30063a6..aa79ee8 100644
--- a/src/main/java/org/gcube/gcat/persistence/ckan/CKANOrganization.java
+++ b/src/main/java/org/gcube/gcat/persistence/ckan/CKANOrganization.java
@@ -2,7 +2,7 @@ package org.gcube.gcat.persistence.ckan;
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,7 +68,7 @@ public class CKANOrganization extends CKAN {
}
public static String getCKANOrganizationName() {
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
return getCKANOrganizationName(context);
}
diff --git a/src/main/java/org/gcube/gcat/persistence/ckan/CKANResource.java b/src/main/java/org/gcube/gcat/persistence/ckan/CKANResource.java
index 380b254..64903db 100644
--- a/src/main/java/org/gcube/gcat/persistence/ckan/CKANResource.java
+++ b/src/main/java/org/gcube/gcat/persistence/ckan/CKANResource.java
@@ -20,7 +20,7 @@ import org.apache.tika.mime.MimeType;
import org.apache.tika.mime.MimeTypes;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
import org.gcube.gcat.utils.Constants;
import org.gcube.gcat.utils.HTTPCall;
@@ -69,7 +69,7 @@ public class CKANResource extends CKAN {
public static final String URI_RESOLVER_STORAGE_HUB_PATH = "/shub/";
static {
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
if(context.startsWith("/gcube")) {
URI_RESOLVER_STORAGE_HUB_HOST = URI_RESOLVER_STORAGE_HUB_HOST_DEV;
} else if(context.startsWith("/pred4s")){
diff --git a/src/main/java/org/gcube/gcat/persistence/ckan/CKANUser.java b/src/main/java/org/gcube/gcat/persistence/ckan/CKANUser.java
index 30f647a..0254509 100644
--- a/src/main/java/org/gcube/gcat/persistence/ckan/CKANUser.java
+++ b/src/main/java/org/gcube/gcat/persistence/ckan/CKANUser.java
@@ -7,7 +7,7 @@ import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response.Status;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.authorization.utils.user.User;
import org.gcube.gcat.api.moderation.Moderated;
import org.gcube.gcat.api.roles.Role;
@@ -82,7 +82,7 @@ public class CKANUser extends CKAN {
* @return true if the display name and the full name has been updated in objectNode
*/
private boolean checkAndSetJobTitle(ObjectNode objectNode) {
- String jobTitle = SecretManager.instance.get().getUser().getAbout();
+ String jobTitle = SecretManagerProvider.instance.get().getUser().getAbout();
String ckanJobTitle = "";
if(objectNode.has(ABOUT)) {
@@ -121,7 +121,7 @@ public class CKANUser extends CKAN {
* @return true if the display name and the full name has been updated
*/
private boolean checkAndSetEmail(ObjectNode objectNode) {
- String portalEmail = SecretManager.instance.get().getUser().getEmail();
+ String portalEmail = SecretManagerProvider.instance.get().getUser().getEmail();
String ckanEmail = "";
if(objectNode.has(EMAIL)) {
@@ -194,7 +194,7 @@ public class CKANUser extends CKAN {
}
public static String getCKANUsername() {
- String username = SecretManager.instance.get().getUser().getUsername();
+ String username = SecretManagerProvider.instance.get().getUser().getUsername();
return getCKANUsername(username);
}
@@ -215,7 +215,7 @@ public class CKANUser extends CKAN {
public Role getRole() {
if(role == null) {
role = Role.MEMBER;
- Collection roles = SecretManager.instance.get().getUser().getRoles();
+ Collection roles = SecretManagerProvider.instance.get().getUser().getRoles();
for(String portalRole : roles) {
Role gotRole = Role.getRoleFromPortalRole(portalRole);
if(gotRole != null && gotRole.ordinal() > role.ordinal()) {
@@ -252,23 +252,23 @@ public class CKANUser extends CKAN {
public boolean isCatalogueModerator() {
if(catalogueModerator == null) {
- catalogueModerator = SecretManager.instance.get().getUser().getRoles().contains(Moderated.CATALOGUE_MODERATOR);
+ catalogueModerator = SecretManagerProvider.instance.get().getUser().getRoles().contains(Moderated.CATALOGUE_MODERATOR);
}
return catalogueModerator;
}
public String getSurnameName(){
- User user = SecretManager.instance.get().getUser();
+ User user = SecretManagerProvider.instance.get().getUser();
return String.format("%s %s", user.getFamilyName(), user.getGivenName()).trim();
}
public String getNameSurname() {
- User user = SecretManager.instance.get().getUser();
+ User user = SecretManagerProvider.instance.get().getUser();
return String.format("%s %s", user.getGivenName(), user.getFamilyName()).trim();
}
public String getEMail() {
- return SecretManager.instance.get().getUser().getEmail();
+ return SecretManagerProvider.instance.get().getUser().getEmail();
}
}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/gcat/persistence/ckan/CKANUserCache.java b/src/main/java/org/gcube/gcat/persistence/ckan/CKANUserCache.java
index 34e610d..264e519 100644
--- a/src/main/java/org/gcube/gcat/persistence/ckan/CKANUserCache.java
+++ b/src/main/java/org/gcube/gcat/persistence/ckan/CKANUserCache.java
@@ -13,6 +13,7 @@ import javax.cache.expiry.Duration;
import javax.cache.spi.CachingProvider;
import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
public abstract class CKANUserCache {
@@ -37,7 +38,7 @@ public abstract class CKANUserCache {
}
public static CKANUser getCurrrentCKANUser() {
- SecretManager secretManager = SecretManager.instance.get();
+ SecretManager secretManager = SecretManagerProvider.instance.get();
String context = secretManager.getContext();
Cache userCache = userCachePerContext.get(context);
if(userCache == null) {
diff --git a/src/main/java/org/gcube/gcat/rest/Configuration.java b/src/main/java/org/gcube/gcat/rest/Configuration.java
index 6fad6d4..83a31b1 100644
--- a/src/main/java/org/gcube/gcat/rest/Configuration.java
+++ b/src/main/java/org/gcube/gcat/rest/Configuration.java
@@ -23,7 +23,7 @@ import javax.xml.ws.WebServiceException;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.gcat.annotation.PATCH;
import org.gcube.gcat.annotation.PURGE;
import org.gcube.gcat.api.GCatConstants;
@@ -50,7 +50,7 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf
throw new BadRequestException("Please provide a valid context as path parameter");
}
- String c = SecretManager.instance.get().getContext();
+ String c = SecretManagerProvider.instance.get().getContext();
if(context.compareTo(Configuration.CURRENT_CONTEXT_PATH_PARAMETER)==0) {
return c;
}
@@ -203,7 +203,7 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf
if(node.has(ServiceCatalogueConfiguration.CONTEXT_KEY)) {
String context = node.get(ServiceCatalogueConfiguration.CONTEXT_KEY).asText();
- String c = SecretManager.instance.get().getContext();
+ String c = SecretManagerProvider.instance.get().getContext();
if(c.compareTo(context)!=0) {
throw new BadRequestException("Context provided in the configuration (i.e. " + catalogueConfiguration.getContext() + ") does not match with token request context (i.e. " + c + ")");
}
diff --git a/src/main/java/org/gcube/gcat/social/SocialPost.java b/src/main/java/org/gcube/gcat/social/SocialPost.java
index d94fef0..2caadaf 100644
--- a/src/main/java/org/gcube/gcat/social/SocialPost.java
+++ b/src/main/java/org/gcube/gcat/social/SocialPost.java
@@ -12,7 +12,7 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.authorization.utils.socialservice.SocialService;
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
@@ -121,7 +121,7 @@ public class SocialPost extends Thread {
CatalogueConfiguration instance = CatalogueConfigurationFactory.getInstance();
if(!instance.isSocialPostEnabled()) {
- logger.info("Social Post are disabled in the context {}", SecretManager.instance.get().getContext());
+ logger.info("Social Post are disabled in the context {}", SecretManagerProvider.instance.get().getContext());
return;
}
logger.info("Going to send Social Post about the Item {} available at {}", itemID, itemURL);
diff --git a/src/main/java/org/gcube/gcat/utils/Constants.java b/src/main/java/org/gcube/gcat/utils/Constants.java
index 33cc950..ea05ef1 100644
--- a/src/main/java/org/gcube/gcat/utils/Constants.java
+++ b/src/main/java/org/gcube/gcat/utils/Constants.java
@@ -5,7 +5,7 @@ import java.util.Properties;
import javax.ws.rs.InternalServerErrorException;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.authorization.utils.secret.JWTSecret;
import org.gcube.common.authorization.utils.secret.Secret;
import org.gcube.common.keycloak.KeycloakClientFactory;
@@ -34,12 +34,12 @@ public class Constants {
return clientSecret;
} catch(Exception e) {
throw new InternalServerErrorException(
- "Unable to retrieve Application Token for context " + SecretManager.instance.get().getContext(), e);
+ "Unable to retrieve Application Token for context " + SecretManagerProvider.instance.get().getContext(), e);
}
}
private static TokenResponse getJWTAccessToken() throws Exception {
- String contextToAuthorise = SecretManager.instance.get().getContext();
+ String contextToAuthorise = SecretManagerProvider.instance.get().getContext();
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(CLIENT_ID, getClientSecret(contextToAuthorise), contextToAuthorise, null);
return tr;
}
diff --git a/src/main/java/org/gcube/gcat/utils/URIResolver.java b/src/main/java/org/gcube/gcat/utils/URIResolver.java
index 2b8cf2f..cb5861b 100644
--- a/src/main/java/org/gcube/gcat/utils/URIResolver.java
+++ b/src/main/java/org/gcube/gcat/utils/URIResolver.java
@@ -5,7 +5,7 @@ import java.util.Map;
import javax.ws.rs.WebApplicationException;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
public abstract class URIResolver {
@@ -19,7 +19,7 @@ public abstract class URIResolver {
public static String getCatalogueItemURL(String name) {
try {
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
UriResolverManager uriResolverManager = new UriResolverManager("CTLG");
Map params = new HashMap<>();
params.put(CATALOGUE_CONTEXT, context);
diff --git a/src/main/java/org/gcube/gcat/workspace/CatalogueStorageHubManagement.java b/src/main/java/org/gcube/gcat/workspace/CatalogueStorageHubManagement.java
index f5fe5cd..8d7afe4 100644
--- a/src/main/java/org/gcube/gcat/workspace/CatalogueStorageHubManagement.java
+++ b/src/main/java/org/gcube/gcat/workspace/CatalogueStorageHubManagement.java
@@ -5,6 +5,7 @@ import java.net.URL;
import java.util.Map;
import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.authorization.utils.secret.Secret;
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
import org.gcube.common.storagehub.client.dsl.FileContainer;
@@ -44,7 +45,7 @@ public class CatalogueStorageHubManagement {
}
public URL ensureResourcePersistence(URL persistedURL, String itemID, String resourceID) throws Exception {
- SecretManager secretManager = SecretManager.instance.get();
+ SecretManager secretManager = SecretManagerProvider.instance.get();
Secret secret = Constants.getCatalogueSecret();
try {
secretManager.startSession(secret);
@@ -70,7 +71,7 @@ public class CatalogueStorageHubManagement {
}
public void deleteResourcePersistence(String itemID, String resourceID, String mimeType) throws Exception {
- SecretManager secretManager = SecretManager.instance.get();
+ SecretManager secretManager = SecretManagerProvider.instance.get();
Secret secret = Constants.getCatalogueSecret();
try {
secretManager.startSession(secret);
@@ -100,7 +101,7 @@ public class CatalogueStorageHubManagement {
}
public void renameFile(String resourceID, String revisionID) throws Exception {
- SecretManager secretManager = SecretManager.instance.get();
+ SecretManager secretManager = SecretManagerProvider.instance.get();
Secret secret = Constants.getCatalogueSecret();
try {
secretManager.startSession(secret);
@@ -114,7 +115,7 @@ public class CatalogueStorageHubManagement {
}
public void addRevisionID(String resourceID, String revisionID) throws Exception {
- SecretManager secretManager = SecretManager.instance.get();
+ SecretManager secretManager = SecretManagerProvider.instance.get();
Secret secret = Constants.getCatalogueSecret();
try {
secretManager.startSession(secret);
@@ -125,7 +126,7 @@ public class CatalogueStorageHubManagement {
}
public FileContainer retrievePersistedFile(String id, String mimeType) throws Exception {
- SecretManager secretManager = SecretManager.instance.get();
+ SecretManager secretManager = SecretManagerProvider.instance.get();
Secret secret = Constants.getCatalogueSecret();
try {
secretManager.startSession(secret);
diff --git a/src/test/java/org/gcube/gcat/ContextTest.java b/src/test/java/org/gcube/gcat/ContextTest.java
index 6c3e89f..0a6b2f9 100644
--- a/src/test/java/org/gcube/gcat/ContextTest.java
+++ b/src/test/java/org/gcube/gcat/ContextTest.java
@@ -8,6 +8,7 @@ import java.io.InputStream;
import java.util.Properties;
import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.authorization.utils.secret.Secret;
import org.gcube.common.authorization.utils.secret.SecretUtility;
import org.junit.AfterClass;
@@ -48,8 +49,11 @@ public class ContextTest {
}
public static void set(Secret secret) throws Exception {
- SecretManager.instance.get().reset();
- secret.set();
+ SecretManagerProvider.instance.reset();
+ SecretManager secretManager = new SecretManager();
+ SecretManagerProvider.instance.set(secretManager);
+ secretManager.addSecret(secret);
+ secretManager.set();
}
public static void setContext(String token) throws Exception {
@@ -79,7 +83,7 @@ public class ContextTest {
@AfterClass
public static void afterClass() throws Exception {
- SecretManager.instance.get().reset();
+ SecretManagerProvider.instance.reset();
}
}
diff --git a/src/test/java/org/gcube/gcat/configuration/GCoreISConfigurationProxyTest.java b/src/test/java/org/gcube/gcat/configuration/GCoreISConfigurationProxyTest.java
index f5d82b3..fd6455d 100644
--- a/src/test/java/org/gcube/gcat/configuration/GCoreISConfigurationProxyTest.java
+++ b/src/test/java/org/gcube/gcat/configuration/GCoreISConfigurationProxyTest.java
@@ -6,7 +6,7 @@ import java.io.InputStreamReader;
import java.util.Set;
import java.util.stream.Collectors;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.gcat.ContextTest;
import org.junit.Assert;
import org.junit.Test;
@@ -23,7 +23,7 @@ public class GCoreISConfigurationProxyTest extends ContextTest {
// @Test
public void testGetSupportedOrganizationsFromIS() throws Exception {
ContextTest.setContextByName("/gcube/devNext/NextNext");
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
@SuppressWarnings("deprecation")
Set organizations = gCoreISConfigurationProxy.getSupportedOrganizationsFromGenericResource();
@@ -33,7 +33,7 @@ public class GCoreISConfigurationProxyTest extends ContextTest {
@Test
public void testCatalogueConfiguration() throws Exception {
ContextTest.setContextByName("/gcube/devsec/devVRE");
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
ServiceCatalogueConfiguration catalogueConfiguration = gCoreISConfigurationProxy.getCatalogueConfigurationFromIS();
String json = catalogueConfiguration.toJsonString();
@@ -54,7 +54,7 @@ public class GCoreISConfigurationProxyTest extends ContextTest {
// @Test
public void updateConfigurationToNewVersion() throws Exception {
ContextTest.setContextByName("/gcube/devsec/devVRE");
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
GCoreISConfigurationProxy gCoreISConfigurationProxy = new GCoreISConfigurationProxy(context);
@SuppressWarnings("deprecation")
ServiceCatalogueConfiguration catalogueConfiguration = gCoreISConfigurationProxy.getOLDCatalogueConfigurationFromIS();
@@ -70,7 +70,7 @@ public class GCoreISConfigurationProxyTest extends ContextTest {
//@Test
public void createConfiguration() throws Exception {
ContextTest.setContextByName("/gcube/devsec/devVRE");
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(DEVVRE_CONFIG_JSON);
String json = new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining("\n"));
ServiceCatalogueConfiguration catalogueConfiguration = ServiceCatalogueConfiguration.getServiceCatalogueConfiguration(json);
diff --git a/src/test/java/org/gcube/gcat/persistence/ckan/CKANOrganizationTest.java b/src/test/java/org/gcube/gcat/persistence/ckan/CKANOrganizationTest.java
index f456237..31e9989 100644
--- a/src/test/java/org/gcube/gcat/persistence/ckan/CKANOrganizationTest.java
+++ b/src/test/java/org/gcube/gcat/persistence/ckan/CKANOrganizationTest.java
@@ -3,7 +3,7 @@ package org.gcube.gcat.persistence.ckan;
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.gcat.ContextTest;
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
@@ -60,7 +60,7 @@ public class CKANOrganizationTest extends ContextTest {
@Test
public void createOrganization() throws Exception {
ContextTest.setContextByName("/gcube/devNext/NextNext");
- String context = SecretManager.instance.get().getContext();
+ String context = SecretManagerProvider.instance.get().getContext();
ScopeBean scopeBean = new ScopeBean(context);
CKANOrganization ckanOrganization = new CKANOrganization();
ckanOrganization.setApiKey(CKANUtility.getSysAdminAPI());
diff --git a/src/test/java/org/gcube/gcat/persistence/ckan/CKANPackageTest.java b/src/test/java/org/gcube/gcat/persistence/ckan/CKANPackageTest.java
index 0a11fd9..de150ff 100644
--- a/src/test/java/org/gcube/gcat/persistence/ckan/CKANPackageTest.java
+++ b/src/test/java/org/gcube/gcat/persistence/ckan/CKANPackageTest.java
@@ -22,7 +22,7 @@ import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
import org.gcube.common.authorization.library.provider.UserInfo;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.gcat.ContextTest;
import org.gcube.gcat.api.GCatConstants;
@@ -54,7 +54,7 @@ public class CKANPackageTest extends ContextTest {
public void count() throws Exception {
CKANPackage ckanPackage = new CKANPackage();
int count = ckanPackage.count();
- logger.debug("Number of items in {} is {}", SecretManager.instance.get().getContext(), count);
+ logger.debug("Number of items in {} is {}", SecretManagerProvider.instance.get().getContext(), count);
}
@Test
@@ -311,7 +311,7 @@ public class CKANPackageTest extends ContextTest {
}
protected CKANPackage createPackage(ObjectMapper mapper, Boolean socialPost) throws Exception {
- String currentContext = SecretManager.instance.get().getContext();
+ String currentContext = SecretManagerProvider.instance.get().getContext();
ScopeBean scopeBean = new ScopeBean(currentContext);
String organization = CatalogueConfiguration.getOrganizationName(scopeBean);
diff --git a/src/test/java/org/gcube/gcat/utils/ConstantsTest.java b/src/test/java/org/gcube/gcat/utils/ConstantsTest.java
index defcc45..9ede444 100644
--- a/src/test/java/org/gcube/gcat/utils/ConstantsTest.java
+++ b/src/test/java/org/gcube/gcat/utils/ConstantsTest.java
@@ -1,6 +1,6 @@
package org.gcube.gcat.utils;
-import org.gcube.common.authorization.utils.manager.SecretManager;
+import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
import org.gcube.common.encryption.encrypter.StringEncrypter;
import org.gcube.gcat.ContextTest;
import org.junit.Test;
@@ -13,7 +13,7 @@ public class ConstantsTest extends ContextTest {
@Test
public void testGetApplicationToken() throws Exception {
- logger.debug("Application token for Context {} is {}", SecretManager.instance.get().getContext(),
+ logger.debug("Application token for Context {} is {}", SecretManagerProvider.instance.get().getContext(),
Constants.getCatalogueSecret().getToken());
}