Compare commits

..

81 Commits

Author SHA1 Message Date
Giancarlo Panichi f771d4464f Updated Changelog 2022-04-01 10:25:36 +02:00
Giancarlo Panichi 4e22245042 Changed DatastapaceManager logs 2022-03-31 16:18:26 +02:00
Giancarlo Panichi 81c260646d Updated write exclusion behavior 2022-03-25 12:47:26 +01:00
Giancarlo Panichi 6d74cf7fc3 Updated to fix protocol parameters when persistence is disabled 2022-03-21 15:57:29 +01:00
Giancarlo Panichi 5f1fee5ca9 Minor updated 2022-03-15 17:02:12 +01:00
Giancarlo Panichi a308f08c93 Updated bom version for release 2022-03-15 17:01:33 +01:00
Giancarlo Panichi 5e3252ef5b Fixed pom for release 2022-03-15 11:12:16 +01:00
Giancarlo Panichi e76593263b Merge pull request 'feature/22700' (!1) from feature/22700 into master
Reviewed-on: #1
2022-03-15 11:09:05 +01:00
Giancarlo Panichi 6ecfcc9a13 Updated for release 2022-03-15 11:04:40 +01:00
Giancarlo Panichi 71361eb435 Updated gcube-bom to 2.1.0-SNAPSHOT for storagehub 2.0.0 2022-01-27 18:33:07 +01:00
Giancarlo Panichi 5f9681048f ref 22700: DataMiner - Check max computations limit
Updated max computations parameter check.
2022-01-24 18:27:56 +01:00
Roberto Cirillo fbade3e930 Update 'CHANGELOG.md'
snapshot removed from CHANGELOG
2021-10-08 17:30:01 +02:00
Roberto Cirillo 9e26a0680a Update 'pom.xml'
snapshot removed from pom
2021-10-08 17:29:36 +02:00
Roberto Cirillo 106a03dab4 Update 'CHANGELOG.md'
add SNAPSHOT to 1.7.1 version
2021-10-06 12:04:25 +02:00
Roberto Cirillo 403b9c2b2e Update 'pom.xml'
add SNAPSHOT to the version
2021-10-06 12:03:56 +02:00
Giancarlo Panichi 84be7e4fe7 Updated for Release Next 2021-06-15 15:40:52 +02:00
Giancarlo Panichi 193885a1a3 Updated for accounting-lib 2021-06-15 15:31:18 +02:00
Giancarlo Panichi be510cbda0 Updated for Release Next 2021-06-15 15:20:40 +02:00
Giancarlo Panichi 1e0b6b4d02 Rebuild SNAPSHOT 2021-06-15 15:14:36 +02:00
Giancarlo Panichi dbb87e55f7 ref 20971: ShortLink - Check for obsolete short urls
https://support.d4science.org/issues/20971

Fixed ShortLink urls.
2021-05-25 11:14:58 +02:00
Giancarlo Panichi 2d982938ce ref 20971: ShortLink - Check for obsolete short urls
https://support.d4science.org/issues/20971

Fixed ShortLink urls.
2021-05-25 10:50:17 +02:00
Giancarlo Panichi 86f5e9de17 ref 20971: ShortLink - Check for obsolete short urls
https://support.d4science.org/issues/20971

Fixed ShortLink urls.
2021-05-25 10:24:59 +02:00
Giancarlo Panichi 33b08ac966 ref 20971: ShortLink - Check for obsolete short urls
https://support.d4science.org/issues/20971

Fixed ShortLink urls.
2021-05-24 18:45:35 +02:00
Giancarlo Panichi a24383b37e ref 20971: ShortLink - Check for obsolete short urls
https://support.d4science.org/issues/20971

Fixed ShortLink urls.
2021-05-24 18:22:21 +02:00
Giancarlo Panichi e0ad80592d ref 20971: ShortLink - Check for obsolete short urls
https://support.d4science.org/issues/20971

