Commit d313d3e9 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

GMS client improvements

parent a625faa5
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -54,12 +54,10 @@ nbactions.xml
### VS Code ###
### VS Code ###
.vscode/
.vscode/


/gms-ui/target/
/gms/nbactions-release-profile.xml
/gms/nbactions-release-profile.xml


/gms-client/gms-client-lib/target/
/gms-client/gms-cli/target/
/gms/node/
/gms/node/
**/target/*


nb-configuration.xml
nb-configuration.xml
dependency-reduced-pom.xml
dependency-reduced-pom.xml
+4 −2
Original line number Original line Diff line number Diff line
base_url=http://localhost:8082/gms/ws/jwt
gms_url=http://localhost:8082/gms/ws/jwt
token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjM0ZmU4MDcwMDVhNTcxMTYifQ.eyJpc3MiOiJzc28uaWEyLmluYWYuaXQiLCJzdWIiOiIyMzg2IiwiaWF0IjoxNTg3NjU5NzYxLCJleHAiOjE1ODc3NDYxNjEsImF1ZCI6ImdtcyJ9.KcXRAciG3ApqlE8MFM8VYW9WAX3hEZb7Vk8jB9uJtWsOMU48ha_Ybb4k_f0nrD2jhOxwaNn2QMxWZuflwCf1N-KiCj5Ff9f8xKOrrXZrl-w1H3_dwtMlIS8t2b0-w0WwRJ7UIhrwVBzmCcWinD3qJhFPzyO2pi-A4aXV57RpJ68VXfALQXeHK0sslrf-RgAU3xWYOgjGTUoGB5BQYC9huA_bZ0eV1HFcancs9pDdoTusqZs8OkPFCJbo7-L5eibsuykqnLHztYdCcP2Vtvtwb0pww-ofWZblIHzoMI8i-ipnfLJETG8Dpc7FrhjCYLw3AEGZg4U1wYTeqG3HRbPXSQ
client_id=gms_cli
client_secret=gms
rap_url=http://localhost/rap-ia2
+1 −1
Original line number Original line Diff line number Diff line
@@ -17,7 +17,7 @@
    <dependencies>
    <dependencies>
        <dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <groupId>${project.groupId}</groupId>
            <artifactId>gms-client-lib</artifactId>
            <artifactId>gms-client</artifactId>
            <version>1.0-SNAPSHOT</version>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        </dependency>
    </dependencies>
    </dependencies>
+16 −12
Original line number Original line Diff line number Diff line
package it.inaf.ia2.gms.cli;
package it.inaf.ia2.gms.cli;


import it.inaf.ia2.client.ClientException;
import it.inaf.ia2.gms.client.GmsClient;
import it.inaf.ia2.gms.client.GmsClient;
import it.inaf.ia2.gms.client.GmsClientBuilder;
import it.inaf.ia2.gms.client.model.Permission;
import it.inaf.ia2.gms.client.model.Permission;
import it.inaf.ia2.rap.client.RapClient;
import java.io.File;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.IOException;
@@ -61,7 +62,11 @@ public class CLI {
                default:
                default:
                    verifyConfigLoaded();
                    verifyConfigLoaded();
                    createClient();
                    createClient();
                    parseCommand();
                    try {
                        parseCommand();
                    } catch (ClientException ex) {
                        System.err.println(ex.getMessage());
                    }
                    commandParsed = true;
                    commandParsed = true;
                    break;
                    break;
            }
            }
@@ -96,17 +101,16 @@ public class CLI {
    }
    }


    private void createClient() {
    private void createClient() {
        GmsClientBuilder clientBuilder = new GmsClientBuilder()

                .setGmsBaseUrl(gmsBaseUrl);
        client = new GmsClient(gmsBaseUrl);


        if (token != null) {
        if (token != null) {
            client = clientBuilder.build();
            client.setAccessToken(token);
            client.setAccessToken(token);
        } else {
        } else {            
            client = clientBuilder.setClientId(clientId)
            RapClient rapClient = new RapClient(rapBaseUrl)
                    .setClientSecret(clientSecret)
                    .setClientId(clientId)
                    .setRapBaseUrl(rapBaseUrl)
                    .setClientSecret(clientSecret);            
                    .build();
            client.setAccessToken(rapClient.getAccessTokenFromClientCredentials());
        }
        }
    }
    }


@@ -118,7 +122,7 @@ public class CLI {
        }
        }


        Properties properties = new Properties();
        Properties properties = new Properties();
        try (InputStream in = new FileInputStream(config)) {
        try ( InputStream in = new FileInputStream(config)) {
            properties.load(in);
            properties.load(in);
        } catch (IOException ex) {
        } catch (IOException ex) {
            throw new UncheckedIOException(ex);
            throw new UncheckedIOException(ex);
@@ -141,7 +145,7 @@ public class CLI {
            System.exit(1);
            System.exit(1);
        }
        }


        try (InputStream in = new FileInputStream(tokenFile)) {
        try ( InputStream in = new FileInputStream(tokenFile)) {
            java.util.Scanner s = new java.util.Scanner(in).useDelimiter("\\A");
            java.util.Scanner s = new java.util.Scanner(in).useDelimiter("\\A");
            token = s.next().trim();
            token = s.next().trim();
        } catch (IOException ex) {
        } catch (IOException ex) {

gms-client/gms-client-lib/pom.xml

deleted100644 → 0
+0 −32
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<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>
    <groupId>it.inaf.ia2</groupId>
    <artifactId>gms-client-lib</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>12</maven.compiler.source>
        <maven.compiler.target>12</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-to-slf4j</artifactId>
            <version>2.12.1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.23.4</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
 No newline at end of file
Loading