From b7776c583af364d23c5e03ebb86f0f632277ba30 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 4 Oct 2016 16:58:05 +0200 Subject: [PATCH] library/roles/smartgears/smartgears: New TokenGenerator. Fix the container.xml template. --- smartgears/smartgears/defaults/main.yml | 2 +- .../smartgears/files/TokenGenerator.class | Bin 2464 -> 2564 bytes .../smartgears/files/TokenGenerator.java | 31 +++++++++--------- .../smartgears/templates/container.xml.j2 | 6 +++- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/smartgears/smartgears/defaults/main.yml b/smartgears/smartgears/defaults/main.yml index 34625d8b..fd04f78a 100644 --- a/smartgears/smartgears/defaults/main.yml +++ b/smartgears/smartgears/defaults/main.yml @@ -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 }}' diff --git a/smartgears/smartgears/files/TokenGenerator.class b/smartgears/smartgears/files/TokenGenerator.class index 56247ca295c8272ea5f12265763f78585c3c021a..c4577b83387fd40552e29ba1a3480c857c70335c 100644 GIT binary patch delta 1167 zcmZ{jTWnNS6o$V&&dffy*6GdRFt$*}X=QpDU~17LB5i3YctHfTt=FMW=|F8usT40b zipYC&o=u37OkzR|n4B7$&^I3RMPE!BUVY-ln3x!iaa?DxUJ^YyS!?aJ*T2@k_g?Et z)1~I}SHFLG6Ug&{#RKfNc$h~tp2a;p8j3xd$4vI}xMrV)!ES?rP!EQiL!q_bVwe$& zI0rPN76}eo9O4PhlNL=pW%4wKEfLSy9N}4mqXx&qo#Wz6^PJ{+gE5QyIS_isH4_$F zdBNaC%}bh>mp__tU(viOw1kY*&=e%O#0k_-sLXJN4$TRNNnTSprwZo^xzb#2q%>1> z$RJ{hlZvK|jf01W&rcTT7fW-qnrVj;rxZ!QA)54;mAm;gGY+pa>oA7|%sZS3b1cx| zf2#)V3}-cq4sUSIZ;K>1WmwXjcX*Sx9NwlV>>S?Vg1;}4G~Nx7WkF6v_O`u8#|Dd; z!tBZ1vFU}mrNW7j<@;RxJc!&@eqU_WUygp_{}B5ywop7>7V$8-=q8UqiZ>-?H_79<46&I}dA_4;VN7cVud4O*fQaH8NYm04psNRU@0syVVS%gt;)UV S{|JRaNuQSfd`RLW^#1{Eq{y@Y delta 1102 zcmZ{i&2v*_6vlsVX!72BbHO%kfDE)XZDTcUjkH+xTB`C<()xiYSX+e}N`*o{G}fYs z#s#u>?#j`H!!Q$FxBzET$IgHoS;*RrjDG}68OQkC*hQVuOmaS-^PH1&-pg%Yw^n}n z>&KhG5TANww2W4tXRPb2&`W zlNh&5c%*pV;{{%{yyTJQNRpR1>hOxgtC4@qa=gRgwaA{dyzbG#l*6>gF2*cxSl;~n z>U8FW<)kLk93r*Mh)rPChG~=Q=^Uz3{7u|2RRaO|*~cJnu{G8ta91C=V-z`KE6$C+BgP3^9c%%|N!sTx~rY`g55 zYW7F>o_Z#;ws=Wn?3^S1~tG^j46J3bLCE+5%q%extx?6l9XO zsug+zyQ%$y>YHh*A>2m)2%5dF7rKkAmXy%xu2GfuE5Gr(9@`>!xVNG2YZnQVG~49g z<4@!>W4cUE_*i3$Wp*p}fcDlb&X$VIl#*$YXGFhUYu&*Cc2ZRIh;A`WCo{?}(xuit zT+yAb=>%0FzZK=rir*oxc3HK{n=S^_E^m72GY9E6fz NyY-s(YQz|i{|%Qgxr_h+ diff --git a/smartgears/smartgears/files/TokenGenerator.java b/smartgears/smartgears/files/TokenGenerator.java index 188c92eb..b42f8ed5 100644 --- a/smartgears/smartgears/files/TokenGenerator.java +++ b/smartgears/smartgears/files/TokenGenerator.java @@ -1,44 +1,46 @@ import static org.gcube.common.authorization.client.Constants.authorizationService; - + import java.io.File; import java.io.FileWriter; import java.io.IOException; - + import org.gcube.common.authorization.client.proxy.AuthorizationProxy; import org.gcube.common.authorization.library.provider.ContainerInfo; 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 host = args[0]; + String adminToken = args[1]; + int port = Integer.parseInt(args[2]); + File file = new File(args[3]); + + try { file.createNewFile(); } catch (IOException e1) { System.out.println("error creating file "+file.getAbsolutePath()); e1.printStackTrace(); } - + ContainerInfo containerInfo = new ContainerInfo(host, port); AuthorizationProxy proxy = authorizationService(); try(FileWriter fw = new FileWriter(file)){ - for (int index =3; index"+token+""); } catch (Exception e) { System.out.println("error generating token for context "+args[index]); + e.printStackTrace(); } finally{ - SecurityTokenProvider.instance.reset(); + SecurityTokenProvider.instance.reset(); } } } catch (Exception e) { @@ -49,4 +51,3 @@ public class TokenGenerator { } } - diff --git a/smartgears/smartgears/templates/container.xml.j2 b/smartgears/smartgears/templates/container.xml.j2 index 2f0a5b04..89f13a9a 100644 --- a/smartgears/smartgears/templates/container.xml.j2 +++ b/smartgears/smartgears/templates/container.xml.j2 @@ -2,12 +2,16 @@ {{ smartgears_hostname }} {%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 %} {{ https_port }} {% else %} {{ http_port }} {% endif %} + {% else %} + {%if http_port is defined %} + {{ http_port }} + {% endif %} {% endif %} {% else %} {{ item.http_port }}