Feature #21505 support new UMATokensProvider class

This commit is contained in:
Massimiliano Assante 2021-05-25 16:55:50 +02:00
parent 4fc9e7c8f7
commit eed8d5e261
3 changed files with 8 additions and 9 deletions

View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portal.plugins</groupId> <groupId>org.gcube.portal.plugins</groupId>
<artifactId>VREFolder-hook</artifactId> <artifactId>VREFolder-hook</artifactId>
<name>VREFolder-hook Hook</name> <name>VREFolder-hook Hook</name>
<version>6.8.1</version> <version>6.8.2-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<description> <description>
VREFolder-hook handles the user adding/removal from the related Home Library VRE Folder VREFolder-hook handles the user adding/removal from the related Home Library VRE Folder
@ -35,7 +35,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>
@ -49,7 +49,6 @@
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>oidc-library-portal</artifactId> <artifactId>oidc-library-portal</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -3,10 +3,10 @@ package org.gcube.portal.plugins;
import java.util.List; import java.util.List;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.authorization.library.provider.UmaJWTProvider;
import org.gcube.common.storagehub.client.dsl.StorageHubClient; import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.common.storagehub.client.dsl.Util; import org.gcube.common.storagehub.client.dsl.Util;
import org.gcube.common.storagehub.client.dsl.VREFolderManager; import org.gcube.common.storagehub.client.dsl.VREFolderManager;
import org.gcube.portal.oidc.lr62.UMATokensProvider;
import org.gcube.portal.plugins.util.AuthUtil; import org.gcube.portal.plugins.util.AuthUtil;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
@ -64,7 +64,7 @@ public class GCubeHookSiteRoleLocalService extends UserGroupRoleLocalServiceWrap
private void setVREFolderAdministrator(long userId, long groupId, boolean enable) throws Exception { private void setVREFolderAdministrator(long userId, long groupId, boolean enable) throws Exception {
String previousToken = SecurityTokenProvider.instance.get(); String previousToken = SecurityTokenProvider.instance.get();
String previousUMAToken = UmaJWTProvider.instance.get(); String previousUMAToken = UMATokensProvider.instance.get();
//this put the necessary auth tokens (legacy e UMA) in ThreadLocal //this put the necessary auth tokens (legacy e UMA) in ThreadLocal
AuthUtil.setInfraManagerLegacyAndUMATokenInThreadLocal(); AuthUtil.setInfraManagerLegacyAndUMATokenInThreadLocal();
String context = gm.getInfrastructureScope(groupId); String context = gm.getInfrastructureScope(groupId);
@ -81,7 +81,7 @@ public class GCubeHookSiteRoleLocalService extends UserGroupRoleLocalServiceWrap
vreFolderManager.removeAdmin(theUserToPromoteOrDeclass); vreFolderManager.removeAdmin(theUserToPromoteOrDeclass);
_log.info("*VREFolder-Hook** add/remove role operation complete"); _log.info("*VREFolder-Hook** add/remove role operation complete");
UmaJWTProvider.instance.set(previousUMAToken); UMATokensProvider.instance.set(previousUMAToken);
SecurityTokenProvider.instance.set(previousToken); SecurityTokenProvider.instance.set(previousToken);
} }
} }

View File

@ -1,11 +1,11 @@
package org.gcube.portal.plugins; package org.gcube.portal.plugins;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.authorization.library.provider.UmaJWTProvider;
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;
import org.gcube.common.storagehub.client.plugins.AbstractPlugin; import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
import org.gcube.common.storagehub.client.proxies.GroupManagerClient; import org.gcube.common.storagehub.client.proxies.GroupManagerClient;
import org.gcube.portal.oidc.lr62.UMATokensProvider;
import org.gcube.portal.plugins.thread.CheckShareLatexUserThread; import org.gcube.portal.plugins.thread.CheckShareLatexUserThread;
import org.gcube.portal.plugins.thread.RemoveUserTokenFromVREThread; import org.gcube.portal.plugins.thread.RemoveUserTokenFromVREThread;
import org.gcube.portal.plugins.util.AuthUtil; import org.gcube.portal.plugins.util.AuthUtil;
@ -150,7 +150,7 @@ public class GCubeHookUserLocalService extends UserLocalServiceWrapper {
*/ */
private boolean setUser2VREFolder(GroupManager gm, UserManager uMan, String username2Add, String context, boolean add) throws Exception { private boolean setUser2VREFolder(GroupManager gm, UserManager uMan, String username2Add, String context, boolean add) throws Exception {
String previousToken = SecurityTokenProvider.instance.get(); String previousToken = SecurityTokenProvider.instance.get();
String previousUMAToken = UmaJWTProvider.instance.get(); String previousUMAToken = UMATokensProvider.instance.get();
AuthUtil.setInfraManagerLegacyAndUMATokenInThreadLocal(); AuthUtil.setInfraManagerLegacyAndUMATokenInThreadLocal();
_log.info("\n*VREFolder-Hook** new authorizationService PortalClient UMA-Token In ThreadLocal done ****\n\n"); _log.info("\n*VREFolder-Hook** new authorizationService PortalClient UMA-Token In ThreadLocal done ****\n\n");
String vreFolderNameForsHub = getVREFolderNameFromContext(context); String vreFolderNameForsHub = getVREFolderNameFromContext(context);
@ -161,7 +161,7 @@ public class GCubeHookUserLocalService extends UserLocalServiceWrapper {
client.removeUserFromGroup(username2Add, vreFolderNameForsHub); client.removeUserFromGroup(username2Add, vreFolderNameForsHub);
_log.info("*VREFolder-Hook** " + username2Add + " was added or removed succefully from this VRE Folder. Added? (if false was removed)" + add); _log.info("*VREFolder-Hook** " + username2Add + " was added or removed succefully from this VRE Folder. Added? (if false was removed)" + add);
UmaJWTProvider.instance.set(previousUMAToken); UMATokensProvider.instance.set(previousUMAToken);
SecurityTokenProvider.instance.set(previousToken); SecurityTokenProvider.instance.set(previousToken);
return true; return true;
} }