diff --git a/.classpath b/.classpath
index 9ed308d..7bade01 100644
--- a/.classpath
+++ b/.classpath
@@ -7,6 +7,6 @@
-
+
diff --git a/build.xml b/build.xml
index 0d78627..153eabe 100755
--- a/build.xml
+++ b/build.xml
@@ -59,6 +59,8 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
+
+
@@ -73,6 +75,8 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
+
+
@@ -90,6 +94,7 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
+
@@ -101,6 +106,9 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
+
+
+
@@ -144,7 +152,11 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
+
+
+
+
@@ -462,10 +474,39 @@ full.stubs: (optional) Set to 'false', it excludes auxiliary stub code plac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/org/gcube/informationsystem/registry/stubs/testsuite/RegistryRemoveTest.java b/src/org/gcube/informationsystem/registry/stubs/testsuite/RegistryRemoveTest.java
deleted file mode 100644
index c2f37ea..0000000
--- a/src/org/gcube/informationsystem/registry/stubs/testsuite/RegistryRemoveTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.gcube.informationsystem.registry.stubs.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.informationsystem.registry.stubs.RegistryFactoryPortType;
-import org.gcube.informationsystem.registry.stubs.RemoveResourceMessage;
-import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
-
-public class RegistryRemoveTest {
-
- public static void main(String[] args) throws Exception {
-
- RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
-
- GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
- public boolean isSecurityEnabled() {
- return true;
- }
- };
-
- EndpointReferenceType factoryEPR = new EndpointReferenceType();
-
- RegistryFactoryPortType registryFactoryPortType = null;
- try {
- factoryEPR.setAddress(new Address(args[0]));
- registryFactoryPortType = registryLocator
- .getRegistryFactoryPortTypePort(factoryEPR);
- } catch (Exception e) {
- e.printStackTrace();
- }
- RemoveResourceMessage message = new RemoveResourceMessage();
-
- // managerSec.useCredentials(cred);
- registryFactoryPortType = GCUBERemotePortTypeContext.getProxy(
- registryFactoryPortType, GCUBEScope.getScope(args[2]),
- managerSec);
- try {
- message.setType(args[3]);
- message.setUniqueID(args[1]);
- registryFactoryPortType.removeResource(message);
- System.out.println("Profile with ID " + args[1] + "has been succesfully removed");
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- }
-
-}
diff --git a/src/org/gcube/informationsystem/registry/stubs/testsuite/RegistryUpdateTest.java b/src/org/gcube/informationsystem/registry/stubs/testsuite/RegistryUpdateTest.java
deleted file mode 100644
index 7990227..0000000
--- a/src/org/gcube/informationsystem/registry/stubs/testsuite/RegistryUpdateTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.gcube.informationsystem.registry.stubs.testsuite;
-
-import java.io.FileReader;
-import java.io.StringWriter;
-
-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.resources.GCUBEResource;
-import org.gcube.common.core.scope.GCUBEScope;
-import org.gcube.common.core.security.GCUBESecurityManagerImpl;
-import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
-import org.gcube.informationsystem.registry.stubs.UpdateResourceMessage;
-import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
-
-public class RegistryUpdateTest {
-
-public static void main (String[]args ) throws Exception {
-
- RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
-
- GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() {return true;}};
- FileReader fis = new FileReader (args[1]);
- // load the resource
- GCUBEResource resource = RegistryRegistrationTest.getResource(args[3], new FileReader(args[1]));
- EndpointReferenceType factoryEPR = new EndpointReferenceType();
- resource.load(fis);
-
- RegistryFactoryPortType registryFactoryPortType= null;
- try {
- factoryEPR.setAddress(new Address(args[0]));
- registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR);
- }catch(Exception e){
- e.printStackTrace();
- }
- UpdateResourceMessage message = new UpdateResourceMessage();
-
-
-
- registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope(args[2]),managerSec);
- try {
- StringWriter writer =new StringWriter();
- resource.store(writer);
- message.setXmlProfile(writer.toString());
- message.setUniqueID(resource.getID());
- message.setType(args[3]);
-
- registryFactoryPortType.updateResource(message);
- System.out.println("Profile has been updated");
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- }
-}
diff --git a/src/org/gcube/informationsystem/registry/stubs/testsuite/RegistryRegistrationTest.java b/test/org/gcube/informationsystem/registry/testsuite/RegistryRegistrationTest.java
similarity index 73%
rename from src/org/gcube/informationsystem/registry/stubs/testsuite/RegistryRegistrationTest.java
rename to test/org/gcube/informationsystem/registry/testsuite/RegistryRegistrationTest.java
index 3774494..7a841b6 100644
--- a/src/org/gcube/informationsystem/registry/stubs/testsuite/RegistryRegistrationTest.java
+++ b/test/org/gcube/informationsystem/registry/testsuite/RegistryRegistrationTest.java
@@ -1,4 +1,4 @@
-package org.gcube.informationsystem.registry.stubs.testsuite;
+package org.gcube.informationsystem.registry.testsuite;
import java.io.FileReader;
import java.io.StringWriter;
@@ -14,12 +14,12 @@ import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.resources.GCUBEService;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
-import org.gcube.informationsystem.registry.stubs.CreateResourceMessage;
-import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
-import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
+import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage;
+import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType;
+import org.gcube.informationsystem.registry.stubs.resourceregistration.service.ResourceRegistrationServiceAddressingLocator;
/**
- * {@link GCUBEResource} registration tester
+ * Tester for Registration.create() operation
*
* @author Manuele Simi (CNR-ISTI)
*
@@ -31,11 +31,11 @@ public class RegistryRegistrationTest {
* @param args
* parameters:
*
- * - factory URI
+ *
- registration portType URI
*
- resource file
*
- resource type
*
- caller scope
- *
+ *
* @throws Exception
* if the registration fails
*/
@@ -49,7 +49,7 @@ public class RegistryRegistrationTest {
for (String param : args) System.out.println("param "+ param);
// get the scope and the factory URI
- GCUBEScope scope = GCUBEScope.getScope(args[2]);
+ GCUBEScope scope = GCUBEScope.getScope(args[3]);
EndpointReferenceType factoryEPR = new EndpointReferenceType();
try {
@@ -59,8 +59,7 @@ public class RegistryRegistrationTest {
Runtime.getRuntime().exit(1);
}
- RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
-
+ ResourceRegistrationServiceAddressingLocator locator = new ResourceRegistrationServiceAddressingLocator();
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {
return false;
@@ -68,26 +67,17 @@ public class RegistryRegistrationTest {
};
// load the resource
- GCUBEResource resource = getResource(args[3], new FileReader(args[1]));
-
- RegistryFactoryPortType registryFactoryPortType = null;
- try {
- registryFactoryPortType = registryLocator
- .getRegistryFactoryPortTypePort(factoryEPR);
- } catch (Exception e) {
- e.printStackTrace();
- Runtime.getRuntime().exit(1);
- }
- CreateResourceMessage message = new CreateResourceMessage();
-
- registryFactoryPortType = GCUBERemotePortTypeContext.getProxy(
- registryFactoryPortType, scope, managerSec);
+ GCUBEResource resource = getResource(args[2], new FileReader(args[1]));
try {
+ ResourceRegistrationPortType registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
+ registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
+ CreateMessage message = new CreateMessage();
+ registration = GCUBERemotePortTypeContext.getProxy(registration, scope, managerSec);
StringWriter writer = new StringWriter();
resource.store(writer);
message.setProfile(writer.toString());
message.setType(resource.getType());
- System.out.println(registryFactoryPortType.createResource(message));
+ System.out.println(registration.create(message));
} catch (Exception e) {
e.printStackTrace();
@@ -140,7 +130,7 @@ public class RegistryRegistrationTest {
*/
static void printUsage() {
System.out
- .println("RegistryRegistrationTest ");
+ .println("RegistryRegistrationTest ");
System.out
.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
System.exit(1);
diff --git a/test/org/gcube/informationsystem/registry/testsuite/RegistryRemoveTest.java b/test/org/gcube/informationsystem/registry/testsuite/RegistryRemoveTest.java
new file mode 100644
index 0000000..08af07b
--- /dev/null
+++ b/test/org/gcube/informationsystem/registry/testsuite/RegistryRemoveTest.java
@@ -0,0 +1,62 @@
+package org.gcube.informationsystem.registry.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.informationsystem.registry.stubs.resourceregistration.RemoveMessage;
+import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType;
+import org.gcube.informationsystem.registry.stubs.resourceregistration.service.ResourceRegistrationServiceAddressingLocator;
+
+/**
+ *
+ * Tester for Registration.remove() operation
+ *
+ * @author Manuele Simi (ISTI-CNR)
+ *
+ */
+public class RegistryRemoveTest {
+
+ public static void main(String[] args) throws Exception {
+
+
+ for (String param : args) System.out.println("param "+ param);
+
+ // get the scope and the registration URI
+ GCUBEScope scope = GCUBEScope.getScope(args[2]);
+
+ EndpointReferenceType factoryEPR = new EndpointReferenceType();
+ try {
+ factoryEPR.setAddress(new Address(args[0]));
+ } catch (Exception e) {
+ e.printStackTrace();
+ Runtime.getRuntime().exit(1);
+ }
+
+ ResourceRegistrationServiceAddressingLocator locator = new ResourceRegistrationServiceAddressingLocator();
+ GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
+ public boolean isSecurityEnabled() {
+ return false;
+ }
+ };
+
+
+ // load the resource
+ try {
+ ResourceRegistrationPortType registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
+ registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
+ RemoveMessage message = new RemoveMessage();
+ registration = GCUBERemotePortTypeContext.getProxy(registration, scope, managerSec);
+ message.setType(args[3]);
+ message.setUniqueID(args[1]);
+ registration.remove(message);
+ System.out.println("Profile with ID " + args[1] + "has been succesfully removed");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+}
diff --git a/test/org/gcube/informationsystem/registry/testsuite/security/SecureRegistryRegistrationTest.java b/test/org/gcube/informationsystem/registry/testsuite/security/SecureRegistryRegistrationTest.java
new file mode 100644
index 0000000..812b971
--- /dev/null
+++ b/test/org/gcube/informationsystem/registry/testsuite/security/SecureRegistryRegistrationTest.java
@@ -0,0 +1,131 @@
+package org.gcube.informationsystem.registry.testsuite.security;
+
+import java.io.FileReader;
+import java.io.StringWriter;
+
+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.resources.GCUBEGenericResource;
+import org.gcube.common.core.resources.GCUBEHostingNode;
+import org.gcube.common.core.resources.GCUBEResource;
+import org.gcube.common.core.resources.GCUBERunningInstance;
+import org.gcube.common.core.resources.GCUBEService;
+import org.gcube.common.core.scope.GCUBEScope;
+import org.gcube.common.core.security.GCUBESecurityManager;
+import org.gcube.informationsystem.registry.stubs.resourceregistration.CreateMessage;
+import org.gcube.informationsystem.registry.stubs.resourceregistration.ResourceRegistrationPortType;
+import org.gcube.informationsystem.registry.stubs.resourceregistration.service.ResourceRegistrationServiceAddressingLocator;
+
+/**
+ * Tester for Registration.create() operation
+ *
+ * @author Manuele Simi (CNR-ISTI)
+ *
+ */
+public class SecureRegistryRegistrationTest {
+
+ /**
+ *
+ * @param args
+ * parameters:
+ *
+ * - registration portType URI
+ *
- resource file
+ *
- resource type
+ *
- caller scope
+ *
- identity
+ *
+ * @throws Exception
+ * if the registration fails
+ */
+
+ public static void main(String[] args) throws Exception {
+
+ for (String param : args) System.out.println("param "+ param);
+
+ final boolean isSecurityEnabled = GHNContext.getContext().isSecurityEnabled();
+
+ if (args.length != 5) {
+ printUsage();
+ }
+
+
+ String identity = null;
+ if (isSecurityEnabled) identity = args [4];
+
+
+ GCUBEResource resource = getResource(args[2], new FileReader(args[1]));
+ EndpointReferenceType factoryEPR = new EndpointReferenceType();
+ try {
+ factoryEPR.setAddress(new Address(args[0]));
+ ResourceRegistrationServiceAddressingLocator locator = new ResourceRegistrationServiceAddressingLocator();
+ ResourceRegistrationPortType registration = locator.getResourceRegistrationPortTypePort(factoryEPR);
+ GCUBESecurityManager securityManager = Utils.generateAndConfigureDefaultSecurityManager(identity, isSecurityEnabled);
+ securityManager.setSecurity(registration, GCUBESecurityManager.AuthMode.PRIVACY, GCUBESecurityManager.DelegationMode.FULL);
+ registration = GCUBERemotePortTypeContext.getProxy(registration, GCUBEScope.getScope(args[3]), securityManager);
+ CreateMessage message = new CreateMessage();
+ StringWriter writer = new StringWriter();
+ resource.store(writer);
+ message.setProfile(writer.toString());
+ message.setType(resource.getType());
+ System.out.println("Resource successfully registered");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ Runtime.getRuntime().exit(1);
+ }
+
+
+
+ }
+
+ /**
+ * Loads the specific GCUBEResource class
+ *
+ * @param type
+ * the resource type
+ * @param file
+ * the file representation of the profile
+ * @return the resource class
+ * @throws Exception
+ * if the loading fails
+ */
+ static GCUBEResource getResource(String type, FileReader file)
+ throws Exception {
+ if (type.compareTo("Service") == 0) {
+ GCUBEService service = GHNContext
+ .getImplementation(GCUBEService.class);
+ service.load(file);
+ return (GCUBEResource) service;
+ } else if (type.compareTo("RunningInstance") == 0) {
+ GCUBERunningInstance instance = GHNContext
+ .getImplementation(GCUBERunningInstance.class);
+ instance.load(file);
+ return (GCUBEResource) instance;
+ } else if (type.compareTo("GHN") == 0) {
+ GCUBEHostingNode node = GHNContext
+ .getImplementation(GCUBEHostingNode.class);
+ node.load(file);
+ return (GCUBEResource) node;
+ } else if (type.compareTo("GenericResource") == 0) {
+ GCUBEGenericResource generic = GHNContext
+ .getImplementation(GCUBEGenericResource.class);
+ generic.load(file);
+ return (GCUBEResource) generic;
+ }
+
+ throw new Exception(type + " is an invalid resource type");
+
+ }
+
+ /**
+ * Prints tester usage syntax
+ */
+ static void printUsage() {
+ System.out.println("RegistryRegistrationTest ");
+ System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
+ System.exit(1);
+ }
+}
diff --git a/test/org/gcube/informationsystem/registry/testsuite/security/Utils.java b/test/org/gcube/informationsystem/registry/testsuite/security/Utils.java
new file mode 100644
index 0000000..6fe3d1f
--- /dev/null
+++ b/test/org/gcube/informationsystem/registry/testsuite/security/Utils.java
@@ -0,0 +1,42 @@
+package org.gcube.informationsystem.registry.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.GCUBELog;
+
+public class Utils
+{
+ public static GCUBESecurityManager generateAndConfigureDefaultSecurityManager (String identity, final boolean isSecurityEnabled)
+ {
+ GCUBELog logger = new GCUBELog(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;
+ }
+
+}