38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
package org.gcube.dataharvest.utils;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.IOException;
|
|
import java.io.InputStreamReader;
|
|
import java.net.HttpURLConnection;
|
|
import java.net.MalformedURLException;
|
|
import java.net.URL;
|
|
|
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
|
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.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
/**
|
|
* @author Eric Perrone (ISTI - CNR)
|
|
* @author Luca Frosini (ISTI - CNR)
|
|
*/
|
|
public class Utils {
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(Utils.class);
|
|
|
|
public static String getCurrentContext() throws ObjectNotFound, Exception {
|
|
return SecretManagerProvider.instance.get().getContext();
|
|
}
|
|
|
|
public static void setContext(Secret secret) throws Exception {
|
|
SecretManagerProvider.instance.reset();
|
|
SecretManager secretManager = new SecretManager();
|
|
SecretManagerProvider.instance.set(secretManager);
|
|
secretManager.addSecret(secret);
|
|
secretManager.set();
|
|
}
|
|
|
|
}
|