git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/data-transfer/data-transfer-service/2.0@160272 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
f06e2ed014
commit
04e826621e
|
@ -15,4 +15,7 @@ public interface PluginManager {
|
||||||
public ExecutionReport execute(PluginInvocation invocation,String transferredFile)throws PluginException, PluginNotFoundException;
|
public ExecutionReport execute(PluginInvocation invocation,String transferredFile)throws PluginException, PluginNotFoundException;
|
||||||
public void shutdown();
|
public void shutdown();
|
||||||
public Object getPluginInfo(String pluginID) throws PluginNotFoundException, PluginExecutionException;
|
public Object getPluginInfo(String pluginID) throws PluginNotFoundException, PluginExecutionException;
|
||||||
|
|
||||||
|
public void initPlugins();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package org.gcube.data.transfer.service.transfers.engine.impl;
|
||||||
|
|
||||||
|
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class TokenUtils {
|
||||||
|
|
||||||
|
public static String getCurrentScope(){
|
||||||
|
// try{
|
||||||
|
// String token=SecurityTokenProvider.instance.get();
|
||||||
|
// log.debug("Token is : "+token);
|
||||||
|
// if(token==null) throw new Exception("Security Token is null");
|
||||||
|
// AuthorizationEntry entry = authorizationService().get(token);
|
||||||
|
// return entry.getContext();
|
||||||
|
// }catch(Exception e ){
|
||||||
|
// log.debug("Unable to resolve token, checking scope provider..",e);
|
||||||
|
// return ScopeProvider.instance.get();
|
||||||
|
// }
|
||||||
|
|
||||||
|
String scope=ScopeProvider.instance.get();
|
||||||
|
if(scope!=null) {
|
||||||
|
log.debug("Found scope provider {}, skipping token",scope);
|
||||||
|
return scope;
|
||||||
|
}else{
|
||||||
|
try{
|
||||||
|
log.debug("Scope provider not set, reverting to token");
|
||||||
|
String token=SecurityTokenProvider.instance.get();
|
||||||
|
log.debug("Token is : "+token);
|
||||||
|
if(token==null) throw new Exception("Security Token is null");
|
||||||
|
AuthorizationEntry entry = authorizationService().get(token);
|
||||||
|
return entry.getContext();
|
||||||
|
}catch(Exception e){
|
||||||
|
throw new RuntimeException("Unable to evaluate scope ",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue