diff --git a/.classpath b/.classpath
index 72a146d..ffddde4 100644
--- a/.classpath
+++ b/.classpath
@@ -11,6 +11,6 @@
-
+
diff --git a/README b/README
index b754b8f..e1264c7 100644
--- a/README
+++ b/README
@@ -13,7 +13,7 @@ Authors
Version and Release Date
------------------------
-v. 1.0.3, 30/08/2010
+v. 1.0.9, 01/08/2011
Description
-----------
diff --git a/build.xml b/build.xml
index 0d78627..0011e15 100644
--- a/build.xml
+++ b/build.xml
@@ -59,7 +59,8 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
-
+
+
@@ -73,6 +74,7 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
+
@@ -101,6 +103,9 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
+
+
+
@@ -144,6 +149,9 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
+
+
+
@@ -475,6 +483,43 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/changelog.xml b/changelog.xml
index e501e3f..6d9dd4a 100644
--- a/changelog.xml
+++ b/changelog.xml
@@ -1,6 +1,29 @@
+
+ Removing an old security manager from the JNDI
+ Adopting the new security in the test-suite
+
+
+ Changing the gHNManager endpoint's lookup
+ Additional fault tolerance when looking for RI's source service
+
+
+ Fixing a misbehavior when a service has missing dependencies, all the following attempts of the same deployment were always failing
+
+
+ Fixing a misbehavior when a service has missing dependencies
+
+
+ Rollback of deployment operation
+ Fixings on gHN lookups
+ RI with no source service are no longer blocking
+
+
+ Instance state synchronized asynchronously
+ Fixing REMOVEREQUESTED and ADDREQUESTED issues in the state transitions
+
- Fixing undeployment of the same RI from different scopes
+ Fixing undeployment of the same RI from different scopes
Integration of the Serialization Library of the Broker Service
diff --git a/etc/deploy-jndi-config.xml b/etc/deploy-jndi-config.xml
index e6a335b..7263b18 100644
--- a/etc/deploy-jndi-config.xml
+++ b/etc/deploy-jndi-config.xml
@@ -7,12 +7,6 @@
value="@config.dir@"
type="java.lang.String"
override="false" />
-
-
ResourceManager creates and manages Scopes within a gCube infrastructure
ResourceManager-service
- 1.0.5
+ 1.0.9
@@ -42,7 +42,7 @@
1.00.00
ResourceManager-stubs
- 1.0.5
+ 1.0.9
false
@@ -79,7 +79,7 @@
Stubs for ResourceManager: provide facilities to interact with a ResourceManager instance
ResourceManager-stubs
- 1.0.5
+ 1.0.9
@@ -91,7 +91,7 @@
Test-suite for ResourceManager: provide sample usages of interaction with a ResourceManager instance
ResourceManager-test-suite
- 1.0.5
+ 1.0.9
application
diff --git a/src/org/gcube/vremanagement/resourcemanager/impl/deployment/VirtualNode.java b/src/org/gcube/vremanagement/resourcemanager/impl/deployment/VirtualNode.java
index 00329e4..5cf1cc3 100644
--- a/src/org/gcube/vremanagement/resourcemanager/impl/deployment/VirtualNode.java
+++ b/src/org/gcube/vremanagement/resourcemanager/impl/deployment/VirtualNode.java
@@ -1,14 +1,16 @@
package org.gcube.vremanagement.resourcemanager.impl.deployment;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
-import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGHNQuery;
+import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
+import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.common.vremanagement.deployer.stubs.common.PackageInfo;
@@ -20,7 +22,7 @@ import org.gcube.vremanagement.resourcemanager.impl.contexts.ServiceContext;
import org.gcube.vremanagement.resourcemanager.impl.contexts.StatefulPortTypeContext;
/**
- * Models a node and the related deployed packages
+ * A target node for deployment and undeployment operations
*
* @author Manuele Simi (ISTI-CNR)
*
@@ -34,9 +36,7 @@ public class VirtualNode {
private String callbackID;
private String ghnID = "";
-
- private String name = "";
-
+
private GCUBEScope scope = null;
private boolean isWorking = false;
@@ -47,22 +47,22 @@ public class VirtualNode {
private long lastActivity;
- private static final String DEPLOYER_PT_NAME = "/wsrf/services/gcube/common/vremanagement/Deployer";
-
+ //here only for backward compatibility (deserialization will fail)
+ private String name = "";
+
//if we do not receive a deployment session from the node after one hour, we assume that the node is not working anymore
private static final long MAX_ACTIVITY = 3600 * 1000; //1h in milliseconds
- protected VirtualNode(String ID, GCUBEScope scope, String ... name) throws NoGHNFoundException {
+ protected VirtualNode(String ID, GCUBEScope scope) throws NoGHNFoundException {
this.ghnID = ID;
this.scope = scope;
- this.name = (name != null && name.length > 0)? name[0] : this.detectName();
}
public void setCallbackID(String id) {
this.callbackID = id;
}
- private String detectName() throws NoGHNFoundException {
+ public String detectName() throws NoGHNFoundException {
logger.debug("Detecting name for " + this.ghnID);
if (GHNContext.getContext().getGHNID().compareToIgnoreCase(this.ghnID) == 0)
throw new NoGHNFoundException ("cannot deploy on the same GHN (ghnID=" + this.ghnID + ") where the Resource Manager is deployed");
@@ -151,15 +151,13 @@ public class VirtualNode {
return;
}
- EndpointReferenceType callbackEPR = new EndpointReferenceType();
- callbackEPR.setAddress(new Address("http://"+ GHNContext.getContext().getHostnameAndPort() +"/wsrf/services/" + StatefulPortTypeContext.getContext().getJNDIName()));
+ EndpointReferenceType callbackEPR = ServiceContext.getContext().getInstance().getAccessPoint().getEndpoint(StatefulPortTypeContext.getContext().getJNDIName());
DeployParameters param = new DeployParameters();
param.set_package(this.packagesToAdd.toArray(new PackageInfo[0]));
param.setTargetScope(new String[] {scope.toString()});
param.setCallbackID(callbackID);
param.setEndpointReference(callbackEPR);
- EndpointReferenceType nodeEPR = new EndpointReferenceType();
- nodeEPR.setAddress(new Address("http://" + this.name + DEPLOYER_PT_NAME));
+ EndpointReferenceType nodeEPR = this.loadDeployer(this.ghnID);
logger.trace("Deploying on " + nodeEPR.toString());
DeployerPortType pt = GCUBERemotePortTypeContext.getProxy(new DeployerServiceAddressingLocator().getDeployerPortTypePort(nodeEPR),
scope, ServiceContext.getContext());
@@ -184,15 +182,13 @@ public class VirtualNode {
return;
}
- EndpointReferenceType callbackEPR = new EndpointReferenceType();
- callbackEPR.setAddress(new Address("http://"+ GHNContext.getContext().getHostnameAndPort() +"/wsrf/services/" + StatefulPortTypeContext.getContext().getJNDIName()));
+ EndpointReferenceType callbackEPR = ServiceContext.getContext().getInstance().getAccessPoint().getEndpoint(StatefulPortTypeContext.getContext().getJNDIName());
UndeployParameters params = new UndeployParameters();
params.set_package(this.packagesToRemove.toArray(new PackageInfo[0]));
params.setTargetScope(new String[] {scope.toString()});
params.setCallbackID(callbackID);
params.setEndpointReference(callbackEPR);
- EndpointReferenceType nodeEPR = new EndpointReferenceType();
- nodeEPR.setAddress(new Address("http://" + this.name + DEPLOYER_PT_NAME));
+ EndpointReferenceType nodeEPR = this.loadDeployer(this.ghnID);
logger.trace("Undeploying from " + nodeEPR.toString() + " in scope " + scope);
DeployerPortType pt = GCUBERemotePortTypeContext.getProxy(new DeployerServiceAddressingLocator().getDeployerPortTypePort(nodeEPR),
scope, ServiceContext.getContext());
@@ -224,16 +220,13 @@ public class VirtualNode {
this.packagesToRemove.addAll(packages);
}
- public String getName() {
- return this.name;
- }
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
- return "VirtualNode [ghnID=" + ghnID + ", name=" + name + ", scope="+ scope + "]";
+ return "VirtualNode [ghnID=" + ghnID + ", scope="+ scope + "]";
}
/* (non-Javadoc)
@@ -291,4 +284,20 @@ public class VirtualNode {
return this.scope;
}
+
+ /**
+ * Looks for the Deployer's endpoint to contact
+ * @param id the identifier of the gHN
+ * @return the endpoint reference of Deployer's portType to contact
+ * @throws Exception if the search fails
+ */
+ private EndpointReferenceType loadDeployer(String id) throws Exception {
+ ISClient client = GHNContext.getImplementation(ISClient.class);
+ GCUBERIQuery riquery = client.getQuery(GCUBERIQuery.class);
+ riquery.addAtomicConditions(new AtomicCondition("//GHN/@UniqueID", id),
+ new AtomicCondition("//ServiceClass", "VREManagement"),
+ new AtomicCondition("//ServiceName", "Deployer"));
+ List results = client.execute(riquery,ServiceContext.getContext().getScope());
+ return results.get(0).getAccessPoint().getEndpoint("gcube/common/vremanagement/Deployer");
+ }
}
diff --git a/src/org/gcube/vremanagement/resourcemanager/impl/deployment/VirtualNodeManager.java b/src/org/gcube/vremanagement/resourcemanager/impl/deployment/VirtualNodeManager.java
index e222d57..f07ca9f 100644
--- a/src/org/gcube/vremanagement/resourcemanager/impl/deployment/VirtualNodeManager.java
+++ b/src/org/gcube/vremanagement/resourcemanager/impl/deployment/VirtualNodeManager.java
@@ -32,14 +32,13 @@ public class VirtualNodeManager {
* Gets or builds the VirtualNode
* @param ID the node identifier
* @param scope the deployment scope
- * @param name the node name (format has to be host:port)
* @return the Virtual Node
* @throws NoGHNFoundException if the node does not exist
*/
- public static VirtualNode getNode(String ID, GCUBEScope scope, String ... name) throws NoGHNFoundException {
+ public static VirtualNode getNode(String ID, GCUBEScope scope) throws NoGHNFoundException {
checkNodes();
if (!nodes.containsKey(ID)) {
- nodes.put(ID,new VirtualNode(ID, scope, name));
+ nodes.put(ID,new VirtualNode(ID, scope));
}
return nodes.get(ID);
}
diff --git a/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedService.java b/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedService.java
index 6e36091..dc4310d 100644
--- a/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedService.java
+++ b/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedDeployedService.java
@@ -353,8 +353,8 @@ public final class ScopedDeployedService extends ScopedResource {
* Gets the ID of the target gHN
* @return the ID of the target gHN
*/
- public String getTargetGHNName() {
- return this.virtualNodes.size() > 0 ? this.virtualNodes.get(0).getName() : "";
+ public String getTargetGHN() {
+ return this.virtualNodes.size() > 0 ? this.virtualNodes.get(0).getID() : "";
}
diff --git a/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedGHN.java b/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedGHN.java
index 411eced..009f2ef 100644
--- a/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedGHN.java
+++ b/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedGHN.java
@@ -40,7 +40,7 @@ public final class ScopedGHN extends ScopedResource {
@Override
protected void addToScope() throws ResourceNotFound, Exception {
- if (this.nodename.compareToIgnoreCase("") == 0)
+ if (this.ghnEpr == null)
this.findResource();
//contact the GHNManager to add the GHN to the given scope
EndpointReferenceType endpoint = new EndpointReferenceType();
@@ -75,14 +75,14 @@ public final class ScopedGHN extends ScopedResource {
List hostingNodes = client.execute(query, ServiceContext.getContext().getScope());
this.nodename = hostingNodes.get(0).getNodeDescription().getName();
this.hostedOn = nodename;
- this.ghnEpr = this.loadGHNmanager(hostingNodes.get(0).getID(), client);
+ this.ghnEpr = this.loadGHNmanager(hostingNodes.get(0).getID(), client, ServiceContext.getContext().getScope());
} catch (Exception e) {
//try in the enclosing scope
try {
List hostingNodes = client.execute(query, ServiceContext.getContext().getScope().getEnclosingScope());
this.nodename = hostingNodes.get(0).getNodeDescription().getName();
this.hostedOn = nodename;
- this.ghnEpr = this.loadGHNmanager(hostingNodes.get(0).getID(), client);
+ this.ghnEpr = this.loadGHNmanager(hostingNodes.get(0).getID(), client,ServiceContext.getContext().getScope().getEnclosingScope());
} catch (Exception ei) {
throw new Exception("unable to find the target GHN (ID=" + this.id + ")", e);
}
@@ -92,7 +92,7 @@ public final class ScopedGHN extends ScopedResource {
@Override
protected void removeFromScope() throws ResourceNotFound, Exception {
- if (this.nodename.compareToIgnoreCase("") == 0)
+ if (this.ghnEpr == null)
this.findResource();
//EndpointReferenceType endpoint = new EndpointReferenceType();
try {
@@ -111,16 +111,17 @@ public final class ScopedGHN extends ScopedResource {
* Looks for the GHN manager's endpoint to contact
* @param id the identifier of the gHN
* @param client the ISClient instance to use
+ * @param scope
* @return the endpoint reference of gHNManager's portType to contact
* @throws Exception if the search fails
*/
- private EndpointReferenceType loadGHNmanager(String id, ISClient client) throws Exception {
+ private EndpointReferenceType loadGHNmanager(String id, ISClient client, GCUBEScope scope) throws Exception {
//looks for the GHN manager's endpoint to contact
GCUBERIQuery riquery = client.getQuery(GCUBERIQuery.class);
riquery.addAtomicConditions(new AtomicCondition("//GHN/@UniqueID", id),
new AtomicCondition("//ServiceClass", "VREManagement"),
new AtomicCondition("//ServiceName", "GHNManager"));
- List results = client.execute(riquery,ServiceContext.getContext().getScope());
+ List results = client.execute(riquery,scope);
return results.get(0).getAccessPoint().getEndpoint("gcube/common/vremanagement/GHNManager");
}
diff --git a/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedResourceFactory.java b/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedResourceFactory.java
index 0de2769..5dbdf7b 100644
--- a/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedResourceFactory.java
+++ b/src/org/gcube/vremanagement/resourcemanager/impl/resources/ScopedResourceFactory.java
@@ -61,17 +61,20 @@ public class ScopedResourceFactory {
*/
public static ScopedDeployedService getRelatedService(
ScopedRunningInstance scopedRunningInstance) throws ServiceNotFoundException {
- try {
for (ScopedResource resource : scopeState.getResourcesByType(ScopedDeployedService.TYPE)) {
- ScopedDeployedService service = (ScopedDeployedService)resource;
- if ((service.getSourceService().getClazz().compareToIgnoreCase(scopedRunningInstance.getSourceServiceClass())==0)
- && (service.getSourceService().getName().compareToIgnoreCase(scopedRunningInstance.getSourceServiceName())==0))
- return service;
+ if (resource == null) continue;
+ try {
+ ScopedDeployedService service = (ScopedDeployedService)resource;
+ if ((service.getSourceService().getClazz().compareToIgnoreCase(scopedRunningInstance.getSourceServiceClass())==0)
+ && (service.getSourceService().getName().compareToIgnoreCase(scopedRunningInstance.getSourceServiceName())==0)) {
+ logger.debug("Source service found for RI " + scopedRunningInstance);
+ return service;
+ }
+ }catch (Exception e ) {
+ logger.warn("An error occurred when looking for the source service for RI "+ scopedRunningInstance + ", error message: " + e.getMessage());
+ }
}
- }catch (Exception e ) {
- logger.error("Unable to find the source service for RI "+ scopedRunningInstance, e);
- throw new ServiceNotFoundException();
- }
+ logger.error("Unable to find a source service for " + scopedRunningInstance);
throw new ServiceNotFoundException();
}
diff --git a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/GetReportTest.java b/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/GetReportTest.java
deleted file mode 100644
index 6428a37..0000000
--- a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/GetReportTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.gcube.vremanagement.resourcemanager.stubs.testsuite;
-
-import java.util.Calendar;
-
-
-import org.apache.axis.message.addressing.Address;
-import org.apache.axis.message.addressing.EndpointReferenceType;
-import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
-import org.gcube.common.core.scope.GCUBEScope;
-import org.gcube.common.core.security.GCUBESecurityManagerImpl;
-import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
-import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
-
-public class GetReportTest {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- EndpointReferenceType endpoint = new EndpointReferenceType();
-
- try {
- endpoint.setAddress(new Address("http://"+ args[0]+":"+ args[1] +"/wsrf/services/gcube/vremanagement/ResourceManager"));
- ResourceManagerPortType pt;
-
- GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
- public boolean isSecurityEnabled() {return false;}};
- pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint),
- GCUBEScope.getScope(args[2]), 90000, managerSec);
- System.out.println(Calendar.getInstance().getTime().toString());
- String report = pt.getReport(args[3]);
- System.out.println(Calendar.getInstance().getTime().toString());
- System.out.println ("REPORT");
- System.out.println ("************");
- System.out.println (report);
- System.out.println ("************");
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
- static void printUsage() {
- System.out.println("GetReportTest ");
- System.exit(1);
- }
-
-
-
-
-}
diff --git a/test-suite/addresource.sh b/test-suite/addresource.sh
index accdc26..f79c418 100755
--- a/test-suite/addresource.sh
+++ b/test-suite/addresource.sh
@@ -1 +1 @@
-java -cp .:./lib/org.gcube.vremanagement.resourcemanager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/stubs/testsuite/AddResourceTest $1 $2 $3
+java -cp .:./lib/org.gcube.vremanagement.resourcemanager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/testsuite/AddResourceTest $1 $2 $3
diff --git a/test-suite/createScope.sh b/test-suite/createScope.sh
index a672730..2548a26 100755
--- a/test-suite/createScope.sh
+++ b/test-suite/createScope.sh
@@ -1 +1 @@
-java -cp .:./lib/org.gcube.vremanagement.resourcemanager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/stubs/testsuite/CreateScopeTest $1 $2 $3
+java -cp .:./lib/org.gcube.vremanagement.resourcemanager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/testsuite/CreateScopeTest $1 $2 $3
diff --git a/test-suite/disposeScope.sh b/test-suite/disposeScope.sh
index cbdd624..2241c43 100644
--- a/test-suite/disposeScope.sh
+++ b/test-suite/disposeScope.sh
@@ -1 +1 @@
-java -cp .:./lib/org.gcube.vremanagement.resourcemanager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/stubs/testsuite/DisposeScopeTest $1 $2 $3
+java -cp .:./lib/org.gcube.vremanagement.resourcemanager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/testsuite/DisposeScopeTest $1 $2 $3
diff --git a/test-suite/getreport.sh b/test-suite/getreport.sh
index 793466d..52236b3 100755
--- a/test-suite/getreport.sh
+++ b/test-suite/getreport.sh
@@ -1 +1 @@
-java -cp .:./lib/org.gcube.vremanagement.resourcemanager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/stubs/testsuite/GetReportTest $1 $2 $3 $4
+java -cp .:./lib/org.gcube.vremanagement.resourcemanager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/testsuite/GetReportTest $1 $2 $3 $4
diff --git a/test-suite/removeresource.sh b/test-suite/removeresource.sh
index 59af684..0b6c903 100755
--- a/test-suite/removeresource.sh
+++ b/test-suite/removeresource.sh
@@ -1 +1 @@
-java -cp .:./lib/org.gcube.vremanagement.resourcemanager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/stubs/testsuite/RemoveResourceTest $1 $2 $3
+java -cp .:./lib/org.gcube.vremanagement.resourcemanager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/testsuite/RemoveResourceTest $1 $2 $3
diff --git a/test-suite/setscopeoptions.sh b/test-suite/setscopeoptions.sh
index 5053a98..cf6cd90 100755
--- a/test-suite/setscopeoptions.sh
+++ b/test-suite/setscopeoptions.sh
@@ -1 +1 @@
-java -cp .:./lib/org.gcube.resourcemanagement.manager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/stubs/testsuite/SetScopeOptionsTest $1 $2 $3
+java -cp .:./lib/org.gcube.resourcemanagement.manager.testsuite.jar:$CLASSPATH org/gcube/vremanagement/resourcemanager/testsuite/SetScopeOptionsTest $1 $2 $3
diff --git a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/AddResourceTest.java b/test/org/gcube/vremanagement/resourcemanager/testsuite/AddResourceTest.java
similarity index 72%
rename from src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/AddResourceTest.java
rename to test/org/gcube/vremanagement/resourcemanager/testsuite/AddResourceTest.java
index a9916f5..2d13e80 100644
--- a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/AddResourceTest.java
+++ b/test/org/gcube/vremanagement/resourcemanager/testsuite/AddResourceTest.java
@@ -1,7 +1,6 @@
-package org.gcube.vremanagement.resourcemanager.stubs.testsuite;
+package org.gcube.vremanagement.resourcemanager.testsuite;
-import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
@@ -9,7 +8,7 @@ import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
-import org.gcube.common.core.security.GCUBESecurityManagerImpl;
+import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.AddResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
@@ -32,11 +31,11 @@ public class AddResourceTest {
*/
public static void main(String[] args) {
- if (args.length < 3)
+ if ((args.length < 2) || (args.length > 3))
AddResourceTest.printUsage();
try {
- resources.load(new FileInputStream(args[2]));
+ resources.load(AddResourceTest.class.getResourceAsStream("/" + args[1]));
} catch (IOException e1) {
e1.printStackTrace();
Runtime.getRuntime().exit(1);
@@ -45,14 +44,18 @@ public class AddResourceTest {
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
- endpoint.setAddress(new Address("http://"+ args[0]+":"+ args[1] +"/wsrf/services/gcube/vremanagement/ResourceManager"));
- ResourceManagerPortType pt;
-
- GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
- public boolean isSecurityEnabled() {return false;}};
- pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint),
- GCUBEScope.getScope(resources.getProperty("callerScope").trim() ),managerSec);
-
+ endpoint.setAddress(new Address(args[0]));
+ ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
+ if (args.length == 3) {
+ GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
+ securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
+ pt = GCUBERemotePortTypeContext.getProxy(pt,
+ GCUBEScope.getScope(resources.getProperty("callerScope").trim()), securityManager);
+
+ } else {
+ pt = GCUBERemotePortTypeContext.getProxy(pt,
+ GCUBEScope.getScope(resources.getProperty("callerScope").trim()));
+ }
AddResourcesParameters add = new AddResourcesParameters();
if (new Integer(resources.getProperty("numOfServicesToAdd")) > 0) {
@@ -99,7 +102,9 @@ public class AddResourceTest {
}
static void printUsage() {
- System.out.println("AddResourceTest ");
+ System.out.println("AddResourceTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
+ System.out.println("or");
+ System.out.println("AddResourceTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
System.exit(1);
}
}
diff --git a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/CreateScopeTest.java b/test/org/gcube/vremanagement/resourcemanager/testsuite/CreateScopeTest.java
similarity index 79%
rename from src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/CreateScopeTest.java
rename to test/org/gcube/vremanagement/resourcemanager/testsuite/CreateScopeTest.java
index 4990cd2..2d10c70 100644
--- a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/CreateScopeTest.java
+++ b/test/org/gcube/vremanagement/resourcemanager/testsuite/CreateScopeTest.java
@@ -1,4 +1,4 @@
-package org.gcube.vremanagement.resourcemanager.stubs.testsuite;
+package org.gcube.vremanagement.resourcemanager.testsuite;
import java.io.IOException;
import java.util.Properties;
@@ -7,7 +7,7 @@ import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
-import org.gcube.common.core.security.GCUBESecurityManagerImpl;
+import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.AddResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.CreateScopeParameters;
@@ -33,11 +33,11 @@ public class CreateScopeTest {
* @param args
*/
public static void main(String[] args) {
- if (args.length < 3)
+ if ((args.length < 2) || (args.length > 3))
CreateScopeTest.printUsage();
try {
- resources.load(CreateScopeTest.class.getResourceAsStream("/" + args[2]));
+ resources.load(CreateScopeTest.class.getResourceAsStream("/" + args[1]));
} catch (IOException e1) {
logger.error("Unable to load the properties file",e1);
Runtime.getRuntime().exit(1);
@@ -46,14 +46,17 @@ public class CreateScopeTest {
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
- endpoint.setAddress(new Address("http://"+ args[0]+":"+ args[1] +"/wsrf/services/gcube/vremanagement/ResourceManager"));
- ResourceManagerPortType pt;
+ endpoint.setAddress(new Address(args[0]));
+ ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
- GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
- public boolean isSecurityEnabled() {return false;}};
- pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint),
- GCUBEScope.getScope(resources.getProperty("callerScope").trim() ),managerSec);
-
+ if (args.length == 3) {
+ GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
+ securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
+ pt = GCUBERemotePortTypeContext.getProxy(pt,
+ GCUBEScope.getScope(resources.getProperty("callerScope").trim()), securityManager);
+ } else {
+ pt = GCUBERemotePortTypeContext.getProxy(pt, GCUBEScope.getScope(resources.getProperty("callerScope").trim()), 90000);
+ }
logger.info("Setting the Scope parameters...");
OptionsParameters options = new OptionsParameters();
ScopeOption[] scopeOptionList = new ScopeOption[optionNames.length];
@@ -117,7 +120,10 @@ public class CreateScopeTest {
}
static void printUsage() {
- System.out.println("CreateScopeTest ");
+ System.out.println("CreateScopeTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
+ System.out.println("or");
+ System.out.println("CreateScopeTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
+
System.exit(1);
}
diff --git a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/DisposeScopeTest.java b/test/org/gcube/vremanagement/resourcemanager/testsuite/DisposeScopeTest.java
similarity index 51%
rename from src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/DisposeScopeTest.java
rename to test/org/gcube/vremanagement/resourcemanager/testsuite/DisposeScopeTest.java
index 22a3f67..e8efa62 100644
--- a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/DisposeScopeTest.java
+++ b/test/org/gcube/vremanagement/resourcemanager/testsuite/DisposeScopeTest.java
@@ -1,10 +1,10 @@
-package org.gcube.vremanagement.resourcemanager.stubs.testsuite;
+package org.gcube.vremanagement.resourcemanager.testsuite;
import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
-import org.gcube.common.core.security.GCUBESecurityManagerImpl;
+import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.DisposeScopeParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
@@ -19,21 +19,26 @@ public class DisposeScopeTest {
* @param args
*/
public static void main(String[] args) {
- if (args.length < 3)
+
+ if ((args.length < 2) || (args.length > 3))
DisposeScopeTest.printUsage();
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
- endpoint.setAddress(new Address("http://"+ args[0]+":"+ args[1] +"/wsrf/services/gcube/vremanagement/ResourceManager"));
- ResourceManagerPortType pt;
+ endpoint.setAddress(new Address(args[0]));
+ ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
- GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
- public boolean isSecurityEnabled() {return false;}};
- pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint),
- GCUBEScope.getScope(args[2].trim() ),managerSec);
+ if (args.length == 3) {
+ GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
+ securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
+ pt = GCUBERemotePortTypeContext.getProxy(pt,
+ GCUBEScope.getScope(args[1].trim()), securityManager);
+ } else {
+ pt = GCUBERemotePortTypeContext.getProxy(pt, GCUBEScope.getScope(args[1].trim()));
+ }
logger.info("Sending the destroy request....");
- String reportID = pt.disposeScope(new DisposeScopeParameters(args[2]));
+ String reportID = pt.disposeScope(new DisposeScopeParameters(args[1]));
logger.info("Returned report ID: " + reportID);
} catch (Exception e) {
logger.fatal("Failed to dispose the VRE",e);
@@ -42,7 +47,10 @@ public class DisposeScopeTest {
}
static void printUsage() {
- System.out.println("DisposeScopeTest ");
+ System.out.println("DisposeScopeTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
+ System.out.println("or");
+ System.out.println("DisposeScopeTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
+
System.exit(1);
}
diff --git a/test/org/gcube/vremanagement/resourcemanager/testsuite/GetReportTest.java b/test/org/gcube/vremanagement/resourcemanager/testsuite/GetReportTest.java
new file mode 100644
index 0000000..68a0a95
--- /dev/null
+++ b/test/org/gcube/vremanagement/resourcemanager/testsuite/GetReportTest.java
@@ -0,0 +1,61 @@
+package org.gcube.vremanagement.resourcemanager.testsuite;
+
+import java.util.Calendar;
+
+
+import org.apache.axis.message.addressing.Address;
+import org.apache.axis.message.addressing.EndpointReferenceType;
+import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
+import org.gcube.common.core.scope.GCUBEScope;
+import org.gcube.common.core.security.GCUBESecurityManager;
+import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
+import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.service.ResourceManagerServiceAddressingLocator;
+
+public class GetReportTest {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+
+ if ((args.length < 3) || (args.length > 4))
+ GetReportTest.printUsage();
+
+ EndpointReferenceType endpoint = new EndpointReferenceType();
+
+ try {
+ endpoint.setAddress(new Address(args[0]));
+ ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
+ if (args.length == 4) {
+ GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[3], true);
+ securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
+ pt = GCUBERemotePortTypeContext.getProxy(pt, GCUBEScope.getScope(args[1]), securityManager);
+ } else {
+ pt = GCUBERemotePortTypeContext.getProxy(pt,
+ GCUBEScope.getScope(args[1]), 90000);
+ }
+ System.out.println(Calendar.getInstance().getTime().toString());
+ String report = pt.getReport(args[2]);
+ System.out.println(Calendar.getInstance().getTime().toString());
+ System.out.println ("REPORT");
+ System.out.println ("************");
+ System.out.println (report);
+ System.out.println ("************");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ static void printUsage() {
+ System.out.println("GetReportTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
+ System.out.println("or");
+ System.out.println("GetReportTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
+
+ System.exit(1);
+ }
+
+
+
+
+}
diff --git a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/RemoveResourceTest.java b/test/org/gcube/vremanagement/resourcemanager/testsuite/RemoveResourceTest.java
similarity index 68%
rename from src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/RemoveResourceTest.java
rename to test/org/gcube/vremanagement/resourcemanager/testsuite/RemoveResourceTest.java
index 93e07b7..6c40986 100644
--- a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/RemoveResourceTest.java
+++ b/test/org/gcube/vremanagement/resourcemanager/testsuite/RemoveResourceTest.java
@@ -1,6 +1,5 @@
-package org.gcube.vremanagement.resourcemanager.stubs.testsuite;
+package org.gcube.vremanagement.resourcemanager.testsuite;
-import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
@@ -8,7 +7,7 @@ import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
-import org.gcube.common.core.security.GCUBESecurityManagerImpl;
+import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.RemoveResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceItem;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceList;
@@ -26,28 +25,30 @@ public class RemoveResourceTest {
*/
public static void main(String[] args) {
- if (args.length < 3)
- AddResourceTest.printUsage();
+ if ((args.length < 2) || (args.length > 3))
+ RemoveResourceTest.printUsage();
try {
- resources.load(new FileInputStream(args[2]));
+ resources.load(RemoveResourceTest.class.getResourceAsStream("/" + args[1]));
} catch (IOException e1) {
e1.printStackTrace();
- Runtime.getRuntime().exit(1);
-
+ Runtime.getRuntime().exit(1);
}
-
EndpointReferenceType endpoint = new EndpointReferenceType();
-
try {
- endpoint.setAddress(new Address("http://"+ args[0]+":"+ args[1] +"/wsrf/services/gcube/vremanagement/ResourceManager"));
- ResourceManagerPortType pt;
-
- GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
- public boolean isSecurityEnabled() {return false;}};
- pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint),
- GCUBEScope.getScope(resources.getProperty("callerScope").trim() ),managerSec);
+ endpoint.setAddress(new Address(args[0]));
+ ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
+ if (args.length == 3) {
+ GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
+ securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
+ pt = GCUBERemotePortTypeContext.getProxy(pt,
+ GCUBEScope.getScope(resources.getProperty("callerScope").trim()), securityManager);
+
+ } else {
+ pt = GCUBERemotePortTypeContext.getProxy(pt,
+ GCUBEScope.getScope(resources.getProperty("callerScope").trim() ));
+ }
RemoveResourcesParameters params = new RemoveResourcesParameters();
if (new Integer(resources.getProperty("numOfResourcesToRemove")) > 0) {
ResourceItem[] resourcelist = new ResourceItem[new Integer(resources.getProperty("numOfResourcesToRemove"))];
@@ -88,7 +89,9 @@ public class RemoveResourceTest {
}
static void printUsage() {
- System.out.println("RemoveResourceTest ");
+ System.out.println("RemoveResourceTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
+ System.out.println("or");
+ System.out.println("RemoveResourceTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
System.exit(1);
}
diff --git a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/SetScopeOptionsTest.java b/test/org/gcube/vremanagement/resourcemanager/testsuite/SetScopeOptionsTest.java
similarity index 60%
rename from src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/SetScopeOptionsTest.java
rename to test/org/gcube/vremanagement/resourcemanager/testsuite/SetScopeOptionsTest.java
index 9a0f9d7..f47d862 100644
--- a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/SetScopeOptionsTest.java
+++ b/test/org/gcube/vremanagement/resourcemanager/testsuite/SetScopeOptionsTest.java
@@ -1,4 +1,4 @@
-package org.gcube.vremanagement.resourcemanager.stubs.testsuite;
+package org.gcube.vremanagement.resourcemanager.testsuite;
import java.io.IOException;
import java.util.Properties;
@@ -7,6 +7,7 @@ import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
+import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.OptionsParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ScopeOption;
@@ -32,11 +33,11 @@ public class SetScopeOptionsTest {
*/
public static void main(String[] args) {
- if (args.length < 3)
+ if ((args.length < 2) || (args.length > 3))
SetScopeOptionsTest.printUsage();
try {
- resources.load(SetScopeOptionsTest.class.getResourceAsStream("/" + args[2]));
+ resources.load(SetScopeOptionsTest.class.getResourceAsStream("/" + args[1]));
} catch (IOException e1) {
e1.printStackTrace();
Runtime.getRuntime().exit(1);
@@ -45,14 +46,17 @@ public class SetScopeOptionsTest {
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
- endpoint.setAddress(new Address("http://"+ args[0]+":"+ args[1] +"/wsrf/services/gcube/vremanagement/ResourceManager"));
- ResourceManagerPortType pt;
-
- GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
- public boolean isSecurityEnabled() {return false;}};
- pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint),
- GCUBEScope.getScope(resources.getProperty("callerScope")),managerSec);
+ endpoint.setAddress(new Address(args[0]));
+ ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
+ if (args.length == 3) {
+ GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
+ securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
+ pt = GCUBERemotePortTypeContext.getProxy(pt,
+ GCUBEScope.getScope(resources.getProperty("callerScope").trim()), securityManager);
+ } else {
+ pt = GCUBERemotePortTypeContext.getProxy(pt, GCUBEScope.getScope(resources.getProperty("callerScope").trim()), 90000);
+ }
OptionsParameters options = new OptionsParameters();
ScopeOption[] scopeOptionList = new ScopeOption[optionNames.length];
for (int i=0; i < optionNames.length; i++)
@@ -68,7 +72,10 @@ public class SetScopeOptionsTest {
}
static void printUsage() {
- System.out.println("SetScopeOptionsTest ");
+ System.out.println("SetScopeOptionsTest http://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
+ System.out.println("or");
+ System.out.println("SetScopeOptionsTest https://host:port/wsrf/services/gcube/vremanagement/ResourceManager ");
+
System.exit(1);
}
diff --git a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/UndeployServiceTest.java b/test/org/gcube/vremanagement/resourcemanager/testsuite/UndeployServiceTest.java
similarity index 73%
rename from src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/UndeployServiceTest.java
rename to test/org/gcube/vremanagement/resourcemanager/testsuite/UndeployServiceTest.java
index 676ea38..0355dd7 100644
--- a/src/org/gcube/vremanagement/resourcemanager/stubs/testsuite/UndeployServiceTest.java
+++ b/test/org/gcube/vremanagement/resourcemanager/testsuite/UndeployServiceTest.java
@@ -1,4 +1,4 @@
-package org.gcube.vremanagement.resourcemanager.stubs.testsuite;
+package org.gcube.vremanagement.resourcemanager.testsuite;
import java.io.IOException;
import java.util.Properties;
@@ -7,7 +7,7 @@ import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.scope.GCUBEScope;
-import org.gcube.common.core.security.GCUBESecurityManagerImpl;
+import org.gcube.common.core.security.GCUBESecurityManager;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.RemoveResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.resourcemanager.ResourceManagerPortType;
@@ -27,11 +27,11 @@ public class UndeployServiceTest {
* @param args
*/
public static void main(String[] args) {
- if (args.length < 3)
+ if ((args.length < 2) || (args.length > 3))
AddResourceTest.printUsage();
try {
- resources.load(RemoveResourceTest.class.getResourceAsStream("/" + args[2]));
+ resources.load(RemoveResourceTest.class.getResourceAsStream("/" + args[1]));
} catch (IOException e1) {
e1.printStackTrace();
Runtime.getRuntime().exit(1);
@@ -41,13 +41,19 @@ public class UndeployServiceTest {
EndpointReferenceType endpoint = new EndpointReferenceType();
try {
- endpoint.setAddress(new Address("http://"+ args[0]+":"+ args[1] +"/wsrf/services/gcube/vremanagement/ResourceManager"));
- ResourceManagerPortType pt;
- GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
- public boolean isSecurityEnabled() {return false;}};
- pt = GCUBERemotePortTypeContext.getProxy(new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint),
- GCUBEScope.getScope(resources.getProperty("callerScope").trim() ),managerSec);
+ endpoint.setAddress(new Address(args[0]));
+ ResourceManagerPortType pt = new ResourceManagerServiceAddressingLocator().getResourceManagerPortTypePort(endpoint);
+
+ if (args.length == 3) {
+ GCUBESecurityManager securityManager = org.gcube.vremanagement.resourcemanager.testsuite.security.Utils.generateAndConfigureDefaultSecurityManager(args[2], true);
+ securityManager.setSecurity(pt, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
+ pt = GCUBERemotePortTypeContext.getProxy(pt,
+ GCUBEScope.getScope(resources.getProperty("callerScope").trim()), securityManager);
+ } else {
+ pt = GCUBERemotePortTypeContext.getProxy(pt, GCUBEScope.getScope(resources.getProperty("callerScope").trim()), 90000);
+ }
+
RemoveResourcesParameters params = new RemoveResourcesParameters();
if (new Integer(resources.getProperty("numOfServicesToRemove")) > 0) {
diff --git a/test/org/gcube/vremanagement/resourcemanager/testsuite/security/Utils.java b/test/org/gcube/vremanagement/resourcemanager/testsuite/security/Utils.java
new file mode 100644
index 0000000..b8dabf8
--- /dev/null
+++ b/test/org/gcube/vremanagement/resourcemanager/testsuite/security/Utils.java
@@ -0,0 +1,41 @@
+package org.gcube.vremanagement.resourcemanager.testsuite.security;
+
+import org.gcube.common.core.security.GCUBEClientSecurityManager;
+import org.gcube.common.core.security.GCUBESecurityManager;
+import org.gcube.common.core.security.GCUBESecurityManagerImpl;
+import org.gcube.common.core.security.context.SecurityContextFactory;
+import org.gcube.common.core.utils.logging.GCUBEClientLog;
+
+public class Utils {
+ public static GCUBESecurityManager generateAndConfigureDefaultSecurityManager (String identity, final boolean isSecurityEnabled)
+ {
+ GCUBEClientLog logger = new GCUBEClientLog(Utils.class);
+
+ GCUBESecurityManager securityManager = null;
+
+ if (isSecurityEnabled)
+ {
+ try {
+ securityManager = SecurityContextFactory.getInstance().getSecurityContext().getDefaultSecurityManager();
+ logger.debug("Identity = "+identity);
+ ((GCUBEClientSecurityManager) securityManager).setDefaultIdentityParameter(identity);
+
+ } catch (Exception e) {
+ logger.error("Unable to generate default security manager: trying without security...",e);
+ securityManager = new GCUBESecurityManagerImpl() {
+ public boolean isSecurityEnabled() {return isSecurityEnabled;}
+ };
+ }
+ }
+ else
+ {
+
+ securityManager = new GCUBESecurityManagerImpl() {
+ public boolean isSecurityEnabled() {return isSecurityEnabled;}
+ };
+ }
+
+ return securityManager;
+ }
+
+}