|
|
|
@ -14,10 +14,8 @@ import javax.ws.rs.core.MediaType;
|
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
|
|
|
|
|
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
|
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
|
|
|
import org.gcube.common.authorization.library.provider.UserInfo;
|
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
|
import org.gcube.datatransfer.resolver.requesthandler.RequestHandler;
|
|
|
|
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -35,19 +33,8 @@ public class GoatResolver {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
String oldToken = SecurityTokenProvider.instance.get();
|
|
|
|
|
String scope = ScopeProvider.instance.get();
|
|
|
|
|
LOG.info("ScopeProvider has scope: " + scope);
|
|
|
|
|
|
|
|
|
|
String appToken = req.getServletContext().getInitParameter(RequestHandler.ROOT_APP_TOKEN);
|
|
|
|
|
|
|
|
|
|
if (oldToken.compareTo(appToken) == 0) {
|
|
|
|
|
LOG.error("Token not passed, SecurityTokenProvider contains the root app token: "
|
|
|
|
|
+ appToken.substring(0, 10) + "...");
|
|
|
|
|
throw ExceptionManager.unauthorizedException(req,
|
|
|
|
|
"You are not authorized. You must pass a valid D4Science token", this.getClass(), "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String username = AuthorizationProvider.instance.get().getClient().getId();
|
|
|
|
|
UserInfo userInfo = new UserInfo(username, new ArrayList<>());
|
|
|
|
|
String userToken = authorizationService().generateUserToken(userInfo, scope);
|
|
|
|
|