Passed to the new KC-client [#27398]

This commit is contained in:
Francesco Mangiacrapa 2024-05-03 15:43:10 +02:00
parent 7d3e9544f5
commit ee4524139e
4 changed files with 25 additions and 7 deletions

View File

@ -677,9 +677,6 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="geoportal-data-mapper-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-mapper/geoportal-data-mapper">
<dependency-type>uses</dependency-type>
</dependent-module>
<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>
</dependent-module>

View File

@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Provided the "Export as PDF" facility [#26026]
- Integrated the GeoportalExporter as service [#27321]
- Passed to the new KC-client [#27398]
## [v3.6.0]

View File

@ -57,6 +57,17 @@ public class GeoportalExporterActionServlet extends HttpServlet {
* @throws ServletException the servlet exception
*/
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
serveRequest(req, resp);
}
/**
* Serve request.
*
* @param req the req
* @param resp the resp
* @throws IOException Signals that an I/O exception has occurred.
*/
public void serveRequest(HttpServletRequest req, HttpServletResponse resp) throws IOException {
// setSecretManager();
String projectID = req.getParameter(GeoportalDataViewerConstants.PROIECT_ID_PARAMETER);
String ucdID = req.getParameter(GeoportalDataViewerConstants.UCD_ID_PARAMETER);
@ -73,7 +84,7 @@ public class GeoportalExporterActionServlet extends HttpServlet {
logger.info("The scope is {}", scope);
try {
//Setting header required to {@PortalContext}
// Setting header required to {@PortalContext}
MutableHttpServletRequest mutableRequest = new MutableHttpServletRequest(req);
mutableRequest.putHeader(PortalContext.VRE_ID_ATTR_NAME, contextID);
mutableRequest.putHeader(PortalContext.USER_ID_ATTR_NAME, userID);
@ -86,7 +97,7 @@ public class GeoportalExporterActionServlet extends HttpServlet {
GeoportalExporterAPI geoportalExporterAPI = new GeoportalExporterAPI();
URL urlRequest = geoportalExporterAPI.exportProject("pdf", ucdID, projectID, false);
String urlToRedirect = urlRequest.toString();
logger.info("Performing request to {} with identity {}", urlToRedirect, identity.getDescription());
logger.info("Performing request to {} with identity description {}", urlToRedirect, identity.getDescription());
logger.info("Token is {}", theToken.substring(0, 20) + "_MASKED_TOKEN");
InputStream is = performHttpRequestToSGService(urlToRedirect, theIdentity, theToken);
@ -99,9 +110,17 @@ public class GeoportalExporterActionServlet extends HttpServlet {
sendError(resp, "Error occurred when exporting the Project. Error is: " + e.getMessage());
return;
}
}
/**
* Perform http request to SG service.
*
* @param urlToService the url to service
* @param identity the identity
* @param token the token
* @return the input stream
* @throws IOException Signals that an I/O exception has occurred.
*/
public static InputStream performHttpRequestToSGService(String urlToService, String identity, String token)
throws IOException {
logger.debug("performHttpRequestToSGService called");

View File

@ -46,8 +46,9 @@ public class IAMClientIdentity implements GcubeIdentity {
try {
LOG.info("Querying KeycloakClientFactory to get UMA token..");
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(clientId, clientSecret, currentScope,
TokenResponse tr = KeycloakClientFactory.newInstance().queryUMAToken(currentScope, clientId, clientSecret, currentScope,
null);
umaAcessToken = tr.getAccessToken();
if (umaAcessToken != null && !umaAcessToken.isEmpty()) {
LOG.info("UMA Access Token read correctly");