42 lines
1.2 KiB
Java
42 lines
1.2 KiB
Java
package org.gcube.data.transfer.service.transfers.engine.impl;
|
|
|
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
|
import org.gcube.common.security.providers.SecretManagerProvider;
|
|
import org.gcube.common.security.secrets.Secret;
|
|
|
|
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();
|
|
// }
|
|
|
|
Secret secret = SecretManagerProvider.instance.get();
|
|
if(secret!=null) {
|
|
log.debug("Found valid secret");
|
|
return secret.getContext();
|
|
}else
|
|
throw new RuntimeException("SecretProvider not set");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
public static String getCurrentUser() throws ObjectNotFound, Exception {
|
|
Secret secret = SecretManagerProvider.instance.get();
|
|
return secret.getOwner().getId();
|
|
}
|
|
|
|
}
|