diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index f2795c5..39e308c 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,19 +1,28 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index c5f76b3..f5e846d 100644 --- a/pom.xml +++ b/pom.xml @@ -76,6 +76,12 @@ common-authorization provided + + org.gcube.portal + oidc-library-portal + [1.3.0-SNAPSHOT, 2.0.0) + provided + com.liferay.portal portal-service diff --git a/src/main/java/org/gcube/portlets/user/wswidget/StorageHubServiceUtil.java b/src/main/java/org/gcube/portlets/user/wswidget/StorageHubServiceUtil.java index 16bdf6a..5924c32 100644 --- a/src/main/java/org/gcube/portlets/user/wswidget/StorageHubServiceUtil.java +++ b/src/main/java/org/gcube/portlets/user/wswidget/StorageHubServiceUtil.java @@ -7,6 +7,7 @@ import java.util.List; import javax.portlet.ResourceRequest; import javax.servlet.http.HttpServletRequest; +import org.gcube.common.authorization.library.provider.UmaJWTProvider; import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; @@ -14,6 +15,13 @@ import org.gcube.common.storagehub.client.plugins.AbstractPlugin; import org.gcube.common.storagehub.client.proxies.ItemManagerClient; 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.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.portlets.user.wswidget.shared.AuthorizedUser; import org.gcube.portlets.user.wswidget.shared.WSItem; @@ -149,9 +157,19 @@ public class StorageHubServiceUtil { * @param request * @return the VRE Folders Id */ - public static String getVREFoldersId(long groupId) { + public static String getVREFoldersId(long groupId, HttpServletRequest request) { String toReturn = ""; + PortalContext pContext = PortalContext.getConfiguration(); String currentContext = PortalContext.getConfiguration().getCurrentScope(""+groupId); + long userId = pContext.getCurrentUser(request).getUserId(); + try { + JWTToken umaToken = OIDCUmaUtil.getUMAToken(request, userId, currentContext); + UmaJWTProvider.instance.set(umaToken.getRaw()); + } catch (InvalidTokenException | MissingTokenException | RefreshException | NotAuthorizedException + | UMAException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } _log.debug("getVREFoldersId, context="+currentContext); ScopeProvider.instance.set(currentContext); try {