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.
|
@ -1,44 +1,46 @@
|
||||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.gcube.common.authorization.client.proxy.AuthorizationProxy;
|
import org.gcube.common.authorization.client.proxy.AuthorizationProxy;
|
||||||
import org.gcube.common.authorization.library.provider.ContainerInfo;
|
import org.gcube.common.authorization.library.provider.ContainerInfo;
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
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 {
|
||||||
file.createNewFile();
|
file.createNewFile();
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
System.out.println("error creating file "+file.getAbsolutePath());
|
System.out.println("error creating file "+file.getAbsolutePath());
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
ContainerInfo containerInfo = new ContainerInfo(host, port);
|
ContainerInfo containerInfo = new ContainerInfo(host, port);
|
||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -49,4 +51,3 @@ public class TokenGenerator {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,16 @@
|
||||||
|
|
||||||
<hostname>{{ smartgears_hostname }}</hostname>
|
<hostname>{{ smartgears_hostname }}</hostname>
|
||||||
{%if setup_nginx %}
|
{%if setup_nginx %}
|
||||||
{%if https_port is defined %}
|
{% if https_port is defined %}
|
||||||
{% if http_redirect_to_https is defined and http_redirect_to_https %}
|
{% if http_redirect_to_https is defined and http_redirect_to_https %}
|
||||||
<port>{{ https_port }}</port>
|
<port>{{ https_port }}</port>
|
||||||
{% 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