library/roles/smartgears/smartgears: New TokenGenerator. Fix the container.xml template.

This commit is contained in:
Andrea Dell'Amico 2016-10-04 16:58:05 +02:00
parent 6a1ae88190
commit b7776c583a
4 changed files with 22 additions and 17 deletions

View File

@ -48,7 +48,7 @@ smartgears_context:
- '/ScalableDataMining'
smartgears_scopes:
- '{{ smartgears_infrastructure_name }}'
- '/{{ smartgears_infrastructure_name }}'
# The iptables rules use this
http_port: '{{ smartgears_http_port }}'

View File

@ -10,12 +10,13 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
public class TokenGenerator {
//call with parameters : host port filePath adminToken1 ... adminTokenN
//call with parameters : token host port filePath scope1 ... scopeN
public static void main(String[] args) {
String host = args[0];
int port = Integer.parseInt(args[1]);
File file = new File(args[2]);
String adminToken = args[1];
int port = Integer.parseInt(args[2]);
File file = new File(args[3]);
try {
@ -30,13 +31,14 @@ public class TokenGenerator {
AuthorizationProxy proxy = authorizationService();
try(FileWriter fw = new FileWriter(file)){
for (int index =3; index<args.length; index++ ){
SecurityTokenProvider.instance.set(args[index]);
for (int index =4; index<args.length; index++ ){
SecurityTokenProvider.instance.set(adminToken);
try {
String token = proxy.requestActivation(containerInfo);
String token = proxy.requestActivation(containerInfo, args[index] );
fw.write("<token>"+token+"</token>");
} catch (Exception e) {
System.out.println("error generating token for context "+args[index]);
e.printStackTrace();
} finally{
SecurityTokenProvider.instance.reset();
}
@ -49,4 +51,3 @@ public class TokenGenerator {
}
}

View File

@ -8,6 +8,10 @@
{% else %}
<port>{{ http_port }}</port>
{% endif %}
{% else %}
{%if http_port is defined %}
<port>{{ http_port }}</port>
{% endif %}
{% endif %}
{% else %}
<port>{{ item.http_port }}</port>