|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|