adopts now the shub.userExists method to check workspace existance

This commit is contained in:
Massimiliano Assante 2021-02-08 16:52:51 +01:00
parent 6f6a6c1ef7
commit ba257fe7ff
2 changed files with 29 additions and 15 deletions

View File

@ -1,46 +1,58 @@
<?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="create-users-portlet"> <wb-module deploy-name="create-users-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/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="email-templates-library-1.4.4.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/email-templates-library/email-templates-library"> <dependent-module archiveName="email-templates-library-1.4.4.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/email-templates-library/email-templates-library">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<property name="java-output-path" value="/create-users/target/subscribe-users-1.0.0-SNAPSHOT/WEB-INF/classes"/> <property name="java-output-path" value="/create-users/target/subscribe-users-1.0.0-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="create-users-portlet"/> <property name="context-root" value="create-users-portlet"/>
</wb-module> </wb-module>
</project-modules> </project-modules>

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.admin.createusers.server; package org.gcube.portlets.admin.createusers.server;
import static org.gcube.common.authorization.client.Constants.authorizationService; import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -15,6 +16,7 @@ import java.util.Locale;
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.authorization.library.provider.UmaJWTProvider;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
import org.gcube.common.storagehub.client.plugins.AbstractPlugin; import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
import org.gcube.common.storagehub.client.proxies.UserManagerClient; import org.gcube.common.storagehub.client.proxies.UserManagerClient;
import org.gcube.portal.mailing.message.Recipient; import org.gcube.portal.mailing.message.Recipient;
@ -308,9 +310,9 @@ public class CreateUsersImpl extends RemoteServiceServlet implements HandleUsers
OIDCUmaUtil.provideConfiguredPortalClientUMATokenInThreadLocal("/" + PortalContext.getConfiguration().getInfrastructureName()); OIDCUmaUtil.provideConfiguredPortalClientUMATokenInThreadLocal("/" + PortalContext.getConfiguration().getInfrastructureName());
logger.info("\nCreateUser.workspaceExists() new authorizationService PortalClient UMA-Token In ThreadLocal done\n"); logger.info("\nCreateUser.workspaceExists() new authorizationService PortalClient UMA-Token In ThreadLocal done\n");
//here we actually make the authorised call to check if the workspace exists through shub //here we actually make the authorised call to check if the workspace exists through shub
UserManagerClient client = AbstractPlugin.users().build(); StorageHubClient shc = new StorageHubClient();
toReturn = client.getUsers().contains(usernameToCheck); toReturn = shc.userExists(usernameToCheck);
logger.info("\nshub UserManagerClient#getUsers().contains(" + usernameToCheck + ") returns "+toReturn); logger.info("\nshub userExists(" + usernameToCheck + ") returns "+toReturn);
UmaJWTProvider.instance.set(previousUMAToken); UmaJWTProvider.instance.set(previousUMAToken);
SecurityTokenProvider.instance.set(previousToken); SecurityTokenProvider.instance.set(previousToken);
return toReturn; return toReturn;