Added IS SSD support

master
Giancarlo Panichi 3 years ago
parent 563082a36f
commit 5cf3a0ec16

@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java"> <classpathentry kind="src" output="target/classes" path="src/main/java">
@ -17,11 +18,22 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> <classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes> <attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="test" value="true"/> <attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="target/classes"/> <classpathentry kind="output" path="target/classes"/>

@ -1,4 +1,6 @@
eclipse.preferences.version=1 eclipse.preferences.version=1
encoding//src/main/java=UTF-8 encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8 encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8 encoding/<project>=UTF-8

@ -20,6 +20,7 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>

@ -143,12 +143,19 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Information System Client IC-Client -->
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
</dependency>
<!-- Common Encryption --> <!-- Common Encryption -->
<dependency> <dependency>
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId> <artifactId>common-encryption</artifactId>
</dependency> </dependency>
<!-- Event Publisher Portal --> <!-- Event Publisher Portal -->
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
@ -174,7 +181,7 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.8.1</version> <version>4.13.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
@ -182,6 +189,20 @@
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<!-- Maven Surefire Plugin for Test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>false</skipTests>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M3</version>
</dependency>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>com.liferay.maven.plugins</groupId> <groupId>com.liferay.maven.plugins</groupId>
<artifactId>liferay-maven-plugin</artifactId> <artifactId>liferay-maven-plugin</artifactId>
@ -203,6 +224,7 @@
<pluginType>portlet</pluginType> <pluginType>portlet</pluginType>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
@ -218,24 +240,6 @@
<encoding>${project.build.resources.encoding}</encoding> <encoding>${project.build.resources.encoding}</encoding>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<additionalJOption>-Xdoclint:none</additionalJOption>
</configuration>
<version>3.1.0</version>
<executions>
<execution>
<id>generate-doc</id>
<phase>install</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