Fixed ShortLink urls.
2021-05-24 18:13:29 +02:00
Roberto Cirillo 6334bb4224 Update 'pom.xml'
removed snapshot
2021-01-20 15:59:21 +01:00
Roberto Cirillo d1f61f1693 Update 'pom.xml'
added SNAPSHOT
2021-01-19 17:02:01 +01:00
Roberto Cirillo a1ae32f437 Update 'pom.xml'
update ecological-engine-smart-executor lower bound range
2021-01-19 16:50:15 +01:00
Roberto Cirillo cde6155c81 Update 'pom.xml'
update ecological-engine-external-algorithms lower bound range
2021-01-19 09:46:31 +01:00
lucio.lelii 2b719a7633 pom updated to remove old maven repositories 2021-01-18 20:01:26 +01:00
lucio.lelii d42448591d pom updated 2020-11-30 17:48:03 +01:00
lucio.lelii d9a6eb21be - EnviromentalVariableManager reverted
- import range changed for ecological-engine libraries
2020-11-30 17:39:25 +01:00
user1 279535c13a config Path can be set from EnvManager 2020-11-20 16:25:19 +01:00
Giancarlo Panichi 0a1de08b27 Updated descriptor.xml 2020-06-11 14:30:40 +02:00
Giancarlo Panichi a6e006439e ref 19423: DataMiner - Update DataMiner Service in Dev for support https
https://support.d4science.org/issues/19423

 Updated for support https protocol
2020-06-10 16:53:51 +02:00
Giancarlo Panichi 806effbd6f Renamed CHANGELOG.md 2020-06-10 15:21:32 +02:00
Giancarlo Panichi 6621bb20d9 Renamed CHANGELOG.md 2020-06-10 14:54:38 +02:00
Giancarlo Panichi 45ecff015d Renamed CHANGELOG.md 2020-06-10 14:44:17 +02:00
Giancarlo Panichi a24ecf41cb Renamed CHANGELOG.md 2020-06-10 14:42:03 +02:00
roberto cirillo 577a564b4d update to version 1.6.0:
removed snapshot, edit changelog.md
2020-05-14 17:13:57 +02:00
roberto cirillo cc1cece20e Merge branch 'master' of https://code-repo.d4science.org/gCubeSystem/dataminer.git 2020-05-12 15:23:53 +02:00
roberto cirillo c573360e2a added shub retry on InputManager class, getLocalFile method 2020-05-12 15:23:26 +02:00
roberto cirillo fdffbd6063 reverting retry in order to push another retry feature
Revert "Added Retry in Input Parameter URL retrieve for fix StorageHub sync."

This reverts commit 4d6318df92.
2020-05-12 15:18:23 +02:00
Giancarlo Panichi 4d6318df92 Added Retry in Input Parameter URL retrieve for fix StorageHub sync. 2020-05-12 11:24:31 +02:00
Giancarlo Panichi 34083f1357 ref 18289: the latest wps doesn't work
https://support.d4science.org/issues/18289

Rebuild Snapshot
2020-04-23 11:22:24 +02:00
Giancarlo Panichi a5223ecb43 Updated to Git and Jenkins 2019-11-28 18:50:01 +01:00
Giancarlo Panichi 08a56c02dd Updated to Git and Jenkins 2019-11-28 11:09:46 +01:00
Giancarlo Panichi c2acc48494 Updated to Git and Jenkins 2019-11-26 15:55:00 +01:00
Giancarlo Panichi 9360f1eaa5 Updated to support Git and Jenkins 2019-11-26 15:13:55 +01:00
Giancarlo Panichi a11cb3647f Updated to support Git and Jenkins 2019-11-26 15:11:49 +01:00
Giancarlo Panichi ea88169e41 Updated to Git and Jenkins 2019-11-25 16:15:04 +01:00
Giancarlo Panichi 6b8d28873b Updated to Git and Jenkins 2019-11-25 15:52:32 +01:00
Giancarlo Panichi f16dbd2f71 Updated to Git and Jenkins 2019-11-25 11:58:58 +01:00
Giancarlo Panichi 81ddc263d1 Updated to Git and Jenkins 2019-11-21 17:32:37 +01:00
Giancarlo Panichi 88bc383f3c Updated Pom to build the SNAPSHOT 2019-11-21 14:23:41 +01:00
Giancarlo Panichi 8d0d481e14 Updated to support Git and Jenkins 2019-11-20 17:23:42 +01:00
Giancarlo Panichi 9891b206a5 Updated to support Git and Jenkins 2019-11-20 17:19:23 +01:00
Giancarlo Panichi 790cff989c ref 18096: DataMiner - HTML file does not open in view widget but in a new browser window
https://support.d4science.org/issues/18096

