diff --git a/.classpath b/.classpath index 66d7749..d8ef8c7 100644 --- a/.classpath +++ b/.classpath @@ -1,12 +1,12 @@ - + - + @@ -35,5 +35,5 @@ - + diff --git a/.settings/com.gwtplugins.gdt.eclipse.core.prefs b/.settings/com.gwtplugins.gdt.eclipse.core.prefs index 0a283a1..988b8c4 100644 --- a/.settings/com.gwtplugins.gdt.eclipse.core.prefs +++ b/.settings/com.gwtplugins.gdt.eclipse.core.prefs @@ -1,4 +1,4 @@ eclipse.preferences.version=1 -lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.0.1 +lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.0.1-SNAPSHOT warSrcDir=src/main/webapp warSrcDirIsOutput=false diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index a0b0c98..78bef0d 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -38,7 +38,7 @@ - + diff --git a/CHANGELOG.md b/CHANGELOG.md index dde369e..33dfffa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v3.0.1-SNAPSHOT] - 2022-12-21 +## [v3.1.0-SNAPSHOT] - 2023-01-11 #### Enhancement - [#24300] Improved the GUI of the search functionality when multiple collections are available @@ -12,7 +12,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm #### Fixes - Reduced the BBOX when resolving a project by share link -- GNA Project binding with automatically adding of the layers to Map +- GNA Project binding with automatically adding of the layers to Map +- [#24390] Read the access policy from the fileset json section ## [v3.0.0] - 2022-11-28 diff --git a/pom.xml b/pom.xml index 56368a5..b5212d6 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-viewer-app war - 3.0.1-SNAPSHOT + 3.1.0-SNAPSHOT GeoPortal Data Viewer App The GeoPortal Data Viewer App is an application to access, discovery and navigate the Geoportal projects/documents by a Web-Map Interface diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java index dd5cef3..e92b4d7 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/Geoportal_JSON_Mapper.java @@ -829,15 +829,43 @@ public class Geoportal_JSON_Mapper { private static boolean checkAccessPolicy(String sectionDocumentJSON, String myLogin) { LOG.info("checkAccessPolicy called"); // CHECKING THE POLICY - String accessPolicyPath = JSON_$_POINTER + "._access._policy"; + //see ticket #24390 + //First reading the access policy from the fileset + String accessPolicyPath = JSON_$_POINTER + ".fileset._access._policy"; boolean isAccessible = true; try { com.jayway.jsonpath.Configuration configuration = com.jayway.jsonpath.Configuration.builder() .jsonProvider(new JsonOrgJsonProvider()).build(); LOG.debug("Reading access policy at {} into section document {}", accessPolicyPath, sectionDocumentJSON); - JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath); - String _policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString(); + String _policy = null; + try { + JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath); + _policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString(); + + if(_policy==null) + throw new Exception("Policy is null"); + + }catch (Exception e) { + LOG.debug("Access policy not found in: "+accessPolicyPath); + } + + //If policy does not exist into fileset, reading from the parent section + if(_policy==null) { + accessPolicyPath = JSON_$_POINTER + "._access._policy"; + LOG.debug("Reading access policy at {} into section document {}", accessPolicyPath, sectionDocumentJSON); + try { + JsonPath theSectionPolycJsonPath = JsonPath.compile(accessPolicyPath); + _policy = theSectionPolycJsonPath.read(sectionDocumentJSON, configuration).toString(); + + if(_policy==null) + throw new Exception("Policy is null"); + + }catch (Exception e) { + LOG.debug("Access policy not found in: "+accessPolicyPath); + } + } + LOG.debug("The section {} has policy {}", accessPolicyPath, _policy); isAccessible = GeportalCheckAccessPolicy.isAccessible(_policy, myLogin); } catch (Exception e) { diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java index 795659e..5cb8986 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/server/util/SessionUtil.java @@ -134,10 +134,12 @@ public class SessionUtil { GCubeUser user = pContext.getCurrentUser(request); String token = PortalContext.getConfiguration().getCurrentUserToken(scope, user.getUsername()); - if (token != null && setInThread) - SecurityTokenProvider.instance.set(token); + if (token != null) { + LOG.debug("Returning token " + token.substring(1, 10) + "_MASKED_TOKEN_"); + if(setInThread) + SecurityTokenProvider.instance.set(token); + } - LOG.debug("Returning token " + token.substring(1, 10) + "_MASKED_TOKEN_"); return token; }