Compare commits
19 Commits
master
...
migrating_
Author | SHA1 | Date |
---|---|---|
Luca Frosini | f5f04417af | |
Luca Frosini | bd554272bd | |
Luca Frosini | aa70d0ecc6 | |
Luca Frosini | 95958df113 | |
Luca Frosini | 90dc8e33a5 | |
Luca Frosini | 362eabd7aa | |
Luca Frosini | 46bfddf27c | |
Luca Frosini | 31984858ec | |
Luca Frosini | 17194547bf | |
Luca Frosini | e5e21457f3 | |
Luca Frosini | e85ef616b5 | |
Luca Frosini | 5e7d614efd | |
Luca Frosini | fc1ba8545a | |
Luca Frosini | 1e0af604e1 | |
Luca Frosini | 5dae7d5cc3 | |
Luca Frosini | 0650b4d652 | |
Luca Frosini | 3bf837d8d4 | |
Luca Frosini | ba1bc7bd0c | |
Luca Frosini | dd0bc39628 |
|
@ -3,6 +3,13 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
# Changelog for gCube Catalogue (gCat) Service
|
||||
|
||||
|
||||
## [v3.0.0-SNAPSHOT]
|
||||
|
||||
- Service migrated to Smartgears 4
|
||||
- Switched form commons-lang3 to commons-lang to avoid duplicates
|
||||
- Set resource-registry-publisher dependency scope to provided
|
||||
|
||||
|
||||
## [v2.4.1]
|
||||
|
||||
- Integrating Sphinx for documentation [#23833]
|
||||
|
|
33
pom.xml
33
pom.xml
|
@ -12,7 +12,7 @@
|
|||
<groupId>org.gcube.data-catalogue</groupId>
|
||||
<artifactId>gcat</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.4.1</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<name>gCube Catalogue (gCat) Service</name>
|
||||
<description>
|
||||
This service allows any client to publish on the gCube Catalogue.
|
||||
|
@ -35,7 +35,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-smartgears-bom</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -52,8 +52,16 @@
|
|||
<artifactId>common-encryption</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope</artifactId>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.security</groupId>
|
||||
<artifactId>gcube-secrets</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>keycloak-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
|
@ -62,18 +70,13 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.data-catalogue</groupId>
|
||||
<artifactId>gcat-api</artifactId>
|
||||
<version>[2.3.1,3.0.0-SNAPSHOT)</version>
|
||||
<version>[2.0.0,3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.social-networking</groupId>
|
||||
<artifactId>social-service-client</artifactId>
|
||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-utils</artifactId>
|
||||
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-model</artifactId>
|
||||
|
@ -189,7 +192,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.data-publishing</groupId>
|
||||
<artifactId>storagehub-application-persistence</artifactId>
|
||||
<version>[3.0.0,4.0.0-SNAPSHOT)</version>
|
||||
<version>[4.0.0-SNAPSHOT,5.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Used to automatically convert XML to JSON -->
|
||||
|
@ -208,9 +211,9 @@
|
|||
|
||||
<!-- Used by Validator -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
|
@ -308,7 +311,7 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- Copy Enunciate Documentation from your-application/api-docs into your war -->
|
||||
<!-- Copy Enunciate Documentation from your-application/api-docs into your war -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.gcat.configuration;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.gcat.persistence.ckan.CKANUserCache;
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,7 +21,6 @@ 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.SecretManagerProvider;
|
||||
import org.gcube.common.resources.gcore.GenericResource;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
|
@ -30,6 +29,7 @@ import org.gcube.common.resources.gcore.ServiceEndpoint.Property;
|
|||
import org.gcube.common.resources.gcore.ServiceEndpoint.Runtime;
|
||||
import org.gcube.common.resources.gcore.common.Platform;
|
||||
import org.gcube.common.resources.gcore.utils.Group;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.gcat.api.GCatConstants;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||
|
@ -609,7 +609,7 @@ public class GCoreISConfigurationProxy {
|
|||
String runningOn = getRunningOn(containerConfiguration);
|
||||
runtime.hostedOn(runningOn);
|
||||
runtime.ghnId(containerContext.id());
|
||||
runtime.status(applicationContext.configuration().mode().toString());
|
||||
runtime.status(applicationContext.lifecycle().state().remoteForm().toLowerCase());
|
||||
}catch (Exception e) {
|
||||
runtime.hostedOn("localhost");
|
||||
runtime.ghnId("");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.gcat.moderation.thread;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.security.providers.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=\"{}\"",
|
||||
SecretManagerProvider.instance.get().getUser().getUsername(),
|
||||
SecretManagerProvider.instance.get().getOwner().getId(),
|
||||
ModerationThread.class.getSimpleName(), itemName, itemID, cmItemStatus, userMessage);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ import java.util.Map;
|
|||
//import java.util.Map;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
//import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
//import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
|
@ -82,8 +82,8 @@ public abstract class ModerationThread {
|
|||
public String getModerationURL() {
|
||||
if(moderationURL==null) {
|
||||
try {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
String context = secretManager.getContext();
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
String context = secret.getContext();
|
||||
UriResolverManager resolver = new UriResolverManager("CTLG");
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
params.put("gcube_scope", context); //e.g. /gcube/devsec/devVRE
|
||||
|
|
|
@ -3,9 +3,9 @@ package org.gcube.gcat.moderation.thread.social.notifications;
|
|||
import java.net.URL;
|
||||
import java.util.Set;
|
||||
|
||||
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.security.AuthorizedTasks;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.gcat.api.moderation.CMItemStatus;
|
||||
import org.gcube.gcat.api.moderation.Moderated;
|
||||
import org.gcube.gcat.moderation.thread.ModerationThread;
|
||||
|
@ -210,17 +210,12 @@ public class SocialNotificationModerationThread extends ModerationThread {
|
|||
@Override
|
||||
protected void postMessage(String messageString) throws Exception {
|
||||
CatalogueEvent catalogueEvent = getCatalogueEvent(messageString);
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
Runnable runnable = getNotificationRunnable(catalogueEvent);
|
||||
if(notificationSentByGCat) {
|
||||
secretManager.startSession(secret);
|
||||
}
|
||||
try {
|
||||
sendNotification(catalogueEvent);
|
||||
}finally {
|
||||
if(notificationSentByGCat) {
|
||||
secretManager.endSession();
|
||||
}
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
AuthorizedTasks.executeSafely(runnable, secret);
|
||||
}else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,25 +254,20 @@ public class SocialNotificationModerationThread extends ModerationThread {
|
|||
stringBuffer.append(userMessage);
|
||||
stringBuffer.append("\".");
|
||||
CatalogueEvent catalogueEvent = getCatalogueEvent(stringBuffer.toString());
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
Runnable runnable = getNotificationRunnable(catalogueEvent);
|
||||
if(notificationSentByGCat) {
|
||||
secretManager.startSession(secret);
|
||||
}
|
||||
try {
|
||||
sendNotification(catalogueEvent);
|
||||
}finally {
|
||||
if(notificationSentByGCat) {
|
||||
secretManager.endSession();
|
||||
}
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
AuthorizedTasks.executeSafely(runnable, secret);
|
||||
}else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendNotification(CatalogueEvent catalogueEvent) throws Exception {
|
||||
Thread thread = new Thread() {
|
||||
protected Runnable getNotificationRunnable(CatalogueEvent catalogueEvent) throws Exception {
|
||||
Runnable runnable = new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
logger.trace("{} is going to send the following notification {}", SecretManagerProvider.instance.get().getUser().getUsername(), catalogueEvent);
|
||||
logger.trace("{} is going to send the following notification {}", SecretManagerProvider.instance.get().getOwner().getId(), catalogueEvent);
|
||||
NotificationClient nc = new NotificationClient();
|
||||
nc.sendCatalogueEvent(catalogueEvent);
|
||||
} catch(Exception e) {
|
||||
|
@ -285,8 +275,7 @@ public class SocialNotificationModerationThread extends ModerationThread {
|
|||
}
|
||||
}
|
||||
};
|
||||
thread.run();
|
||||
// thread.start();
|
||||
return runnable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.gcat.moderation.thread.zulip;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
//import java.util.Set;
|
||||
//
|
||||
//import javax.ws.rs.InternalServerErrorException;
|
||||
|
@ -8,7 +9,6 @@ package org.gcube.gcat.moderation.thread.zulip;
|
|||
//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;
|
||||
|
@ -41,7 +41,7 @@ public class ZulipStream 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=\"{}\"",
|
||||
SecretManagerProvider.instance.get().getUser().getUsername(),
|
||||
SecretManagerProvider.instance.get().getOwner().getId(),
|
||||
ZulipStream.class.getSimpleName(), itemName, itemID, cmItemStatus, userMessage);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,12 +16,12 @@ import javax.ws.rs.InternalServerErrorException;
|
|||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
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.scope.api.ScopeProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.DataType;
|
||||
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataField;
|
||||
import org.gcube.datacatalogue.metadatadiscovery.bean.jaxb.MetadataFormat;
|
||||
|
@ -127,7 +127,7 @@ public class Validator {
|
|||
logger.debug("Retrieved namespaces are {}", categories);
|
||||
List<String> categoriesIds = new ArrayList<String>(categories == null ? 0 : categories.size());
|
||||
if(categories == null || categories.isEmpty()) {
|
||||
logger.warn("No category defined in context {}", ScopeProvider.instance.get());
|
||||
logger.warn("No category defined in context {}", SecretManagerProvider.instance.get().getContext());
|
||||
} else {
|
||||
for(NamespaceCategory metadataCategory : categories) {
|
||||
categoriesIds.add(metadataCategory.getId()); // save them later for matching with custom fields
|
||||
|
@ -588,7 +588,7 @@ public class Validator {
|
|||
break;
|
||||
case Number:
|
||||
|
||||
if(!NumberUtils.isCreatable(value))
|
||||
if(!NumberUtils.isNumber(value))
|
||||
throw new BadRequestException("Field's value with key '" + key + "' is not a valid number!");
|
||||
|
||||
break;
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import org.gcube.com.fasterxml.jackson.databind.node.NullNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||
import org.gcube.gcat.configuration.CatalogueConfigurationFactory;
|
||||
import org.gcube.gcat.utils.HTTPUtility;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -239,7 +238,6 @@ public abstract class CKAN {
|
|||
String catalogueURL = CKANUtility.getCkanURL();
|
||||
|
||||
GXHTTPStringRequest gxhttpStringRequest = HTTPUtility.createGXHTTPStringRequest(catalogueURL, path, post);
|
||||
gxhttpStringRequest.isExternalCall(true);
|
||||
gxhttpStringRequest.header(AUTH_CKAN_HEADER, getApiKey());
|
||||
|
||||
return gxhttpStringRequest;
|
||||
|
|
|
@ -2,8 +2,8 @@ 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.SecretManagerProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.security.ContextBean;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -73,8 +73,8 @@ public class CKANOrganization extends CKAN {
|
|||
}
|
||||
|
||||
public static String getCKANOrganizationName(String context) {
|
||||
ScopeBean scopeBean = new ScopeBean(context);
|
||||
return scopeBean.name().toLowerCase();
|
||||
ContextBean contextBean = new ContextBean(context);
|
||||
return contextBean.name().toLowerCase();
|
||||
}
|
||||
|
||||
public int count() {
|
||||
|
|
|
@ -21,7 +21,8 @@ import javax.ws.rs.core.MultivaluedMap;
|
|||
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.scope.impl.ScopeBean.Type;
|
||||
import org.gcube.common.security.ContextBean;
|
||||
import org.gcube.common.security.ContextBean.Type;
|
||||
import org.gcube.gcat.api.GCatConstants;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
import org.gcube.gcat.api.moderation.CMItemStatus;
|
||||
|
@ -891,7 +892,10 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
((ObjectNode) jsonNode).remove(RESOURCES_KEY);
|
||||
}
|
||||
|
||||
if(configuration.getScopeBean().is(Type.VRE)) {
|
||||
String context = configuration.getContext();
|
||||
ContextBean contextBean = new ContextBean(context);
|
||||
|
||||
if(contextBean.is(Type.VRE)) {
|
||||
addItemURLViaResolver(jsonNode);
|
||||
}
|
||||
|
||||
|
@ -904,7 +908,7 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
postItemCreated();
|
||||
|
||||
if(!isModerationEnabled()) {
|
||||
if(configuration.getScopeBean().is(Type.VRE)) {
|
||||
if(contextBean.is(Type.VRE)) {
|
||||
// Actions performed after a package has been correctly created on ckan.
|
||||
sendSocialPost();
|
||||
}
|
||||
|
@ -1489,7 +1493,9 @@ public class CKANPackage extends CKAN implements Moderated {
|
|||
moderationThread.setItemCoordinates(itemID, name, itemTitle, itemURL);
|
||||
moderationThread.postItemApproved(moderatorMessage);
|
||||
|
||||
if(configuration.getScopeBean().is(Type.VRE)) {
|
||||
String context = configuration.getContext();
|
||||
ContextBean contextBean = new ContextBean(context);
|
||||
if(contextBean.is(Type.VRE)) {
|
||||
// Actions performed after a package has been correctly created on ckan.
|
||||
sendSocialPost();
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ 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.SecretManagerProvider;
|
||||
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.gcat.utils.Constants;
|
||||
import org.gcube.gcat.utils.HTTPCall;
|
||||
import org.gcube.gcat.workspace.CatalogueStorageHubManagement;
|
||||
|
|
|
@ -8,8 +8,9 @@ import javax.ws.rs.core.Response.Status;
|
|||
|
||||
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.SecretManagerProvider;
|
||||
import org.gcube.common.authorization.utils.user.User;
|
||||
import org.gcube.common.security.Owner;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
import org.gcube.gcat.api.moderation.Moderated;
|
||||
import org.gcube.gcat.api.roles.Role;
|
||||
|
@ -77,7 +78,7 @@ public class CKANUser extends CKAN {
|
|||
objectNode.put(PASSWORD, randomString.nextString());
|
||||
checkAndSetEmail(objectNode);
|
||||
checkAndSetFullName(objectNode);
|
||||
checkAndSetJobTitle(objectNode);
|
||||
// checkAndSetJobTitle(objectNode);
|
||||
return create(getAsString(objectNode));
|
||||
}
|
||||
|
||||
|
@ -86,24 +87,26 @@ public class CKANUser extends CKAN {
|
|||
this.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param objectNode
|
||||
* @return true if the display name and the full name has been updated in objectNode
|
||||
*/
|
||||
private boolean checkAndSetJobTitle(ObjectNode objectNode) {
|
||||
String jobTitle = SecretManagerProvider.instance.get().getUser().getAbout();
|
||||
|
||||
String ckanJobTitle = "";
|
||||
if(objectNode.has(ABOUT)) {
|
||||
ckanJobTitle = objectNode.get(ABOUT).asText();
|
||||
}
|
||||
if(jobTitle!=null && jobTitle.compareTo(ckanJobTitle) != 0) {
|
||||
objectNode.put(ABOUT, jobTitle);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// /**
|
||||
// *
|
||||
// * @param objectNode
|
||||
// * @return true if the display name and the full name has been updated in objectNode
|
||||
// */
|
||||
// private boolean checkAndSetJobTitle(ObjectNode objectNode) {
|
||||
// Secret secret = SecretManagerProvider.instance.get();
|
||||
// Owner owner = secret.getOwner();
|
||||
// String jobTitle = owner.getAbout();
|
||||
//
|
||||
// String ckanJobTitle = "";
|
||||
// if(objectNode.has(ABOUT)) {
|
||||
// ckanJobTitle = objectNode.get(ABOUT).asText();
|
||||
// }
|
||||
// if(jobTitle!=null && jobTitle.compareTo(ckanJobTitle) != 0) {
|
||||
// objectNode.put(ABOUT, jobTitle);
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -131,15 +134,15 @@ public class CKANUser extends CKAN {
|
|||
* @return true if the display name and the full name has been updated
|
||||
*/
|
||||
private boolean checkAndSetEmail(ObjectNode objectNode) {
|
||||
User user = SecretManagerProvider.instance.get().getUser();
|
||||
String portalEmail = user.getEmail();
|
||||
Owner owner = SecretManagerProvider.instance.get().getOwner();
|
||||
String portalEmail = owner.getEmail();
|
||||
|
||||
String ckanEmail = "";
|
||||
if(objectNode.has(EMAIL)) {
|
||||
ckanEmail = objectNode.get(EMAIL).asText();
|
||||
}
|
||||
if(portalEmail==null) {
|
||||
String username = user.getUsername();
|
||||
String username = owner.getId();
|
||||
String eMail = username + "@d4science.org";
|
||||
objectNode.put(EMAIL, eMail);
|
||||
return true;
|
||||
|
@ -160,7 +163,7 @@ public class CKANUser extends CKAN {
|
|||
|
||||
toBeUpdated = checkAndSetEmail(objectNode) || toBeUpdated;
|
||||
toBeUpdated = checkAndSetFullName(objectNode) || toBeUpdated;
|
||||
toBeUpdated = checkAndSetJobTitle(objectNode) || toBeUpdated;
|
||||
// toBeUpdated = checkAndSetJobTitle(objectNode) || toBeUpdated;
|
||||
|
||||
if(toBeUpdated) {
|
||||
update(getAsString(objectNode));
|
||||
|
@ -239,7 +242,9 @@ public class CKANUser extends CKAN {
|
|||
|
||||
|
||||
public static String getCKANUsername() {
|
||||
String username = SecretManagerProvider.instance.get().getUser().getUsername();
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
Owner owner = secret.getOwner();
|
||||
String username = owner.getId();
|
||||
return getCKANUsername(username);
|
||||
}
|
||||
|
||||
|
@ -272,7 +277,9 @@ public class CKANUser extends CKAN {
|
|||
public Role getRole() {
|
||||
if(role == null) {
|
||||
role = Role.MEMBER;
|
||||
Collection<String> roles = SecretManagerProvider.instance.get().getUser().getRoles();
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
Owner owner = secret.getOwner();
|
||||
Collection<String> roles = owner.getRoles();
|
||||
for(String portalRole : roles) {
|
||||
Role gotRole = Role.getRoleFromPortalRole(portalRole);
|
||||
if(gotRole != null && gotRole.ordinal() > role.ordinal()) {
|
||||
|
@ -309,24 +316,29 @@ public class CKANUser extends CKAN {
|
|||
|
||||
public boolean isCatalogueModerator() {
|
||||
if(catalogueModerator == null) {
|
||||
catalogueModerator = SecretManagerProvider.instance.get().getUser().getRoles().contains(Moderated.CATALOGUE_MODERATOR);
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
Owner owner = secret.getOwner();
|
||||
catalogueModerator = owner.getRoles().contains(Moderated.CATALOGUE_MODERATOR);
|
||||
}
|
||||
return catalogueModerator;
|
||||
}
|
||||
|
||||
public String getSurnameName(){
|
||||
User user = SecretManagerProvider.instance.get().getUser();
|
||||
return user.getFullName();
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
Owner owner = secret.getOwner();
|
||||
return owner.getLastName() + owner.getFirstName();
|
||||
}
|
||||
|
||||
public String getNameSurname() {
|
||||
User user = SecretManagerProvider.instance.get().getUser();
|
||||
return user.getFullName(true);
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
Owner owner = secret.getOwner();
|
||||
return owner.getFirstName() + owner.getLastName();
|
||||
}
|
||||
|
||||
public String getEMail() {
|
||||
User user = SecretManagerProvider.instance.get().getUser();
|
||||
return user.getEmail();
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
Owner owner = secret.getOwner();
|
||||
return owner.getEmail();
|
||||
}
|
||||
|
||||
}
|
|
@ -10,8 +10,8 @@ import javax.cache.expiry.CreatedExpiryPolicy;
|
|||
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;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -35,14 +35,14 @@ public abstract class CKANUserCache {
|
|||
}
|
||||
|
||||
public synchronized static CKANUser getCurrrentCKANUser() {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
String context = secretManager.getContext();
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
String context = secret.getContext();
|
||||
Cache<String,CKANUser> userCache = cacheManager.getCache(context);
|
||||
if(userCache == null) {
|
||||
userCache = cacheManager.createCache(context, userCacheConfiguration);
|
||||
}
|
||||
|
||||
String gcubeUsername = secretManager.getUser().getUsername();
|
||||
String gcubeUsername = secret.getOwner().getId();
|
||||
CKANUser ckanUser = userCache.get(gcubeUsername);
|
||||
if(ckanUser == null) {
|
||||
ckanUser = new CKANUser();
|
||||
|
@ -53,14 +53,14 @@ public abstract class CKANUserCache {
|
|||
}
|
||||
|
||||
public synchronized static void removeUserFromCache() {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
String gcubeUsername = secretManager.getUser().getUsername();
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
String gcubeUsername = secret.getOwner().getId();
|
||||
removeUserFromCache(gcubeUsername);
|
||||
}
|
||||
|
||||
public synchronized static void removeUserFromCache(String gcubeUsername) {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
String context = secretManager.getContext();
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
String context = secret.getContext();
|
||||
Cache<String,CKANUser> userCache = cacheManager.getCache(context);
|
||||
if(userCache != null) {
|
||||
userCache.remove(gcubeUsername);
|
||||
|
@ -68,8 +68,8 @@ public abstract class CKANUserCache {
|
|||
}
|
||||
|
||||
public synchronized static void emptyUserCache() {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
String context = secretManager.getContext();
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
String context = secret.getContext();
|
||||
cacheManager.destroyCache(context);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ import javax.ws.rs.NotAuthorizedException;
|
|||
import javax.ws.rs.NotFoundException;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.gcube.common.resources.gcore.GenericResource;
|
||||
import org.gcube.common.resources.gcore.Resources;
|
||||
import org.gcube.datacatalogue.metadatadiscovery.reader.MetadataFormatDiscovery;
|
||||
|
@ -29,9 +31,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
|
|
|
@ -5,8 +5,8 @@ import javax.ws.rs.core.HttpHeaders;
|
|||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.gcat.api.GCatConstants;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class BaseREST {
|
|||
protected static final String LOCATION_HEADER = "Location";
|
||||
|
||||
protected void setCalledMethod(String method) {
|
||||
CalledMethodProvider.instance.set(method);
|
||||
InnerMethodName.instance.set(method);
|
||||
logger.info("{}", uriInfo.getAbsolutePath());
|
||||
}
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ public class Item extends REST<CKANPackage> implements org.gcube.gcat.api.interf
|
|||
Boolean countOnly = false;
|
||||
MultivaluedMap<String,String> queryParameters = uriInfo.getQueryParameters();
|
||||
if(queryParameters.containsKey(GCatConstants.COUNT_QUERY_PARAMETER)) {
|
||||
countOnly = Boolean.parseBoolean(queryParameters.get(GCatConstants.ALL_FIELDS_QUERY_PARAMETER).get(0));
|
||||
countOnly = Boolean.parseBoolean(queryParameters.get(GCatConstants.COUNT_QUERY_PARAMETER).get(0));
|
||||
}
|
||||
|
||||
if(countOnly) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.gcat.rest;
|
||||
|
||||
import javax.ws.rs.InternalServerErrorException;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
@ -29,8 +30,10 @@ public class REST<C extends CKAN> extends BaseREST implements CRUD<Response,Resp
|
|||
C ckan = reference.newInstance();
|
||||
ckan.setUriInfo(uriInfo);
|
||||
return ckan;
|
||||
} catch (WebApplicationException e) {
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
throw new InternalServerErrorException();
|
||||
throw new InternalServerErrorException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
package org.gcube.gcat.rest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.ws.rs.container.ContainerRequestContext;
|
||||
import javax.ws.rs.container.ContainerRequestFilter;
|
||||
import javax.ws.rs.container.ContainerResponseContext;
|
||||
import javax.ws.rs.container.ContainerResponseFilter;
|
||||
import javax.ws.rs.container.PreMatching;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.authorization.utils.secret.GCubeSecret;
|
||||
import org.gcube.common.authorization.utils.secret.JWTSecret;
|
||||
import org.gcube.common.authorization.utils.secret.Secret;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@Provider
|
||||
@PreMatching
|
||||
public class RequestFilter implements ContainerRequestFilter, ContainerResponseFilter {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(RequestFilter.class);
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext requestContext) throws IOException {
|
||||
logger.trace("PreMatching RequestFilter");
|
||||
|
||||
SecretManagerProvider.instance.reset();
|
||||
SecretManager secretManager = new SecretManager();
|
||||
|
||||
String token = AccessTokenProvider.instance.get();
|
||||
if(token!=null) {
|
||||
Secret secret = new JWTSecret(token);
|
||||
secretManager.addSecret(secret);
|
||||
}
|
||||
|
||||
token = SecurityTokenProvider.instance.get();
|
||||
if(token!=null) {
|
||||
Secret secret = new GCubeSecret(token);
|
||||
secretManager.addSecret(secret);
|
||||
}
|
||||
|
||||
SecretManagerProvider.instance.set(secretManager);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
|
||||
throws IOException {
|
||||
logger.trace("ResponseFilter");
|
||||
SecretManagerProvider.instance.reset();
|
||||
}
|
||||
|
||||
}
|
|
@ -24,8 +24,8 @@ 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.security.providers.SecretManagerProvider;
|
||||
//import org.gcube.common.authorization.control.annotations.AuthorizationControl;
|
||||
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;
|
||||
|
|
|
@ -13,8 +13,9 @@ import javax.ws.rs.Produces;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.security.Owner;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.gcat.annotation.PURGE;
|
||||
//import org.gcube.common.authorization.control.annotations.AuthorizationControl;
|
||||
import org.gcube.gcat.api.GCatConstants;
|
||||
|
@ -141,9 +142,9 @@ public class User extends REST<CKANUser> implements org.gcube.gcat.api.interface
|
|||
@DELETE
|
||||
// @AuthorizationControl(allowedRoles={Role.CATALOGUE_MANAGER}, exception=NotAuthorizedException.class)
|
||||
public Response removeCallerFromCache() {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
org.gcube.common.authorization.utils.user.User user = secretManager.getUser();
|
||||
if(user.getRoles().contains(Role.MANAGER.getPortalRole())) {
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
Owner owner = secret.getOwner();
|
||||
if(owner.getRoles().contains(Role.MANAGER.getPortalRole())) {
|
||||
CKANUserCache.removeUserFromCache();
|
||||
}else {
|
||||
throw new ForbiddenException("Only " + Role.MANAGER.getPortalRole() + "s are authorized to remove an user from the cache");
|
||||
|
@ -155,9 +156,9 @@ public class User extends REST<CKANUser> implements org.gcube.gcat.api.interface
|
|||
@Path("/{" + GCUBE_USERNAME_PARAMETER + "}")
|
||||
// @AuthorizationControl(allowedRoles={Role.CATALOGUE_MANAGER}, exception=NotAuthorizedException.class)
|
||||
public Response removeUserFromCache(@PathParam(GCUBE_USERNAME_PARAMETER) String username) {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
org.gcube.common.authorization.utils.user.User user = secretManager.getUser();
|
||||
if(user.getRoles().contains(Role.MANAGER.getPortalRole())) {
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
Owner owner = secret.getOwner();
|
||||
if(owner.getRoles().contains(Role.MANAGER.getPortalRole())) {
|
||||
CKANUserCache.removeUserFromCache(username);
|
||||
}else {
|
||||
throw new ForbiddenException("Only " + Role.MANAGER.getPortalRole() + "s are authorized to remove an user from the cache");
|
||||
|
|
|
@ -6,11 +6,9 @@ import java.util.List;
|
|||
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
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.security.AuthorizedTasks;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
import org.gcube.gcat.configuration.CatalogueConfigurationFactory;
|
||||
import org.gcube.gcat.persistence.ckan.CKANUserCache;
|
||||
|
@ -129,11 +127,9 @@ public class SocialPost extends Thread {
|
|||
}
|
||||
|
||||
public void sendSocialPost(boolean notifyUsers) {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
try {
|
||||
String fullName = CKANUserCache.getCurrrentCKANUser().getNameSurname();
|
||||
|
||||
|
||||
StringWriter messageWriter = new StringWriter();
|
||||
messageWriter.append(String.format(NOTIFICATION_MESSAGE, fullName, itemTitle, itemURL));
|
||||
|
||||
|
@ -152,21 +148,29 @@ public class SocialPost extends Thread {
|
|||
logger.debug("The social post that is going to be written is\n{}", message);
|
||||
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
secretManager.startSession(secret);
|
||||
|
||||
PostClient postClient = new PostClient();
|
||||
PostInputBean postInputBean = new PostInputBean();
|
||||
postInputBean.setEnablenotification(notifyUsers);
|
||||
postInputBean.setText(message);
|
||||
Post post = postClient.writeApplicationPost(postInputBean);
|
||||
logger.trace("Sent post {}", post);
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PostClient postClient = new PostClient();
|
||||
PostInputBean postInputBean = new PostInputBean();
|
||||
postInputBean.setEnablenotification(notifyUsers);
|
||||
postInputBean.setText(message);
|
||||
Post post = postClient.writeApplicationPost(postInputBean);
|
||||
logger.trace("Sent post is {}", post);
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to send Social Post", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
AuthorizedTasks.executeSafely(runnable, secret);
|
||||
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to send Social Post", e);
|
||||
} finally {
|
||||
secretManager.endSession();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ import java.util.Properties;
|
|||
|
||||
import javax.ws.rs.InternalServerErrorException;
|
||||
|
||||
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;
|
||||
import org.gcube.common.keycloak.model.TokenResponse;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.AccessTokenSecret;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -39,16 +39,10 @@ public class Constants {
|
|||
}
|
||||
}
|
||||
|
||||
private static TokenResponse getJWTAccessToken() throws Exception {
|
||||
String contextToAuthorise = SecretManagerProvider.instance.get().getContext();
|
||||
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(CLIENT_ID, getClientSecret(contextToAuthorise), contextToAuthorise, null);
|
||||
return tr;
|
||||
}
|
||||
|
||||
public static Secret getCatalogueSecret() throws Exception {
|
||||
TokenResponse tr = getJWTAccessToken();
|
||||
Secret secret = new JWTSecret(tr.getAccessToken());
|
||||
return secret;
|
||||
String contextToAuthorise = SecretManagerProvider.instance.get().getContext();
|
||||
TokenResponse tokenResponse = KeycloakClientFactory.newInstance().queryUMAToken(contextToAuthorise, CLIENT_ID, getClientSecret(contextToAuthorise), contextToAuthorise, null);
|
||||
return new AccessTokenSecret(tokenResponse.getAccessToken());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.Map;
|
|||
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,11 +3,13 @@ package org.gcube.gcat.workspace;
|
|||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
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.Secret;
|
||||
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||
import org.gcube.common.security.AuthorizedTasks;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||
import org.gcube.common.storagehub.model.Metadata;
|
||||
import org.gcube.gcat.utils.Constants;
|
||||
|
@ -48,43 +50,54 @@ public class CatalogueStorageHubManagement {
|
|||
}
|
||||
|
||||
public URL ensureResourcePersistence(URL persistedURL, String itemID, String resourceID) throws Exception {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
try {
|
||||
secretManager.startSession(secret);
|
||||
GXHTTPStringRequest gxhttpStringRequest = GXHTTPStringRequest.newRequest(persistedURL.toString());
|
||||
gxhttpStringRequest.from(Constants.CATALOGUE_NAME);
|
||||
gxhttpStringRequest.isExternalCall(true);
|
||||
HttpURLConnection httpURLConnection = gxhttpStringRequest.get();
|
||||
mimeType = httpURLConnection.getContentType().split(";")[0];
|
||||
originalFilename = getOriginalFileName(httpURLConnection);
|
||||
CatalogueMetadata catalogueMetadata = new CatalogueMetadata(itemID);
|
||||
storageHubManagement.setCheckMetadata(catalogueMetadata);
|
||||
Metadata metadata = catalogueMetadata.getMetadata(persistedURL, originalFilename, resourceID);
|
||||
persistedURL = storageHubManagement.persistFile(httpURLConnection.getInputStream(), resourceID, mimeType,
|
||||
metadata);
|
||||
mimeType = storageHubManagement.getMimeType();
|
||||
return persistedURL;
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while trying to persists the resource", e);
|
||||
throw e;
|
||||
} finally {
|
||||
secretManager.endSession();
|
||||
|
||||
Callable<URL> callable = new Callable<URL>() {
|
||||
|
||||
@Override
|
||||
public URL call() throws Exception {
|
||||
GXHTTPStringRequest gxhttpStringRequest = GXHTTPStringRequest.newRequest(persistedURL.toString());
|
||||
gxhttpStringRequest.from(Constants.CATALOGUE_NAME);
|
||||
HttpURLConnection httpURLConnection = gxhttpStringRequest.get();
|
||||
mimeType = httpURLConnection.getContentType().split(";")[0];
|
||||
originalFilename = getOriginalFileName(httpURLConnection);
|
||||
CatalogueMetadata catalogueMetadata = new CatalogueMetadata(itemID);
|
||||
storageHubManagement.setCheckMetadata(catalogueMetadata);
|
||||
Metadata metadata = catalogueMetadata.getMetadata(persistedURL, originalFilename, resourceID);
|
||||
URL persistedURL = storageHubManagement.persistFile(httpURLConnection.getInputStream(), resourceID, mimeType,
|
||||
metadata);
|
||||
mimeType = storageHubManagement.getMimeType();
|
||||
return persistedURL;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return AuthorizedTasks.executeSafely(callable, secret);
|
||||
} catch (Throwable t) {
|
||||
logger.error("Error while trying to persists the resource", t);
|
||||
throw new InternalServerErrorException(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deleteResourcePersistence(String itemID, String resourceID, String mimeType) throws Exception {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
try {
|
||||
secretManager.startSession(secret);
|
||||
storageHubManagement = new StorageHubManagement();
|
||||
CatalogueMetadata catalogueMetadata = new CatalogueMetadata(itemID);
|
||||
storageHubManagement.setCheckMetadata(catalogueMetadata);
|
||||
storageHubManagement.removePersistedFile(resourceID, mimeType);
|
||||
} finally {
|
||||
secretManager.endSession();
|
||||
}
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
storageHubManagement = new StorageHubManagement();
|
||||
CatalogueMetadata catalogueMetadata = new CatalogueMetadata(itemID);
|
||||
storageHubManagement.setCheckMetadata(catalogueMetadata);
|
||||
storageHubManagement.removePersistedFile(resourceID, mimeType);
|
||||
}catch (Exception e) {
|
||||
logger.error("Error while trying to delete resource with ID {} and mimetype {} of the item with ID {}", resourceID, mimeType, itemID, e);
|
||||
throw new InternalServerErrorException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
AuthorizedTasks.executeSafely(runnable, secret);
|
||||
}
|
||||
|
||||
protected void internalAddRevisionID(String resourceID, String revisionID) throws Exception {
|
||||
|
@ -104,38 +117,57 @@ public class CatalogueStorageHubManagement {
|
|||
}
|
||||
|
||||
public void renameFile(String resourceID, String revisionID) throws Exception {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
try {
|
||||
secretManager.startSession(secret);
|
||||
FileContainer createdfile = storageHubManagement.getPersistedFile();
|
||||
createdfile.rename(resourceID);
|
||||
internalAddRevisionID(resourceID, revisionID);
|
||||
} finally {
|
||||
secretManager.endSession();
|
||||
}
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
FileContainer createdfile = storageHubManagement.getPersistedFile();
|
||||
createdfile.rename(resourceID);
|
||||
internalAddRevisionID(resourceID, revisionID);
|
||||
}catch (Exception e) {
|
||||
logger.error("Error while trying to rename file of resource with ID {} and revision with ID {}", resourceID, revisionID, e);
|
||||
throw new InternalServerErrorException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
AuthorizedTasks.executeSafely(runnable, secret);
|
||||
}
|
||||
|
||||
public void addRevisionID(String resourceID, String revisionID) throws Exception {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
try {
|
||||
secretManager.startSession(secret);
|
||||
internalAddRevisionID(resourceID, revisionID);
|
||||
} finally {
|
||||
secretManager.endSession();
|
||||
}
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
internalAddRevisionID(resourceID, revisionID);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while trying to add revision of resource with ID {} and revision with ID {}", resourceID, revisionID, e);
|
||||
throw new InternalServerErrorException(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
AuthorizedTasks.executeSafely(runnable, secret);
|
||||
}
|
||||
|
||||
public FileContainer retrievePersistedFile(String id, String mimeType) throws Exception {
|
||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
try {
|
||||
secretManager.startSession(secret);
|
||||
return storageHubManagement.getPersistedFile(id, mimeType);
|
||||
} finally {
|
||||
secretManager.endSession();
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
Callable<FileContainer> callable = new Callable<FileContainer>() {
|
||||
@Override
|
||||
public FileContainer call() throws Exception {
|
||||
try {
|
||||
return storageHubManagement.getPersistedFile(id, mimeType);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error while trying to read file with ID {} and mimetype {} from storagehub", id, mimeType, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
return AuthorizedTasks.executeSafely(callable, secret);
|
||||
} catch (Throwable t) {
|
||||
logger.error("Error while trying to read file with ID {} and mimetype {} from storagehub", id, mimeType, t);
|
||||
throw new InternalServerErrorException(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,11 @@ import java.io.IOException;
|
|||
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.gcube.common.keycloak.KeycloakClientFactory;
|
||||
import org.gcube.common.keycloak.model.TokenResponse;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.AccessTokenSecret;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
|
@ -48,32 +49,20 @@ public class ContextTest {
|
|||
|
||||
}
|
||||
|
||||
public static void set(Secret secret) throws Exception {
|
||||
SecretManagerProvider.instance.reset();
|
||||
SecretManager secretManager = new SecretManager();
|
||||
SecretManagerProvider.instance.set(secretManager);
|
||||
secretManager.addSecret(secret);
|
||||
secretManager.set();
|
||||
public static void setContextBySecret(Secret secret) throws Exception {
|
||||
SecretManagerProvider.instance.set(secret);
|
||||
}
|
||||
|
||||
public static void setContext(String token) throws Exception {
|
||||
Secret secret = getSecret(token);
|
||||
set(secret);
|
||||
}
|
||||
|
||||
public static void setContextByName(String fullContextName) throws Exception {
|
||||
Secret secret = getSecretByContextName(fullContextName);
|
||||
set(secret);
|
||||
}
|
||||
|
||||
private static Secret getSecret(String token) throws Exception {
|
||||
Secret secret = SecretUtility.getSecretByTokenString(token);
|
||||
return secret;
|
||||
setContextBySecret(secret);
|
||||
}
|
||||
|
||||
private static Secret getSecretByContextName(String fullContextName) throws Exception {
|
||||
String token = ContextTest.properties.getProperty(fullContextName);
|
||||
return getSecret(token);
|
||||
String clientID = "";
|
||||
String clientSecret = ContextTest.properties.getProperty(fullContextName);
|
||||
TokenResponse tokenResponse = KeycloakClientFactory.newInstance().queryUMAToken(fullContextName, clientID, clientSecret, fullContextName, null);
|
||||
return new AccessTokenSecret(tokenResponse.getAccessToken());
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.io.InputStreamReader;
|
|||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.gcat.ContextTest;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
|
@ -6,8 +6,8 @@ import java.util.List;
|
|||
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.SecretManagerProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.security.ContextBean;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.gcat.ContextTest;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
import org.junit.Ignore;
|
||||
|
@ -70,12 +70,12 @@ public class CKANOrganizationTest extends ContextTest {
|
|||
public void createOrganization() throws Exception {
|
||||
ContextTest.setContextByName("/gcube/devNext/NextNext");
|
||||
String context = SecretManagerProvider.instance.get().getContext();
|
||||
ScopeBean scopeBean = new ScopeBean(context);
|
||||
ContextBean contextBean = new ContextBean(context);
|
||||
CKANOrganization ckanOrganization = new CKANOrganization();
|
||||
ckanOrganization.setApiKey(CKANUtility.getSysAdminAPI());
|
||||
String name = CatalogueConfiguration.getOrganizationName(scopeBean);
|
||||
String name = CatalogueConfiguration.getOrganizationName(context);
|
||||
ckanOrganization.setName(name);
|
||||
String json = "{\"display_name\": \"" + scopeBean.name() + "\",\"description\": \"" + context + " Organization\",\"name\": \"" + name + "\"}";
|
||||
String json = "{\"display_name\": \"" + contextBean.name() + "\",\"description\": \"" + context + " Organization\",\"name\": \"" + name + "\"}";
|
||||
logger.info("Going to create Organization {} : {}", name, json);
|
||||
// ckanOrganization.create(json);
|
||||
}
|
||||
|
|
|
@ -22,13 +22,10 @@ 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.SecretManagerProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.gcat.ContextTest;
|
||||
import org.gcube.gcat.api.GCatConstants;
|
||||
import org.gcube.gcat.api.configuration.CatalogueConfiguration;
|
||||
import org.gcube.gcat.api.moderation.CMItemStatus;
|
||||
import org.gcube.gcat.api.moderation.Moderated;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
@ -180,8 +177,7 @@ public class CKANPackageTest extends ContextTest {
|
|||
@Test
|
||||
public void listWithParameters() throws Exception {
|
||||
String contextName = "/gcube/devNext/NextNext";
|
||||
ScopeBean scopeBean = new ScopeBean(contextName);
|
||||
String ckanOrganizationName = CatalogueConfiguration.getOrganizationName(scopeBean);
|
||||
String ckanOrganizationName = CatalogueConfiguration.getOrganizationName(contextName);
|
||||
ContextTest.setContextByName(contextName);
|
||||
|
||||
CKANPackage ckanPackage = new CKANPackage();
|
||||
|
@ -312,8 +308,7 @@ public class CKANPackageTest extends ContextTest {
|
|||
|
||||
protected CKANPackage createPackage(ObjectMapper mapper, Boolean socialPost) throws Exception {
|
||||
String currentContext = SecretManagerProvider.instance.get().getContext();
|
||||
ScopeBean scopeBean = new ScopeBean(currentContext);
|
||||
String organization = CatalogueConfiguration.getOrganizationName(scopeBean);
|
||||
String organization = CatalogueConfiguration.getOrganizationName(currentContext);
|
||||
|
||||
ObjectNode itemObjectNode = mapper.createObjectNode();
|
||||
itemObjectNode.put(CKAN.NAME_KEY, ITEM_NAME_VALUE);
|
||||
|
|
|
@ -24,8 +24,9 @@ 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.client.exceptions.ObjectNotFound;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.security.ContextBean;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.gcat.ContextTest;
|
||||
import org.gcube.gcat.api.GCatConstants;
|
||||
import org.gcube.gcat.persistence.ckan.CKANGroup;
|
||||
|
@ -172,8 +173,13 @@ public class GRSFUtilities extends ContextTest {
|
|||
ckanGroupToCreate.setApiKey(sysAdminAPI);
|
||||
ckanGroupToCreate.setName(name);
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("display_name", name);
|
||||
node.put("title", name);
|
||||
if(name.compareTo("SDG")==0){
|
||||
node.put("display_name", "FAO SDG 14.4.1 Questionnaire");
|
||||
node.put("title", "FAO SDG 14.4.1 Questionnaire");
|
||||
}else{
|
||||
node.put("display_name", name);
|
||||
node.put("title", name);
|
||||
}
|
||||
node.put("name", getGroupId(name));
|
||||
String json = objectMapper.writeValueAsString(node);
|
||||
logger.info(json);
|
||||
|
@ -194,8 +200,9 @@ public class GRSFUtilities extends ContextTest {
|
|||
// };
|
||||
//
|
||||
List<String> groupNames = CKANGroupTest.listGroup();
|
||||
logger.debug(SecretManagerProvider.instance.get().getUser().getUsername());
|
||||
logger.debug(SecretManagerProvider.instance.get().getContext());
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
logger.debug(secret.getOwner().getId());
|
||||
logger.debug(secret.getContext());
|
||||
|
||||
for(String name : groupNames) {
|
||||
CKANGroup ckanGroupToCreate = new CKANGroup();
|
||||
|
@ -239,11 +246,11 @@ public class GRSFUtilities extends ContextTest {
|
|||
// @Test
|
||||
public void manageOrganizations() throws JsonProcessingException {
|
||||
String context = SecretManagerProvider.instance.get().getContext();
|
||||
ScopeBean scopeBean = new ScopeBean(context);
|
||||
ContextBean contextBean = new ContextBean(context);
|
||||
|
||||
String sysAdminAPI = CKANUtility.getSysAdminAPI();
|
||||
Map<String, String> organizations = new HashMap<>();
|
||||
organizations.put(scopeBean.name(), scopeBean.name());
|
||||
organizations.put(contextBean.name(), contextBean.name());
|
||||
organizations.put("FIRMS", "FIRMS");
|
||||
organizations.put("FishSource", "FishSource");
|
||||
organizations.put("RAM", "RAM");
|
||||
|
@ -258,7 +265,7 @@ public class GRSFUtilities extends ContextTest {
|
|||
node.put("display_name", fancyName);
|
||||
node.put("title", fancyName);
|
||||
node.put("name", org.toLowerCase());
|
||||
String json = objectMapper.writeValueAsString(node);
|
||||
// String json = objectMapper.writeValueAsString(node);
|
||||
try {
|
||||
// ckanOrganization.create(json);
|
||||
// ckanOrganization.purge();
|
||||
|
@ -338,17 +345,19 @@ public class GRSFUtilities extends ContextTest {
|
|||
String[] contexts = new String[] {PRODUCTION_GRSF};
|
||||
for(String context : contexts) {
|
||||
ContextTest.setContextByName(context);
|
||||
logger.debug(SecretManagerProvider.instance.get().getUser().getUsername());
|
||||
logger.debug(SecretManagerProvider.instance.get().getContext());
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
logger.debug(secret.getOwner().getId());
|
||||
logger.debug(secret.getContext());
|
||||
|
||||
CKANPackage ckanPackage = new CKANPackage();
|
||||
SortedSet<String> sortedSet = new TreeSet<>();
|
||||
String[] types = new String[] {"Marine Resource", "Assessment Unit"};
|
||||
for(String type : types) {
|
||||
int offset = 0;
|
||||
boolean go = true;
|
||||
ScopeBean scopeBean = new ScopeBean(context);
|
||||
ContextBean contextBean = new ContextBean(context);
|
||||
while(go) {
|
||||
Map<String,String> parameters = getListParameter(limit, offset==0 ? 0 : (offset*limit), type, scopeBean.name().toLowerCase());
|
||||
Map<String,String> parameters = getListParameter(limit, offset==0 ? 0 : (offset*limit), type, contextBean.name().toLowerCase());
|
||||
String ret = ckanPackage.list(parameters);
|
||||
JsonNode gotList = mapper.readTree(ret);
|
||||
Assert.assertTrue(gotList instanceof ArrayNode);
|
||||
|
@ -363,7 +372,7 @@ public class GRSFUtilities extends ContextTest {
|
|||
go=false;
|
||||
}
|
||||
}
|
||||
File file = new File(scopeBean.name() + "-" + type.replace(" ", "_")+".txt");
|
||||
File file = new File(contextBean.name() + "-" + type.replace(" ", "_")+".txt");
|
||||
if(file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
|
|
@ -4,24 +4,11 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.common.authorization.utils.secret.Secret;
|
||||
import org.gcube.gcat.ContextTest;
|
||||
import org.gcube.gcat.utils.Constants;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SocialPostTest extends ContextTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SocialPostTest.class);
|
||||
|
||||
@Test
|
||||
public void testToken() throws Exception {
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
logger.debug("Application Token is {}", secret.getToken());
|
||||
ContextTest.set(secret);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSendPost() throws Exception {
|
||||
SocialPost socialService = new SocialPost();
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package org.gcube.gcat.social;
|
||||
|
||||
import org.gcube.common.authorization.utils.socialservice.SocialService;
|
||||
import org.gcube.gcat.ContextTest;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SocialServiceTest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(SocialServiceTest.class);
|
||||
|
||||
@Test
|
||||
public void get() throws Exception {
|
||||
ContextTest.setContextByName("/d4science.research-infrastructures.eu/D4Research/AGINFRAplusDev");
|
||||
SocialService socialService = SocialService.getSocialService();
|
||||
logger.debug(socialService.getServiceBasePath());
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package org.gcube.gcat.utils;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.authorization.utils.secret.Secret;
|
||||
import org.gcube.common.encryption.encrypter.StringEncrypter;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.gcube.gcat.ContextTest;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -17,8 +16,9 @@ public class ConstantsTest extends ContextTest {
|
|||
|
||||
@Test
|
||||
public void testGetApplicationToken() throws Exception {
|
||||
logger.debug("Application token for Context {} is {}", SecretManagerProvider.instance.get().getContext(),
|
||||
Constants.getCatalogueSecret().getToken());
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
logger.debug("Authorization Header is {}", secret.getHTTPAuthorizationHeaders());
|
||||
ContextTest.setContextBySecret(secret);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -27,11 +27,5 @@ public class ConstantsTest extends ContextTest {
|
|||
String decrypted = stringEncrypter.decrypt("w0KVc+78b2yUQsndDh/cXyyRquuwyILTygmoF0Y5Dls=");
|
||||
logger.debug("{}", decrypted);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getToken() throws Exception {
|
||||
Secret secret = Constants.getCatalogueSecret();
|
||||
logger.debug(secret.getToken());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue