This commit is contained in:
Massimiliano Assante 2021-04-06 12:18:19 +02:00
parent 3927b75c67
commit 23b109755c
3 changed files with 49 additions and 16 deletions

View File

@ -1,19 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="workspace-widget-portlet">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="workspace-widget-portlet"/>
<property name="java-output-path" value="/workspace-widget-portlet/target/classes"/>
</wb-module>
<wb-module deploy-name="workspace-widget-portlet">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="workspace-widget-portlet"/>
<property name="java-output-path" value="/workspace-widget-portlet/target/classes"/>
</wb-module>
</project-modules>

View File

@ -76,6 +76,12 @@
<artifactId>common-authorization</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>oidc-library-portal</artifactId>
<version>[1.3.0-SNAPSHOT, 2.0.0)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>

View File

@ -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 {