Loading src/main/java/it/inaf/oats/vospace/CreateNodeController.java +5 −39 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package it.inaf.oats.vospace; import it.inaf.ia2.aa.data.User; import it.inaf.oats.vospace.datamodel.NodeProperties; import it.inaf.oats.vospace.datamodel.NodeUtils; import net.ivoa.xml.vospace.v2.Node; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestBody; Loading Loading @@ -60,45 +61,10 @@ public class CreateNodeController extends BaseNodeController { } } // First check if parent node creator is == userid List<String> nodeOwner = NodeProperties.getNodePropertyByURI( parentNode, NodeProperties.CREATOR_URI); if (nodeOwner == null || nodeOwner.isEmpty() || !nodeOwner.get(0).equals(principal.getName())) { // Node owner check has failed: let's check if user can write // due to group privileges List<String> userGroups = principal.getGroups(); // If the user doesn't belong to any groups throw exception if (userGroups == null || userGroups.isEmpty()) { throw new PermissionDeniedException(path); } List<String> groupWritePropValues = NodeProperties.getNodePropertyByURI(parentNode, "ivo://ivoa.net/vospace/core#groupwrite"); // If groupwrite property is absent in Parent Node throw exception if (groupWritePropValues == null || groupWritePropValues.isEmpty()) { if(!NodeUtils.checkIfWritable(parentNode, principal.getName(), principal.getGroups())) { throw new PermissionDeniedException(path); } List<String> nodeGroups = NodeProperties.parsePropertyStringToList(groupWritePropValues.get(0)); if (nodeGroups.isEmpty() || !nodeGroups.stream() .anyMatch((i) -> userGroups.contains(i))) { throw new PermissionDeniedException(path); } } nodeDao.createNode(node); return node; Loading src/main/java/it/inaf/oats/vospace/UriService.java +2 −11 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package it.inaf.oats.vospace; import it.inaf.ia2.aa.ServletRapClient; import it.inaf.ia2.aa.data.User; import it.inaf.ia2.rap.client.call.TokenExchangeRequest; import it.inaf.oats.vospace.datamodel.NodeProperties; import it.inaf.oats.vospace.persistence.NodeDAO; import java.util.ArrayList; import java.util.List; Loading Loading @@ -73,7 +74,7 @@ public class UriService { // TODO add token for authenticated access String endpoint = fileServiceUrl + relativePath + "?jobId=" + job.getJobId(); if (!"true".equals(getProperty(node, "publicread"))) { if (!"true".equals(NodeProperties.getProperty(node, "publicread"))) { endpoint += "&token=" + getEndpointToken(fileServiceUrl + relativePath); } Loading @@ -97,16 +98,6 @@ public class UriService { return rapClient.exchangeToken(exchangeRequest, servletRequest); } private String getProperty(Node node, String propertyName) { for (Property property : node.getProperties()) { if (property.getUri().equals("ivo://ivoa.net/vospace/core#".concat(propertyName))) { return property.getValue(); } } return null; } private Transfer getTransfer(JobSummary job) { // TODO add checks on data type return (Transfer) job.getJobInfo().getAny().get(0); Loading Loading
src/main/java/it/inaf/oats/vospace/CreateNodeController.java +5 −39 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package it.inaf.oats.vospace; import it.inaf.ia2.aa.data.User; import it.inaf.oats.vospace.datamodel.NodeProperties; import it.inaf.oats.vospace.datamodel.NodeUtils; import net.ivoa.xml.vospace.v2.Node; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.RequestBody; Loading Loading @@ -60,45 +61,10 @@ public class CreateNodeController extends BaseNodeController { } } // First check if parent node creator is == userid List<String> nodeOwner = NodeProperties.getNodePropertyByURI( parentNode, NodeProperties.CREATOR_URI); if (nodeOwner == null || nodeOwner.isEmpty() || !nodeOwner.get(0).equals(principal.getName())) { // Node owner check has failed: let's check if user can write // due to group privileges List<String> userGroups = principal.getGroups(); // If the user doesn't belong to any groups throw exception if (userGroups == null || userGroups.isEmpty()) { throw new PermissionDeniedException(path); } List<String> groupWritePropValues = NodeProperties.getNodePropertyByURI(parentNode, "ivo://ivoa.net/vospace/core#groupwrite"); // If groupwrite property is absent in Parent Node throw exception if (groupWritePropValues == null || groupWritePropValues.isEmpty()) { if(!NodeUtils.checkIfWritable(parentNode, principal.getName(), principal.getGroups())) { throw new PermissionDeniedException(path); } List<String> nodeGroups = NodeProperties.parsePropertyStringToList(groupWritePropValues.get(0)); if (nodeGroups.isEmpty() || !nodeGroups.stream() .anyMatch((i) -> userGroups.contains(i))) { throw new PermissionDeniedException(path); } } nodeDao.createNode(node); return node; Loading
src/main/java/it/inaf/oats/vospace/UriService.java +2 −11 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package it.inaf.oats.vospace; import it.inaf.ia2.aa.ServletRapClient; import it.inaf.ia2.aa.data.User; import it.inaf.ia2.rap.client.call.TokenExchangeRequest; import it.inaf.oats.vospace.datamodel.NodeProperties; import it.inaf.oats.vospace.persistence.NodeDAO; import java.util.ArrayList; import java.util.List; Loading Loading @@ -73,7 +74,7 @@ public class UriService { // TODO add token for authenticated access String endpoint = fileServiceUrl + relativePath + "?jobId=" + job.getJobId(); if (!"true".equals(getProperty(node, "publicread"))) { if (!"true".equals(NodeProperties.getProperty(node, "publicread"))) { endpoint += "&token=" + getEndpointToken(fileServiceUrl + relativePath); } Loading @@ -97,16 +98,6 @@ public class UriService { return rapClient.exchangeToken(exchangeRequest, servletRequest); } private String getProperty(Node node, String propertyName) { for (Property property : node.getProperties()) { if (property.getUri().equals("ivo://ivoa.net/vospace/core#".concat(propertyName))) { return property.getValue(); } } return null; } private Transfer getTransfer(JobSummary job) { // TODO add checks on data type return (Transfer) job.getJobInfo().getAny().get(0); Loading