Feature #21507 support new UMATokensProvider class

This commit is contained in:
Massimiliano Assante 2021-05-25 17:58:30 +02:00
parent 7d43b96e11
commit e9330f651e
5 changed files with 46 additions and 18 deletions

View File

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

View File

@ -4,9 +4,13 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v1.5.1-SNAPSHOT] - 2021-05-25
- Feature #21507 support new UMATokensProvider class
## [v1.5.0] - 2021-04-06 ## [v1.5.0] - 2021-04-06
Removed legacy auth dependency - Removed legacy auth dependency
## [v1.4.1] - 2021-01-26 ## [v1.4.1] - 2021-01-26

10
pom.xml
View File

@ -13,7 +13,7 @@
<artifactId>workspace-widget-portlet</artifactId> <artifactId>workspace-widget-portlet</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<name>workspace-widget-portlet Portlet</name> <name>workspace-widget-portlet Portlet</name>
<version>1.5.0</version> <version>1.5.1-SNAPSHOT</version>
<description> <description>
Workspace Widget Portlet is a small Front-end component looking like G Drive which exposes the content of the user's workspace or VRE Folders in read only mode. Workspace Widget Portlet is a small Front-end component looking like G Drive which exposes the content of the user's workspace or VRE Folders in read only mode.
</description> </description>
@ -36,7 +36,7 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>3.6.1</version> <version>3.6.2-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
@ -79,7 +79,11 @@
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>oidc-library-portal</artifactId> <artifactId>oidc-library-portal</artifactId>
<version>[1.3.0-SNAPSHOT, 2.0.0)</version> <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>oidc-library</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -7,7 +7,7 @@ import java.util.List;
import javax.portlet.ResourceRequest; import javax.portlet.ResourceRequest;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.gcube.common.authorization.library.provider.UmaJWTProvider;
import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
@ -22,6 +22,7 @@ import org.gcube.portal.oidc.lr62.NotAuthorizedException;
import org.gcube.portal.oidc.lr62.OIDCUmaUtil; import org.gcube.portal.oidc.lr62.OIDCUmaUtil;
import org.gcube.portal.oidc.lr62.RefreshException; import org.gcube.portal.oidc.lr62.RefreshException;
import org.gcube.portal.oidc.lr62.UMAException; 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.AuthorizedUser;
import org.gcube.portlets.user.wswidget.shared.WSItem; import org.gcube.portlets.user.wswidget.shared.WSItem;
@ -146,7 +147,7 @@ public class StorageHubServiceUtil {
try { try {
long userId = PortalUtil.getUser(request).getUserId(); long userId = PortalUtil.getUser(request).getUserId();
JWTToken umaToken = OIDCUmaUtil.getUMAToken(request, userId, currentContext); JWTToken umaToken = OIDCUmaUtil.getUMAToken(request, userId, currentContext);
UmaJWTProvider.instance.set(umaToken.getRaw()); UMATokensProvider.instance.set(umaToken.getRaw());
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
@ -173,7 +174,7 @@ public class StorageHubServiceUtil {
String username = currentUsername; String username = currentUsername;
try { try {
JWTToken umaToken = OIDCUmaUtil.getUMAToken(request, username, currentContext); JWTToken umaToken = OIDCUmaUtil.getUMAToken(request, username, currentContext);
UmaJWTProvider.instance.set(umaToken.getRaw()); UMATokensProvider.instance.set(umaToken.getRaw());
} catch (InvalidTokenException | MissingTokenException | RefreshException | NotAuthorizedException } catch (InvalidTokenException | MissingTokenException | RefreshException | NotAuthorizedException
| UMAException e1) { | UMAException e1) {
_log.warn("could not get UMA Token for context="+currentContext); _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.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.gcube.common.authorization.library.provider.UmaJWTProvider;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.StreamDescriptor; import org.gcube.common.storagehub.client.StreamDescriptor;
import org.gcube.common.storagehub.client.dsl.FileContainer; import org.gcube.common.storagehub.client.dsl.FileContainer;
@ -26,6 +26,7 @@ import org.gcube.common.storagehub.model.items.ExternalURL;
import org.gcube.common.storagehub.model.items.Item; import org.gcube.common.storagehub.model.items.Item;
import org.gcube.oidc.rest.JWTToken; import org.gcube.oidc.rest.JWTToken;
import org.gcube.portal.oidc.lr62.OIDCUmaUtil; 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.AuthorizedUser;
import org.gcube.portlets.user.wswidget.shared.Breadcrumb; import org.gcube.portlets.user.wswidget.shared.Breadcrumb;
import org.gcube.portlets.user.wswidget.shared.WSItem; import org.gcube.portlets.user.wswidget.shared.WSItem;
@ -70,7 +71,7 @@ public class WorkspaceWidget extends MVCPortlet {
try { try {
userId = PortalUtil.getUser(resourceRequest).getUserId(); userId = PortalUtil.getUser(resourceRequest).getUserId();
JWTToken umaToken = OIDCUmaUtil.getUMAToken(httpReq, userId, currentContext); JWTToken umaToken = OIDCUmaUtil.getUMAToken(httpReq, userId, currentContext);
UmaJWTProvider.instance.set(umaToken.getRaw()); UMATokensProvider.instance.set(umaToken.getRaw());
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
} }