forked from ISTI-ansible-roles/ansible-roles
library/roles/smartgears/smartgears: New TokenGenerator. Fix the container.xml template.
This commit is contained in:
parent
6a1ae88190
commit
b7776c583a
|
@ -48,7 +48,7 @@ smartgears_context:
|
||||||
- '/ScalableDataMining'
|
- '/ScalableDataMining'
|
||||||
|
|
||||||
smartgears_scopes:
|
smartgears_scopes:
|
||||||
- '{{ smartgears_infrastructure_name }}'
|
- '/{{ smartgears_infrastructure_name }}'
|
||||||
|
|
||||||
# The iptables rules use this
|
# The iptables rules use this
|
||||||
http_port: '{{ smartgears_http_port }}'
|
http_port: '{{ smartgears_http_port }}'
|
||||||
|
|
Binary file not shown.
|
@ -10,12 +10,13 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
|
||||||
public class TokenGenerator {
|
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) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
String host = args[0];
|
String host = args[0];
|
||||||
int port = Integer.parseInt(args[1]);
|
String adminToken = args[1];
|
||||||
File file = new File(args[2]);
|
int port = Integer.parseInt(args[2]);
|
||||||
|
File file = new File(args[3]);
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -30,13 +31,14 @@ public class TokenGenerator {
|
||||||
AuthorizationProxy proxy = authorizationService();
|
AuthorizationProxy proxy = authorizationService();
|
||||||
|
|
||||||
try(FileWriter fw = new FileWriter(file)){
|
try(FileWriter fw = new FileWriter(file)){
|
||||||
for (int index =3; index<args.length; index++ ){
|
for (int index =4; index<args.length; index++ ){
|
||||||
SecurityTokenProvider.instance.set(args[index]);
|
SecurityTokenProvider.instance.set(adminToken);
|
||||||
try {
|
try {
|
||||||
String token = proxy.requestActivation(containerInfo);
|
String token = proxy.requestActivation(containerInfo, args[index] );
|
||||||
fw.write("<token>"+token+"</token>");
|
fw.write("<token>"+token+"</token>");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("error generating token for context "+args[index]);
|
System.out.println("error generating token for context "+args[index]);
|
||||||
|
e.printStackTrace();
|
||||||
} finally{
|
} finally{
|
||||||
SecurityTokenProvider.instance.reset();
|
SecurityTokenProvider.instance.reset();
|
||||||
}
|
}
|
||||||
|
@ -49,4 +51,3 @@ public class TokenGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<port>{{ http_port }}</port>
|
<port>{{ http_port }}</port>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{%if http_port is defined %}
|
||||||
|
<port>{{ http_port }}</port>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<port>{{ item.http_port }}</port>
|
<port>{{ item.http_port }}</port>
|
||||||
|
|
Loading…
Reference in New Issue