Fixes Bug #17462, rmp-common-library: check the source scope when an add or remove operation is performed

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/resource-management@181782 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2019-09-19 15:43:21 +00:00
parent a5b221edb5
commit 7e1fde30be
8 changed files with 48 additions and 25 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/resource-management-6.6.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/resource-management-6.7.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/resource-management-6.6.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/resource-management-6.7.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -20,11 +20,13 @@
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
@ -39,5 +41,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/resource-management-6.6.1-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/resource-management-6.7.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -45,6 +45,16 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.gwtplugins.gdt.eclipse.core.webAppProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.gwtplugins.gwt.eclipse.core.gwtProjectValidator</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
@ -56,5 +66,6 @@
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
<nature>com.liferay.ide.core.liferayNature</nature>
<nature>com.gwtplugins.gwt.eclipse.core.gwtNature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,4 @@
eclipse.preferences.version=1
lastWarOutDir=/Users/massi/Documents/workspace/resource-management/target/resource-management-6.7.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -5,4 +5,5 @@ org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -1,12 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="resource-management-portlet">
<wb-module deploy-name="resource-management">
<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="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="rmp-common-library-2.8.1-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/rmp-common-library/rmp-common-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="resource-management"/>
</wb-module>

View File

@ -6,4 +6,5 @@
<installed facet="liferay.portlet" version="6.0"/>
<installed facet="jst.jaxrs" version="2.0"/>
<installed facet="java" version="1.7"/>
<installed facet="com.gwtplugins.gwt.facet" version="1.0"/>
</faceted-project>

View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>resource-management</artifactId>
<version>6.6.1-SNAPSHOT</version>
<version>6.7.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>gCube Resource Management Portlet</name>
<description>
@ -103,7 +103,7 @@
<dependency>
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>rmp-common-library</artifactId>
<version>[2.7.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<version>[2.8.3-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency>
<!-- FWS DEPS -->
<dependency>
@ -124,7 +124,7 @@
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<scope>compile</scope>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.resourcemanagement</groupId>

View File

@ -21,16 +21,12 @@ import static org.gcube.resources.discovery.icclient.ICFactory.client;
import java.io.File;
import java.io.StringReader;
import java.security.InvalidParameterException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
import javax.servlet.http.HttpSession;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@ -38,9 +34,11 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.portlets.admin.resourcemanagement.client.remote.ServiceProxy;
import org.gcube.portlets.admin.resourcemanagement.server.gcube.services.StatusHandler;
import org.gcube.portlets.admin.resourcemanagement.server.gcube.services.configuration.ConfigurationLoader;
import org.gcube.portlets.admin.resourcemanagement.shared.utils.BCrypt;
import org.gcube.resourcemanagement.support.client.utils.CurrentStatus;
import org.gcube.resourcemanagement.support.client.views.ResourceTypeDecorator;
import org.gcube.resourcemanagement.support.server.gcube.CacheManager;
@ -68,9 +66,7 @@ import org.gcube.vremanagement.resourcemanager.client.RMReportingLibrary;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import org.gcube.portlets.admin.resourcemanagement.shared.utils.BCrypt;
/**
* @author Daniele Strollo
@ -168,10 +164,16 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
checker.validate(resType != null && resType.trim().length() > 0, new Exception("Invalid parameter type"));
checker.validate(resourceIDs != null && resourceIDs.size() > 0, new Exception("Invalid parameter type"));
checker.validate(scope != null && scope.trim().length() > 0, new Exception("Invalid parameter type"));
AllowedResourceTypes type = AllowedResourceTypes.valueOf(resType);
ScopeBean targetScope = new ScopeBean(scope);
ScopeBean sourceScope = new ScopeBean(status.getCurrentScope());
//new check
if (sourceScope.type() == Type.INFRASTRUCTURE && targetScope.type() == Type.VRE ) {
throw new Exception("Because adding a VRE Context from the Root VO is not allowed.");
}
String reportID = ManagementUtils.addToExistingScope(type,
resourceIDs.toArray(new String[]{}),
@ -211,13 +213,18 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
AllowedResourceTypes type = AllowedResourceTypes.valueOf(resType);
ScopeBean targetScope = new ScopeBean(scope);
ScopeBean sourceScope = new ScopeBean(status.getCurrentScope());
//new check
if (sourceScope.type() == Type.INFRASTRUCTURE && targetScope.type() == Type.VRE ) {
throw new Exception("Because removing a VRE Context from the Root VO is not allowed.");
}
String reportID = ManagementUtils.removeFromExistingScope(type,
resourceIDs.toArray(new String[]{}),
sourceScope,
targetScope);
RMReportingLibrary manager =
ResourceFactory.createResourceManager(type).getReportResourceManager(targetScope.toString());
@ -265,14 +272,14 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
Map<String, ScopeBean> scopes = ScopeManager.getAvailableScopes();
for (ScopeBean scope : scopes.values())
retval.add(scope.toString());
return retval;
} catch (Exception e) {
retval.add("/gcube");
retval.add("/gcube/devsec");
e.printStackTrace();
}
return retval;
}
@ -354,12 +361,12 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
if (results != null && results.size() > 0) {
ResourceDescriptor retval = new ResourceDescriptor();
List<String> currValue = null;
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node node = docBuilder.parse(new InputSource(new StringReader(results.get(0)))).getDocumentElement();
XPathHelper helper = new XPathHelper(node);
currValue = helper.evaluate("/Resource/ID/text()");
if (currValue != null && currValue.size() > 0) {
retval.setID(currValue.get(0));
@ -529,6 +536,6 @@ public class ServiceProxyImpl extends RemoteServiceServlet implements ServicePro
ServerConsole.info(LOG_PREFIX, "FAILED ATTEMPT SUPER USER MODE FROM IP: " + ipAddressCaller);
return matched;
}
}