Fixed Content-Type in output files

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@182280 82a268e6-3cf1-43bd-a215-b396298e98cf
2019-11-20 15:43:27 +00:00
Giancarlo Panichi 4d653662ce ref 17659: DataMiner - DataMiner Service - DataMiner service must create https links instead of http links for output parameters to avoid problems with the portal that uses https.
https://support.d4science.org/issues/17659

Fixed https link for output parameter

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@181938 82a268e6-3cf1-43bd-a215-b396298e98cf
2019-10-03 13:26:30 +00:00
Giancarlo Panichi 020c621a34 ref 13024: DataMiner - The service must support the https protocol
https://support.d4science.org/issues/13024

Updated DataMiner now support https

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@181937 82a268e6-3cf1-43bd-a215-b396298e98cf
2019-10-03 13:14:53 +00:00
Lucio Lelii f47693f27a git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@179537 82a268e6-3cf1-43bd-a215-b396298e98cf 2019-05-23 14:48:31 +00:00
Lucio Lelii ed556a9960 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@179518 82a268e6-3cf1-43bd-a215-b396298e98cf 2019-05-22 15:45:21 +00:00
Lucio Lelii 9d6794ffde git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@179069 82a268e6-3cf1-43bd-a215-b396298e98cf 2019-04-17 15:36:38 +00:00
Lucio Lelii 0adfa5b959 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@178855 82a268e6-3cf1-43bd-a215-b396298e98cf 2019-04-04 16:48:29 +00:00
Lucio Lelii fb6c980623 Added possibility to exclude single or all user to write to workspace
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@178710 82a268e6-3cf1-43bd-a215-b396298e98cf
2019-03-27 17:34:46 +00:00
Giancarlo Panichi fc5e616101 Fixed Jersey version in dependencies
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@176633 82a268e6-3cf1-43bd-a215-b396298e98cf
2019-01-17 11:11:46 +00:00
Giancarlo Panichi d3080c4052 ref 13024: DataMiner - The service must support the https protocol
https://support.d4science.org/issues/13024

Updated DataMiner now support https

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@174936 82a268e6-3cf1-43bd-a215-b396298e98cf
2018-12-17 15:07:07 +00:00
Giancarlo Panichi 34d131b900 Aligned Trunk to Branch
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@174213 82a268e6-3cf1-43bd-a215-b396298e98cf
2018-11-19 09:03:18 +00:00
Lucio Lelii 60ccac1784 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@174113 82a268e6-3cf1-43bd-a215-b396298e98cf 2018-11-12 17:16:15 +00:00
Giancarlo Panichi 26ad1e8cc9 ref 12703: Public pages visualised by data miner services and proxies
https://support.d4science.org/issues/12703

