This repository has been archived on 2021-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
2021-08-03 15:33:28 +02:00
|
|
|
package org.gcube.application.geoportal.service;
|
2020-11-11 18:17:06 +01:00
|
|
|
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
|
2021-07-30 18:21:29 +02:00
|
|
|
import java.util.Properties;
|
|
|
|
|
2020-11-11 18:17:06 +01:00
|
|
|
public class TokenSetter {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Properties props=new Properties();
|
|
|
|
|
|
|
|
static{
|
|
|
|
try {
|
|
|
|
props.load(TokenSetter.class.getResourceAsStream("/tokens.properties"));
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new RuntimeException("YOU NEED TO SET TOKEN FILE IN CONFIGURATION");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void set(String scope){
|
|
|
|
try{
|
|
|
|
if(!props.containsKey(scope)) throw new RuntimeException("No token found for scope : "+scope);
|
|
|
|
SecurityTokenProvider.instance.set(props.getProperty(scope));
|
2020-11-16 18:21:07 +01:00
|
|
|
}catch(Exception e){
|
|
|
|
e.printStackTrace(System.err);
|
|
|
|
throw e;
|
2020-11-11 18:17:06 +01:00
|
|
|
}
|
|
|
|
ScopeProvider.instance.set(scope);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|