Managed USERNAME parameter to perform the request to exporter service on

behalf of the user.
This commit is contained in:
Francesco Mangiacrapa 2024-05-07 12:45:29 +02:00
parent 3aa7f6462f
commit 3e568b58b4
4 changed files with 37 additions and 23 deletions

View File

@ -109,6 +109,7 @@
@ -241,6 +242,7 @@
@ -373,6 +375,7 @@
@ -505,6 +508,7 @@
@ -637,6 +641,7 @@
@ -676,6 +681,7 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="geoportal-data-common-2.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
@ -683,9 +689,7 @@
<dependent-module archiveName="geoportal-client-1.2.2-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-client/geoportal-client">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="uri-resolver-manager-1.8.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/uri-resolver-manager/uri-resolver-manager">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -928,6 +932,7 @@
@ -1060,6 +1065,7 @@
@ -1192,6 +1198,7 @@

View File

@ -21,6 +21,7 @@ public class GeoportalDataViewerConstants {
public static final String PROIECT_ID_PARAMETER = "projectID";
public static final String CONTEXT_ID_PARAMETER = "c_id";
public static final String USER_ID_PARAMETER = "u_id";
public static final String USERNAME_PARAMETER = "usn";
public static final String GEOPORTAL_EXPORT_ACTION_SERVLET = GWT.getModuleBaseURL()
+ "geoportalexporterservice";

View File

@ -256,6 +256,10 @@ public class ProjectViewer extends Composite {
panel.add(new Hidden(GeoportalDataViewerConstants.CONTEXT_ID_PARAMETER, currentContextId));
panel.add(new Hidden(GeoportalDataViewerConstants.USER_ID_PARAMETER, currentUserId));
if(myLogin!=null) {
panel.add(new Hidden(GeoportalDataViewerConstants.USERNAME_PARAMETER, myLogin));
}
final Modal contactinServiceModal = new Modal(true, true);
contactinServiceModal.setCloseVisible(false);
contactinServiceModal.setTitle("Export");
@ -341,14 +345,6 @@ public class ProjectViewer extends Composite {
public void onClick(ClickEvent event) {
boolean visible = toc_list_container.isVisible();
setTocContentVisible(!visible);
// if (visible) {
// toc_list_container.setVisible(false);
// reduceToc.setIcon(IconType.PLUS_SIGN_ALT);
// } else {
// toc_list_container.setVisible(true);
// reduceToc.setIcon(IconType.MINUS_SIGN_ALT);
// }
}
});

View File

@ -82,9 +82,10 @@ public class GeoportalExporterActionServlet extends HttpServlet {
String ucdID = req.getParameter(GeoportalDataViewerConstants.UCD_ID_PARAMETER);
String contextID = req.getParameter(GeoportalDataViewerConstants.CONTEXT_ID_PARAMETER);
String userID = req.getParameter(GeoportalDataViewerConstants.USER_ID_PARAMETER);
String username = req.getParameter(GeoportalDataViewerConstants.USERNAME_PARAMETER);
// logger.info("serveRequest called with [projectID: " + projectID + ", ucdID: " + ucdID + ", contextID: " + contextID+"]");
logger.info("serveRequest called with [projectID: " + projectID + ", ucdID: " + ucdID + ", contextID: "
+ contextID + ", userID: " + userID + "]");
+ contextID + ", userID: " + userID + ", username: " + username + "]");
if (contextID == null || contextID.isEmpty())
sendError(resp, "Bad Request. No context found!");
@ -97,10 +98,19 @@ public class GeoportalExporterActionServlet extends HttpServlet {
// Setting header required to {@PortalContext}
MutableHttpServletRequest mutableRequest = new MutableHttpServletRequest(req);
mutableRequest.putHeader(PortalContext.VRE_ID_ATTR_NAME, contextID);
// DEV MODE
if (!SessionUtil.isIntoPortal()) {
logger.info("DEBUG MODE, putting header "+PortalContext.USER_ID_ATTR_NAME);
logger.info("DEBUG MODE, putting header " + PortalContext.USER_ID_ATTR_NAME);
mutableRequest.putHeader(PortalContext.USER_ID_ATTR_NAME, userID);
}
// IF USERNAME exists, add the userID to request. So performing the request to
// exporter service on behalf of the user.
if (username != null) {
logger.info("Username found, putting header " + PortalContext.USER_ID_ATTR_NAME);
mutableRequest.putHeader(PortalContext.USER_ID_ATTR_NAME, userID);
}
ScopeProvider.instance.set(scope);
GeoportalServiceIdentityProxy identity = new GeoportalServiceIdentityProxy(mutableRequest);
String theToken = identity.getToken();