Updated DataMiner service metadata info

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173657 82a268e6-3cf1-43bd-a215-b396298e98cf
2018-10-18 15:38:14 +00:00
Lucio Lelii bf7e31697d git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173645 82a268e6-3cf1-43bd-a215-b396298e98cf 2018-10-18 08:00:09 +00:00
Lucio Lelii 3d509ae807 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173523 82a268e6-3cf1-43bd-a215-b396298e98cf 2018-10-16 13:57:23 +00:00
Lucio Lelii 9013721e12 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173518 82a268e6-3cf1-43bd-a215-b396298e98cf 2018-10-16 13:27:01 +00:00
Lucio Lelii 67fbb1f724 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173508 82a268e6-3cf1-43bd-a215-b396298e98cf 2018-10-16 12:35:16 +00:00
Lucio Lelii fdda6ce838 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173507 82a268e6-3cf1-43bd-a215-b396298e98cf 2018-10-16 12:11:26 +00:00
Lucio Lelii f6b3253459 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173502 82a268e6-3cf1-43bd-a215-b396298e98cf 2018-10-16 09:57:30 +00:00
Lucio Lelii 8e7edbb075 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173499 82a268e6-3cf1-43bd-a215-b396298e98cf 2018-10-15 17:41:21 +00:00
Lucio Lelii 30749c37e3 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173393 82a268e6-3cf1-43bd-a215-b396298e98cf 2018-10-12 14:19:28 +00:00
Lucio Lelii 908e7e57f4 EnvironmentVariableManager added
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173383 82a268e6-3cf1-43bd-a215-b396298e98cf
2018-10-12 13:53:36 +00:00
Lucio Lelii 607f49125c Removed special char "["and "]" from output omputation name
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@173249 82a268e6-3cf1-43bd-a215-b396298e98cf
2018-10-11 16:57:04 +00:00
Lucio Lelii c6676795ce git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/DataMiner@169188 82a268e6-3cf1-43bd-a215-b396298e98cf 2018-06-14 09:29:15 +00:00
6 changed files with 36 additions and 204 deletions

View File

