save and restore the previous UMA Token in ThreadLocal

This commit is contained in:
Massimiliano Assante 2021-02-02 18:18:47 +01:00
parent 90775c6563
commit c4a1bbe4f9
1 changed files with 6 additions and 1 deletions

View File

@ -38,6 +38,7 @@ import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.authorization.library.provider.UmaJWTProvider;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.portal.PortalContext;
@ -93,7 +94,6 @@ import org.gcube.vremanagement.vremodel.cl.stubs.types.VREDescription;
import org.gcube.vremanagement.vremodeler.utils.Utils;
import org.gcube.vremanagement.vremodeler.utils.reports.DeployReport;
import org.gcube.vremanagement.vremodeler.utils.reports.FunctionalityReport;
import org.gcube.vremanagement.vremodeler.utils.reports.GHNonCloudReport;
import org.gcube.vremanagement.vremodeler.utils.reports.Resource;
import org.gcube.vremanagement.vremodeler.utils.reports.ServiceReport;
import org.gcube.vremanagement.vremodeler.utils.reports.Status;
@ -699,6 +699,7 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
private void createVRESharedGroupFolder(UserManager uMan, org.gcube.vomanagement.usermanagement.model.GCubeGroup vreCreated, String designer, String manager, String description) throws Exception {
GroupManager gm = new LiferayGroupManager();
String previousToken = SecurityTokenProvider.instance.get();
String previousUMAToken = UmaJWTProvider.instance.get();
//get the super user
log.info("Getting super user with role {}", GatewayRolesNames.INFRASTRUCTURE_MANAGER.getRoleName());
//get the super user
@ -722,6 +723,7 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
SecurityTokenProvider.instance.set(theAdminToken);
OIDCUmaUtil.provideConfiguredPortalClientUMATokenInThreadLocal("/" + PortalContext.getConfiguration().getInfrastructureName());
System.out.println("\n\n***** new authorizationService PortalClient UMA-Token In ThreadLocal done **** ");
String newVreContext = gm.getInfrastructureScope(vreCreated.getGroupId());
@ -737,7 +739,10 @@ public class VREDeployerServiceImpl extends RemoteServiceServlet implements Vre
log.info("Created the VRE Folder on storageHub: {} ", vreFolderName);
UmaJWTProvider.instance.set(previousUMAToken);
SecurityTokenProvider.instance.set(previousToken);
//}
}
/**