From 9714cc66eed386cdbcf45deab6b61882e2600775 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 30 Sep 2016 18:35:44 +0200 Subject: [PATCH] library/roles/smartgears/smartgears/files/TokenGenerator.java: New version of the token generator. --- .../smartgears/files/TokenGenerator.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/smartgears/smartgears/files/TokenGenerator.java b/smartgears/smartgears/files/TokenGenerator.java index ba92ce10..188c92eb 100644 --- a/smartgears/smartgears/files/TokenGenerator.java +++ b/smartgears/smartgears/files/TokenGenerator.java @@ -1,3 +1,5 @@ +import static org.gcube.common.authorization.client.Constants.authorizationService; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -6,16 +8,15 @@ import org.gcube.common.authorization.client.proxy.AuthorizationProxy; import org.gcube.common.authorization.library.provider.ContainerInfo; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; -import static org.gcube.common.authorization.client.Constants.authorizationService; - public class TokenGenerator { + //call with parameters : host port filePath adminToken1 ... adminTokenN public static void main(String[] args) { - String adminToken = args[0]; - String host = args[1]; - int port = Integer.parseInt(args[2]); - File file = new File(args[3]); + String host = args[0]; + int port = Integer.parseInt(args[1]); + File file = new File(args[2]); + try { file.createNewFile(); @@ -24,19 +25,20 @@ public class TokenGenerator { e1.printStackTrace(); } - SecurityTokenProvider.instance.set(adminToken); - ContainerInfo containerInfo = new ContainerInfo(host, port); AuthorizationProxy proxy = authorizationService(); try(FileWriter fw = new FileWriter(file)){ - for (int index =4; index"+token+""); } catch (Exception e) { System.out.println("error generating token for context "+args[index]); + } finally{ + SecurityTokenProvider.instance.reset(); } } } catch (Exception e) { @@ -44,10 +46,7 @@ public class TokenGenerator { e.printStackTrace(); } - - } } -