@ -1,19 +1,6 @@
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# Changelog for "dataminer"
## [v1.9.1]
- Updated gcube-bom to 2.4.1
## [v1.9.0] - 2022-04-05
- Added support to new JWT token via URI Resolver [#23107]
## [v1.8.1] - 2022-03-21
## [v1.8.1-SNAPSHOT] - 2022-03-21
- Update wps service to support not writing of the computation status to the user's workspace [#23054]
- Fixed protocol parameter when persistence is disabled
@ -75,3 +62,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- First Release
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

34
pom.xml
View File

@ -1,19 +1,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.2.0</version>
<version>1.1.0</version>
<relativePath />
</parent>
<groupId>org.gcube.dataanalysis</groupId>
<artifactId>dataminer</artifactId>
<version>1.9.1</version>
<version>1.8.1-SNAPSHOT</version>
<name>dataminer</name>
<description>An e-Infrastructure service providing state-of-the art DataMining algorithms and ecological modelling approaches under the Web Processing Service (WPS) standard.</description>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
@ -22,7 +21,7 @@
<developers>
<developer>
<name>Gianpaolo 52n-wps-io-implCoro</name>
<name>Gianpaolo Coro</name>
<email>gianpaolo.coro@isti.cnr.it</email>
<organization>CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"</organization>
<roles>
@ -40,14 +39,14 @@
</roles>
</developer>
</developers>
<properties>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<distroDirectory>distro</distroDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<!-- Old solution <dependencies> <dependency> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-smartgears-bom</artifactId> <version>2.1.0</version> <type>pom</type>
@ -56,14 +55,14 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>2.4.1</version>
<version>2.1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.reflections/reflections-maven -->
<dependency>
@ -92,12 +91,12 @@
<dependency>
<groupId>org.gcube.dataanalysis</groupId>
<artifactId>52n-wps-algorithm-gcube</artifactId>
<version>[3.6.1,3.7.0-SNAPSHOT)</version>
<version>[3.6.1,3.7.0)</version>
</dependency>
<dependency>
<groupId>org.gcube.dataanalysis</groupId>
<artifactId>52n-wps-server-gcube</artifactId>
<version>[3.6.1, 3.7.0-SNAPSHOT)</version>
<version>[3.6.1, 3.7.0)</version>
</dependency>
<dependency>
<groupId>org.gcube.dataanalysis</groupId>
@ -107,7 +106,7 @@
<dependency>
<groupId>org.gcube.dataanalysis</groupId>
<artifactId>ecological-engine-geospatial-extensions</artifactId>
<version>[1.5.2,2.0.0-SNAPSHOT)</version>
<version>[1.5.2-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<exclusions>
<exclusion>
<artifactId>log4j</artifactId>
@ -118,12 +117,12 @@
<dependency>
<groupId>org.gcube.dataanalysis</groupId>
<artifactId>ecological-engine-external-algorithms</artifactId>
<version>[1.2.2,2.0.0-SNAPSHOT)</version>
<version>[1.2.2-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.dataanalysis</groupId>
<artifactId>ecological-engine-smart-executor</artifactId>
<version>[1.6.5,2.0.0-SNAPSHOT)</version>
<version>[1.6.5-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<exclusions>
<exclusion>
<groupId>org.glassfish.jersey.core</groupId>
@ -146,7 +145,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -201,7 +199,7 @@
<repository>
<id>n52-releases</id>
<name>52n Releases</name>
<url>https://52north.org/maven/repo/releases</url>
<url>http://52north.org/maven/repo/releases</url>
<releases>
<enabled>true</enabled>
</releases>

View File

@ -1,67 +0,0 @@
package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.is;
import java.util.List;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.Runtime;
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 final Logger LOGGER = LoggerFactory.getLogger(InformationSystemUtils.class);
private static final String URI_RESOLVER_SERVICE_CATEGORY = "Service";
private static final String URI_RESOLVER_SERVICE_NAME = "HTTP-URI-Resolver";
public static String retrieveUriResolverOat(String scope) throws Exception {
try {
LOGGER.info("Retrieve URI Resolver Oat Service Info");
if (scope == null || scope.length() == 0) {
String error="Invalid request scope: " + scope;
LOGGER.error(error);
throw new Exception(error);
}
ScopeProvider.instance.set(scope);
SimpleQuery query = ICFactory.queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Category/text() eq '" + URI_RESOLVER_SERVICE_CATEGORY + "'")
.addCondition("$resource/Profile/Name/text() eq '" + URI_RESOLVER_SERVICE_NAME + "'")
.setResult("$resource/Profile/RunTime");
DiscoveryClient<Runtime> client = ICFactory.clientFor(Runtime.class);
List<Runtime> runtimeList = client.submit(query);
String serviceAddress = null;
if (runtimeList != null && !runtimeList.isEmpty()) {
for (int i = 0; i < runtimeList.size(); i++) {
Runtime accessPoint = runtimeList.get(i);
if (accessPoint != null) {
StringBuilder sb=new StringBuilder();
sb.append("https://");
sb.append(accessPoint.hostedOn());
sb.append("/oat/get");
serviceAddress=sb.toString();
break;
}
}
} else {
String error="RuntimeList error: "+runtimeList;
LOGGER.error(error);
throw new Exception(error);
}
LOGGER.info("Uri Resolver Oat Service Info: " + serviceAddress);
return serviceAddress;
} catch (Throwable e) {
LOGGER.error("Error in discovery Uri Resolver Oat Service Endpoint in scope: " + scope);
LOGGER.error(e.getLocalizedMessage(),e);
throw e;
}
}
}

View File

@ -2,122 +2,59 @@ package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping;
import static org.gcube.common.authorization.client.Constants.authorizationService;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.ws.rs.core.Response;
import org.gcube.common.authorization.library.AuthorizationEntry;
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.dataanalysis.wps.statisticalmanager.synchserver.is.InformationSystemUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TokenManager {
private static final Logger LOGGER = LoggerFactory.getLogger(TokenManager.class);
private static final Logger LOGGER= LoggerFactory.getLogger(TokenManager.class);
String username;
String scope;
String token;
String tokenQualifier;
public String getScope() {
public String getScope(){
return scope;
}
public String getUserName() {
public String getUserName(){
return username;
}
public String getToken() {
public String getToken(){
return token;
}
public String getTokenQualifier() {
return tokenQualifier;
}
public void getCredentials() {
try {
LOGGER.info("Retrieving token credentials");
// get username from SmartGears
try{
LOGGER.debug("Retrieving token credentials");
//get username from SmartGears
username = AuthorizationProvider.instance.get().getClient().getId();
token = SecurityTokenProvider.instance.get();
if (token == null || token.isEmpty()) {
String jwtToken = AccessTokenProvider.instance.get();
scope = ScopeProvider.instance.get();
token = getGcubeTokenFromUriResolver(jwtToken, scope);
}
AuthorizationEntry entry = authorizationService().get(token);
scope = entry.getContext();
tokenQualifier = entry.getQualifier();
} catch (Exception e) {
LOGGER.error("Error Retrieving token credentials: "+e.getLocalizedMessage(),e);
}catch(Exception e){
LOGGER.error("Error Retrieving token credentials ",e);
scope = null;
username = null;
username= null;
}
if ((scope == null || username == null) && ConfigurationManager.isSimulationMode()) {
if ((scope==null || username==null) && ConfigurationManager.isSimulationMode()){
scope = ConfigurationManager.defaultScope;
username = ConfigurationManager.defaultUsername;
}
LOGGER.info("Retrieved scope: {} Username: {} Token {} SIMULATION MODE: {} ", scope, username, token,
ConfigurationManager.isSimulationMode());
LOGGER.debug("Retrieved scope: {} Username: {} Token {} SIMULATION MODE: {} ",scope, username, token, ConfigurationManager.isSimulationMode());
}
public String getGcubeTokenFromUriResolver(String jwtToken, String scope) throws Exception {
String gcubeToken = null;
String uriResolverOatURL = InformationSystemUtils.retrieveUriResolverOat(scope);
try {
LOGGER.info("Create Request: "+ uriResolverOatURL);
URL urlObj = new URL(uriResolverOatURL);
HttpURLConnection connection = (HttpURLConnection) urlObj.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "Bearer " + jwtToken);
connection.setDoOutput(true);
try (AutoCloseable conc = () -> connection.disconnect()) {
int responseCode = connection.getResponseCode();
LOGGER.info("Response Code: " + responseCode);
if (Response.Status.fromStatusCode(responseCode).compareTo(Response.Status.OK) == 0) {
try (InputStream ins = connection.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(ins))) {
String inputLine = null;
while ((inputLine = in.readLine()) != null) {
break;
}
gcubeToken = inputLine;
}
} else {
String error = "Invalid Response Code retrieving GCube Token from Uri Resolver: " + responseCode;
LOGGER.error(error);
try (InputStream ins = connection.getErrorStream();
BufferedReader in = new BufferedReader(new InputStreamReader(ins))) {
String inputLine = null;
while ((inputLine = in.readLine()) != null) {
LOGGER.error(inputLine);
}
}
throw new Exception(error);
}
}
} catch (IOException e) {
LOGGER.error("Error retrieving GcubeToken from Uri Resolver: "+e.getLocalizedMessage());
e.printStackTrace();
throw e;
}
LOGGER.info("Retrieved GcubeToken: "+gcubeToken);
return gcubeToken;
}
}

View File

@ -1,26 +0,0 @@
package org.gcube.dataanalysis.wps.statisticalmanager.synchserver.mapping;
import org.apache.log4j.BasicConfigurator;
import org.junit.Test;
public class TokenManagerTest {
private static final String JWT_TOKEN = "";
private static final String SCOPE = "/gcube/devsec/devVRE";
@Test
public void retrieveTokenFromUriResolver() throws Exception {
try {
BasicConfigurator.configure();
System.out.println("Test Retrieve Token From Uri Resolver");
TokenManager tm = new TokenManager();
String token = tm.getGcubeTokenFromUriResolver(JWT_TOKEN, SCOPE);
System.out.println("GcubeToken retrieved: "+token);
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
e.getStackTrace();
}
}
}

View File

@ -30,7 +30,7 @@ public class AlgorithmTest {
String protocol = "http";
String hostname = "dataminer-genericworkers.d4science.org";
String token = "xxx-xxx-xxx-xxx";
String token = "257800d8-24bf-4bae-83cd-ea99369e7dd6-843339462";
String layerID = "08ee0d70-4d8b-4f42-8b06-d709482bca95";
Iterator<String> uris = getUrisIterator();