updated use of wrong token provider

This commit is contained in:
Massimiliano Assante 2021-05-25 18:24:17 +02:00
parent b9e4aea1db
commit 9890dfe01c
2 changed files with 8 additions and 7 deletions

View File

@ -7,7 +7,7 @@ import java.util.List;
import javax.portlet.ResourceRequest;
import javax.servlet.http.HttpServletRequest;
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
@ -17,12 +17,12 @@ import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.oidc.rest.JWTToken;
import org.gcube.portal.oidc.lr62.InvalidTokenException;
import org.gcube.portal.oidc.lr62.JWTTokenUtil;
import org.gcube.portal.oidc.lr62.MissingTokenException;
import org.gcube.portal.oidc.lr62.NotAuthorizedException;
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
import org.gcube.portal.oidc.lr62.RefreshException;
import org.gcube.portal.oidc.lr62.UMAException;
import org.gcube.portal.oidc.lr62.UMATokensProvider;
import org.gcube.portlets.user.wswidget.shared.AuthorizedUser;
import org.gcube.portlets.user.wswidget.shared.WSItem;
@ -147,7 +147,7 @@ public class StorageHubServiceUtil {
try {
long userId = PortalUtil.getUser(request).getUserId();
JWTToken umaToken = OIDCUmaUtil.getUMAToken(request, userId, currentContext);
UMATokensProvider.instance.set(umaToken.getRaw());
AccessTokenProvider.instance.set(JWTTokenUtil.getAccessTokenString(umaToken));
} catch (Exception e1) {
e1.printStackTrace();
}
@ -174,7 +174,7 @@ public class StorageHubServiceUtil {
String username = currentUsername;
try {
JWTToken umaToken = OIDCUmaUtil.getUMAToken(request, username, currentContext);
UMATokensProvider.instance.set(umaToken.getRaw());
AccessTokenProvider.instance.set(JWTTokenUtil.getAccessTokenString(umaToken));
} catch (InvalidTokenException | MissingTokenException | RefreshException | NotAuthorizedException
| UMAException e1) {
_log.warn("could not get UMA Token for context="+currentContext);

View File

@ -12,7 +12,7 @@ import javax.portlet.ResourceResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.StreamDescriptor;
import org.gcube.common.storagehub.client.dsl.FileContainer;
@ -25,8 +25,9 @@ import org.gcube.common.storagehub.model.items.ExternalLink;
import org.gcube.common.storagehub.model.items.ExternalURL;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.oidc.rest.JWTToken;
import org.gcube.portal.oidc.lr62.JWTTokenUtil;
import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
import org.gcube.portal.oidc.lr62.UMATokensProvider;
import org.gcube.portlets.user.wswidget.shared.AuthorizedUser;
import org.gcube.portlets.user.wswidget.shared.Breadcrumb;
import org.gcube.portlets.user.wswidget.shared.WSItem;
@ -71,7 +72,7 @@ public class WorkspaceWidget extends MVCPortlet {
try {
userId = PortalUtil.getUser(resourceRequest).getUserId();
JWTToken umaToken = OIDCUmaUtil.getUMAToken(httpReq, userId, currentContext);
UMATokensProvider.instance.set(umaToken.getRaw());
AccessTokenProvider.instance.set(JWTTokenUtil.getAccessTokenString(umaToken));
} catch (Exception e1) {
e1.printStackTrace();
}