@ -199,8 +199,7 @@ public class SystemServiceDefinition extends MVCPortlet {
ArrayList<DefinitionItem> itemsList = new ArrayList<>(); ArrayList<DefinitionItem> itemsList = new ArrayList<>();
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
DefinitionItem definitionItem = new DefinitionItem("client_id_" + i, "description_" + i, "xxxx_" + i, DefinitionItem definitionItem = new DefinitionItem("client_id_" + i, "description_" + i, "xxxx_" + i);
"enc_xxxx_" + i);
itemsList.add(definitionItem); itemsList.add(definitionItem);
} }
@ -351,7 +350,9 @@ public class SystemServiceDefinition extends MVCPortlet {
logger.debug("Requested: [clientId={}, description={}]", clientId, description); logger.debug("Requested: [clientId={}, description={}]", clientId, description);
String secret = UUID.randomUUID().toString(); String secret = UUID.randomUUID().toString();
String encryptedSecret = null; // StringEncrypter.getEncrypter().encrypt(secret); String encryptedSecret = null; // StringEncrypter.getEncrypter().encrypt(secret);
DefinitionItem definitionItem = new DefinitionItem(clientId, description, secret, encryptedSecret); DefinitionItem definitionItem = new DefinitionItem(clientId, description, secret);
// publishCreateSSDEvent(definitionItem); // publishCreateSSDEvent(definitionItem);
SessionMessages.add(actionRequest, "success-definition-created"); SessionMessages.add(actionRequest, "success-definition-created");
actionResponse.setRenderParameter("jspPage", "/html/systemservicedefinition/view.jsp"); actionResponse.setRenderParameter("jspPage", "/html/systemservicedefinition/view.jsp");

@ -14,14 +14,12 @@ public class DefinitionItem implements Serializable {
private String clientId; private String clientId;
private String description; private String description;
private String secret; private String secret;
private String encryptedSecret;
public DefinitionItem(String clientId, String description, String secret, String encryptedSecret) { public DefinitionItem(String clientId, String description, String secret) {
super(); super();
this.clientId = clientId; this.clientId = clientId;
this.description = description; this.description = description;
this.secret = secret; this.secret = secret;
this.encryptedSecret = encryptedSecret;
} }
public String getClientId() { public String getClientId() {
@ -48,24 +46,13 @@ public class DefinitionItem implements Serializable {
this.secret = secret; this.secret = secret;
} }
public String getEncryptedSecret() {
return encryptedSecret;
}
public void setEncryptedSecret(String encryptedSecret) {
this.encryptedSecret = encryptedSecret;
}
public static long getSerialversionuid() { public static long getSerialversionuid() {
return serialVersionUID; return serialVersionUID;
} }
@Override @Override
public String toString() { public String toString() {
return "DefinitionItem [clientId=" + clientId + ", description=" + description + ", secret=" + secret return "DefinitionItem [clientId=" + clientId + ", description=" + description + ", secret=" + secret + "]";
+ ", encryptedSecret=" + encryptedSecret + "]";
} }
} }

@ -16,14 +16,12 @@ public class CreateSSDEvent extends PortalEvent {
public static final String CLIENT_ID_ENTRY = "client_id"; public static final String CLIENT_ID_ENTRY = "client_id";
public static final String DESCRIPTION_ENTRY = "description"; public static final String DESCRIPTION_ENTRY = "description";
public static final String CLIENT_SECRET_ENTRY = "client_sercret"; public static final String CLIENT_SECRET_ENTRY = "client_sercret";
public static final String ENCRYPTED_SECRET_ENTRY = "encrypted_secret";
public CreateSSDEvent(DefinitionItem definitionItem) { public CreateSSDEvent(DefinitionItem definitionItem) {
super(NAME); super(NAME);
setClientId(definitionItem.getClientId()); setClientId(definitionItem.getClientId());
setDescription(definitionItem.getDescription()); setDescription(definitionItem.getDescription());
setClientSecret(definitionItem.getSecret()); setClientSecret(definitionItem.getSecret());
setEncryptedSecret(definitionItem.getEncryptedSecret());
} }
public void setClientId(String clientId) { public void setClientId(String clientId) {
@ -50,12 +48,4 @@ public class CreateSSDEvent extends PortalEvent {
return (String) get(CLIENT_SECRET_ENTRY); return (String) get(CLIENT_SECRET_ENTRY);
} }
public void setEncryptedSecret(String encryptedSecret) {
set(ENCRYPTED_SECRET_ENTRY, encryptedSecret);
}
public String getEncryptedSecret() {
return (String) get(ENCRYPTED_SECRET_ENTRY);
}
} }

@ -0,0 +1,83 @@
package org.gcube.portlets.admin.systemservicedefinition.is;
import java.util.List;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.resources.discovery.icclient.ICFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class InformationSystemUtils {
private static Logger logger = LoggerFactory.getLogger(InformationSystemUtils.class);
public static void retrieveSSD(String category, String scope, String token) throws Exception {
try {
logger.debug("Retrieve System Services Definition on IS");
if (scope == null || scope.isEmpty())
throw new Exception("Invalid scope: " + scope);
if (token == null || token.isEmpty())
throw new Exception("Invalid token: " + scope);
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(token);
//
SimpleQuery query = ICFactory.queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Category/text() eq '" + category + "'");
DiscoveryClient<ServiceEndpoint> client = ICFactory.clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> resources = client.submit(query);
logger.debug("Retrieved: " + resources);
/*
* String serviceAddress = null; ArrayList<ServiceInfoData> serviceProperties =
* new ArrayList<>();
*
* if (accessPointList != null && !accessPointList.isEmpty()) { for (int i = 0;
* i < accessPointList.size(); i++) { AccessPoint accessPoint =
* accessPointList.get(i); if (accessPoint != null) { if (i == 0) { if
* (accessPoint.address() != null && !accessPoint.address().isEmpty()) { String
* accessPointAddress = accessPoint.address(); int wpsWebProcessingServiceIndex
* = accessPointAddress .indexOf(Constants.WPSWebProcessingService); if
* (wpsWebProcessingServiceIndex > 0) { serviceAddress =
* accessPointAddress.substring(0, wpsWebProcessingServiceIndex); } } }
*
* String categoryDescription; if (accessPoint.description() == null &&
* accessPoint.description().isEmpty()) { categoryDescription =
* Constants.DATA_MINER_DEFAULT_SERVICE_INFO_CATEGORY; } else {
* categoryDescription = accessPoint.description(); }
*
* if (accessPoint.properties() != null && !accessPoint.propertyMap().isEmpty())
* { for (String key : accessPoint.propertyMap().keySet()) { Property property =
* accessPoint.propertyMap().get(key); if (property != null && property.name()
* != null && !property.name().isEmpty()) { if (property.name().contains(":")) {
* String[] propertyWithCategory = property.name().split(":"); if
* (propertyWithCategory.length >= 2) { serviceProperties.add(new
* ServiceInfoData(propertyWithCategory[1], property.value(),
* propertyWithCategory[0])); } else { serviceProperties.add(new
* ServiceInfoData(property.name(), property.value(), categoryDescription)); } }
* else { serviceProperties.add(new ServiceInfoData(property.name(),
* property.value(), categoryDescription)); } }
*
* } } } } } ServiceInfo serviceInfo = new ServiceInfo(serviceAddress,
* serviceProperties);
*
* logger.debug("DataMiner Service Info: " + serviceInfo); return serviceInfo;
*/
} catch (Throwable e) {
logger.error("Error in discovery System Services Endpoint in scope: " + scope);
logger.error(e.getLocalizedMessage(), e);
throw e;
}
}
}

@ -0,0 +1,30 @@
package org.gcube.portlets.admin.systemservicedefinition.shared;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class Constants {
public static final boolean DEBUG_MODE = false;
public static final boolean TEST_ENABLE = false;
public static final String DEFAULT_USER = "giancarlo.panichi";
public static final String DEFAULT_SCOPE = "/gcube";
public static final String DEFAULT_TOKEN = "";
public static final String DEFAULT_ROLE = "OrganizationMember";
// Session
public static final String CURR_GROUP_ID = "CURR_GROUP_ID";
// Social Resource
public static final String SOCIAL_NETWORKING_NAME = "SocialNetworking";
public static final String SOCIAL_NETWORKING_CATEGORY = "Portal";
// SSD Services Endpoint
public static final String SYSTEM_SERVICE_CATEGORY = "SystemService";
}

@ -0,0 +1,44 @@
package org.gcube.portlets.admin.systemservicedefinition;
import static org.junit.Assert.assertTrue;
import java.util.List;
import org.gcube.common.resources.gcore.GenericResource;
import org.gcube.portlets.admin.systemservicedefinition.is.InformationSystemUtils;
import org.gcube.portlets.admin.systemservicedefinition.shared.Constants;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Giancarlo Panichi
*
*
*/
public class ISTest {
private static Logger logger = LoggerFactory.getLogger(ISTest.class);
@Test
public void findAlgoInVRE() {
try {
InformationSystemUtils.retrieveSSD(Constants.SYSTEM_SERVICE_CATEGORY,
Constants.DEFAULT_SCOPE, Constants.DEFAULT_TOKEN);
assertTrue(true);
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
assertTrue("Error searching the resource!",false);
}
}
}

@ -0,0 +1,9 @@
/FARM.gcubekey
/d4science.research-infrastructures.eu.gcubekey
/devNext.gcubekey
/devsec.gcubekey
/gCubeApps.gcubekey
/gcube.gcubekey
/howto.txt
/log4j.properties
/symm.key
Loading…
Cancel
Save