2018-05-11 17:50:37 +02:00
|
|
|
package org.gcube.dataharvest.utils;
|
|
|
|
|
2018-05-18 12:00:10 +02:00
|
|
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
2022-09-01 14:08:36 +02:00
|
|
|
import org.gcube.common.authorization.utils.manager.SecretManager;
|
|
|
|
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
|
|
|
import org.gcube.common.authorization.utils.secret.Secret;
|
2018-05-11 17:50:37 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2018-05-18 14:17:54 +02:00
|
|
|
/**
|
|
|
|
* @author Eric Perrone (ISTI - CNR)
|
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
|
|
*/
|
2018-05-11 17:50:37 +02:00
|
|
|
public class Utils {
|
2018-05-17 16:04:22 +02:00
|
|
|
|
2018-05-11 17:50:37 +02:00
|
|
|
private static Logger logger = LoggerFactory.getLogger(Utils.class);
|
2018-05-18 18:33:28 +02:00
|
|
|
|
|
|
|
public static String getCurrentContext() throws ObjectNotFound, Exception {
|
2022-09-05 14:49:45 +02:00
|
|
|
return SecretManagerProvider.instance.get().getContext();
|
2018-05-18 12:00:10 +02:00
|
|
|
}
|
|
|
|
|
2022-09-01 14:08:36 +02:00
|
|
|
public static void setContext(Secret secret) throws Exception {
|
|
|
|
SecretManagerProvider.instance.reset();
|
|
|
|
SecretManager secretManager = new SecretManager();
|
|
|
|
SecretManagerProvider.instance.set(secretManager);
|
|
|
|
secretManager.addSecret(secret);
|
|
|
|
secretManager.set();
|
2018-05-18 12:00:10 +02:00
|
|
|
}
|
2018-05-18 18:33:28 +02:00
|
|
|
|
2018-05-11 17:50:37 +02:00
|
|
|
}
|