From f70b7ab46369738f53b12b901fe18d8d3e6f27fd Mon Sep 17 00:00:00 2001 From: Lance Lafontaine Date: Sat, 24 Mar 2018 14:46:23 -0400 Subject: [PATCH 1/4] Adds whitespace, rip --- README.md | 1 + build.gradle | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 663e7ee..9e29045 100644 --- a/README.md +++ b/README.md @@ -179,3 +179,4 @@ Centralize configuration for all micro services. - [Spring cloud bootstrap](https://github.com/eugenp/tutorials/tree/master/spring-cloud/spring-cloud-bootstrap) - [Securing cloud services](http://www.baeldung.com/spring-cloud-securing-services) + diff --git a/build.gradle b/build.gradle index 3b319c2..dbd5ac2 100644 --- a/build.gradle +++ b/build.gradle @@ -42,4 +42,4 @@ subprojects { maven { url 'https://repo.spring.io/libs-snapshot' } } -} \ No newline at end of file +} From dc3fa96b4c8196b87e3f4e3ea127374cdd4faa3a Mon Sep 17 00:00:00 2001 From: Lance Lafontaine Date: Sat, 24 Mar 2018 14:52:21 -0400 Subject: [PATCH 2/4] Also adds my failure to the readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 9e29045..f221c54 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Java micro-services +BATTLESTARCONCORDIA_SERVICES_HOUR1 +- [x] Adds whitespace, rip + ## Build build all projects ``` From cdc5a9222ffe59fb7ce1dbc0af582f991be61fd2 Mon Sep 17 00:00:00 2001 From: Jacob Gagne Date: Sat, 24 Mar 2018 15:53:03 -0400 Subject: [PATCH 3/4] hour 2 gg --- .../com/ship/authorization/ActionDto.class | Bin 0 -> 651 bytes .../AuthorizationApplication.class | Bin 0 -> 1268 bytes .../ForbiddenAccessException.class | Bin 0 -> 519 bytes .../ship/authorization/SecurityConfig.class | Bin 0 -> 2969 bytes .../com/ship/authorization/SessionConfig.class | Bin 0 -> 569 bytes .../controller/AuthorizationController.class | Bin 0 -> 2935 bytes .../authorization/service/UsersService.class | Bin 0 -> 1402 bytes .../out/production/resources/bootstrap.yml | 12 ++++++++++++ .../controller/AuthorizationController.java | 6 +++--- .../authorization/service/UsersService.java | 15 +++++++++++++++ .../controller/MessageController.java | 17 +++++++++++++++-- .../src/main/resources/application.yml | 2 +- 12 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 authorization/out/production/classes/com/ship/authorization/ActionDto.class create mode 100644 authorization/out/production/classes/com/ship/authorization/AuthorizationApplication.class create mode 100644 authorization/out/production/classes/com/ship/authorization/ForbiddenAccessException.class create mode 100644 authorization/out/production/classes/com/ship/authorization/SecurityConfig.class create mode 100644 authorization/out/production/classes/com/ship/authorization/SessionConfig.class create mode 100644 authorization/out/production/classes/com/ship/authorization/controller/AuthorizationController.class create mode 100644 authorization/out/production/classes/com/ship/authorization/service/UsersService.class create mode 100644 authorization/out/production/resources/bootstrap.yml diff --git a/authorization/out/production/classes/com/ship/authorization/ActionDto.class b/authorization/out/production/classes/com/ship/authorization/ActionDto.class new file mode 100644 index 0000000000000000000000000000000000000000..1c44ba2afb44a990042e470a0663fec7a23ac246 GIT binary patch literal 651 zcmaiw%}&BV6ot=}Qf#e&{OnrKX1_y9hX z@eXZ3#l+3rdnaek`R0CnzP$rD!L9=nRU0|f3aA&b!(b;Olv61p#oz@ae$V|ej|P5M zB{CYEGFWFalB&&+YczWd=0$ub7)pVR#MOM#7s)N}kLkt>;*gJfJdt|NE=@I*Glqj8 zj3@qVD5pN3t6`kT2d-os`RAc7mnx>9T4Oz4C%OZnZdQ=hMsr<9s@V^f(~ajzC^}N3 z6_+tb`hzYC*l>}D#jy7u7(;orlC^@tQfjTE4O)jUFjg)_3J0l7^0UcDJJnNl=A@G} zmWC*yoO$|-SwlU;c%(-ul$L>l{{q@x0<|+B>laM=C6D4N-$1M-h_wXq7KxQFEqre3 literal 0 HcmV?d00001 diff --git a/authorization/out/production/classes/com/ship/authorization/AuthorizationApplication.class b/authorization/out/production/classes/com/ship/authorization/AuthorizationApplication.class new file mode 100644 index 0000000000000000000000000000000000000000..0805de10b1fcf3721233a09b3001befef2b72a2b GIT binary patch literal 1268 zcmb7DO>Yx15Pfc%ZV7>wv;+ziD4%H%SV#y|1yyPaoFXbURXK3-ZrsFW*Nz--3;Zg$ z0OG(8;71|Go0KlnMuI(fJ>z*Z&oj?Ie|`S};0YQPlyNn{wF*{oy@DIK8DNcJ?zz&+ zZ8DS^>-!9|+omTO7CK7H*J%<;yC=e!JhhIAM7%Go^7h0z>jrAX@VFD1gpUSl$VKV~ z#;T9PDWmyT-r5=tV-;lwEh>}JnYNsmhN!wa4L{0$_?I0Wj z88!-$|5B4-WjEDMC30Vl6m@e;YvZ!U(2XA!=8cSY^1b8YPbhCop@~tYYf>A@SISRm zby~+C`6e@L7ADU~)8q_QIZ*x7O5V+S*`^NuJ+^jXf+#j=@1)H=HHyrUv>*6O?X~ja z#NN)v(5hk%0R#U}%>=kr#ckXPaJPzkxX-Y7Dx970P)3fSIaLSa3*|0Dinl2#Flyuk zIL^~55M8lQPR6o5X`H`rt_HdN)M!f2rV^W?wTVC(%9-M*UyWi4Q}8XUVTPW(|4N{D zj)2yAvN-)2{mad-V4rC-gEO?wWzH%pw6Bf>aF%wU({nga9uIy>(H=Zsn`wSS>CGv= zLMOlim08T?m?zI7`57*tMiD;823bC~{NM{_KhY*nU^xTV#{m-p6pAG*6YL^Id!qFW QbtzjfXI@`^h3qT9Z~kCtng9R* literal 0 HcmV?d00001 diff --git a/authorization/out/production/classes/com/ship/authorization/ForbiddenAccessException.class b/authorization/out/production/classes/com/ship/authorization/ForbiddenAccessException.class new file mode 100644 index 0000000000000000000000000000000000000000..505b523ae483969729162019471e74c585a4a840 GIT binary patch literal 519 zcmb7B!Ab)$5S_H$*4EZ))q{cu4}y9y2p$AQsJ2C6snAOA+1=P3-A$Hcw-x`&li36e0_g>0>Bw;H=qoi8f?~Ji$V1g6{c4V%7;f229+BfNCs^e zl^kZVC(VQKB4RqO_C+)i26KNwR?-kHgHzYnF}EQmTx4me4ZeyLwc-P9JPZP_druCLfF@2@qDv ZupOvFqlm8-*n}4CEsCwtYD-v$jUVNZjw=8F literal 0 HcmV?d00001 diff --git a/authorization/out/production/classes/com/ship/authorization/SecurityConfig.class b/authorization/out/production/classes/com/ship/authorization/SecurityConfig.class new file mode 100644 index 0000000000000000000000000000000000000000..4d54313a098bd142553b7fb4cf47219a42273ffd GIT binary patch literal 2969 zcmcguOLH4V5dOxNz45Xku@js)fCC{9TX}2@Ap{&8Y}tuzq&)1zIdK@R#?l07SD9J) z!G$Ug{2wl&iUXB1KZ>GfSJJMG;)1cG;&Ls2`f@FT+4ew&D9lIcX=bM1WNwGLmBw) zw(uHChKISp-<4&GcG`EKqT69`Jq+vZ zGm9CkkcMHiC%R*f=MPvO3ca7njJbSA35%JRc-pn})b5)_hZ^FGaB( zfS9`5(=FMB;vh`Z8-r=6$kn2Q)0njIy@Mq@aPR|`Evz`mVU=OM&)R(}F%H)7(841J z>)5pLqk}vO79KOa9w0=U3)2>B2X!U1rZRk?s-{Oe{n<`asLO4=DA6W{lSgD{!}o>C zRk_weJ9vUk2T!r;;2E|UuDnzGGyF6}Ch@7J&NBhOT;lamC@LmXJ#LlzWlFl$dJJBl zQF+%GNt(k@l8l}1@xm}I{eq}bn|5zw_;qf+XW1RoJx36v53{adP?CueFu@|G%1e2x$4nrQw;LH93A(sPO=m)?xt zW7$8!{-DJO&d_r_QaU(GYbV}-k1$OV!#SKMC&qY*q!F|GdJ`ir6KgxtPSX8yD)KNL z?`nB4-e+)uY(FO3481?Wr^XAdW+Tl-d`1=~!d@#vmLiNck$Ho$CdQkvqQ!|OCf>kq z;)5ofNOLlUVip#8m?jVB=+1kd@|q#(0xnYAd5URri;-nJ$g)J#C9+76jp7U1H-gI% bMw8hUlCRS5F8!uRw(%9dCYuF%Z-D&=*%reb literal 0 HcmV?d00001 diff --git a/authorization/out/production/classes/com/ship/authorization/SessionConfig.class b/authorization/out/production/classes/com/ship/authorization/SessionConfig.class new file mode 100644 index 0000000000000000000000000000000000000000..aafc06de3adedffdd89f983d7800267774741951 GIT binary patch literal 569 zcma)3O-lnY5S{c>*J`z%JPIP}!Cb^kMJPp4SOia867A#4hju284}}xl$RXOi771N0HIV_2oJ;wY%KPr+X*Y!D+S?7NK$XG4 ze?EZ0{i+5QI&!K-Go8RXBSN=C)k)JB!=j~Iniz^0r_#ValxUp!VzfyN*%~2UV1Vk$ mJFqtjl%P(wMqz+;SR>mg&Q(HQalcX625ge|D1VE56W|A=C8l8j literal 0 HcmV?d00001 diff --git a/authorization/out/production/classes/com/ship/authorization/controller/AuthorizationController.class b/authorization/out/production/classes/com/ship/authorization/controller/AuthorizationController.class new file mode 100644 index 0000000000000000000000000000000000000000..82a7734ae9ed69688a89238a4ccac7c67aa3c8dd GIT binary patch literal 2935 zcmbVOS#uOs7(F+cOiyN-MIewUNJPc3ghm8`1dtFCK!-`3fgqq_PtPT3GSeNpdlG`; zzM(!_1%JR7U$m@Hkt*@o7t1HBB97w;jHr23313&MY!W$~O5k(~F^s8`GYPzr#95qc$3~n_ zLg38=-b&$ZTu9*^m}&#&%SB~w(A(wQX0nTI`w{mu58%}?2;U_eLG*21CHYcp@A>3FYS8c zhCk)m&iF;oEXf(yn>6y$bbRBYX$7t~YnW97W1t+kGqxuSbQ?clJ9cnLptWbqm_TgM zEikziY1@&Raw#vpQzoMctV+9Bv0Nwc++tCBDrW7DgVl3p zkg_JEH925e(x0-Ks4Si1s&QUp3G1Jf>spfC02 zjW{WTLSzuqsbb9F%RFh>Q#KRIy3zAqGN(JvDO1Z$aCQq7E;d8TeG!!+I zn(=K$=8e4V6zZv#m6yxX59nhm^4T_R7R%(5ZZtf5yd=qwg23J-p?r|*(2&{2Mn`g| z2xViPjGC$*0_imr%$~=Ma>OmnGDb4zmOV=j+X}PwO*p+nLHT$f`9VWTYpyPRL z*5K%HF(t77f3rfvWgQ+!t#ymJaHMP(3({k^P)(_?TStJhj%m#3xPloCvpTNgU4gYq z-aTRZ-Ks>`(*j%iO8-4vQ%3KT#n}bs^>u6bK*xv5%QM)d<0E{`5Q>mW^ofp7@frE1 z<8yqW<4bkDT@SzB;)2z29Wx|cb|gJ?VK6&%=Hx(zMAq>YzEYymS_-X zX-kKd+uKv;uhK*6LqtavD$!75J{i{L;#4Z80*Szl)&i@;OdDgZP7IgszRckyLqXk z@5hk%)EH39nE2RLI;?HD)&flw$gIVTyu$b6_x&83q!Vrw7Zz~gcQDQ_ZK{t-1C9$A zoMUxv(intmGiUQ#W_F6xrH-(5XTp|GdK&*ZCh`l<%dw*!%-=Nze8I%>X8Dr zVjFh?+tG_wWh}07)_8Vz+dNtYenl+vBie2we)bl$Rf##YQ;-zkVh*V}=ylR%JnWsv zawT1HpL8Xq+vo5^)pF}kSQQ+$J=?V+a1ki};Hc3cf=GQ^|G^>p1s!D?qB%PU>&Bf2Q!W$fi&?LNxap!FWU)v#YfpN9T_aQJU(t5@x${Q<5Io`>)m>lMxthcSR7 Vl(x5U5E$gxf}`O$R3*bO@E^$1S&RSx literal 0 HcmV?d00001 diff --git a/authorization/out/production/classes/com/ship/authorization/service/UsersService.class b/authorization/out/production/classes/com/ship/authorization/service/UsersService.class new file mode 100644 index 0000000000000000000000000000000000000000..242f9fbeba3f15acc61e99738489636bd0a5e7ad GIT binary patch literal 1402 zcmb7DYi|=r6g}gZ?8Mo;76?#Y;n_S2%e&Boz~Y!-$#IaK81+*%ai-2td)Mp(M1NJ0 zs1U7$_{@(&oLw7r(})jz@aUei_ntZT-tni;|9k*&3r|WohMN{{l~BOVF^uB2#2pJi zOB^4^UEGuSMdGByvcxHg6^YXl_a)9qtV*1fcpx#CCO)*_S$HI1H#TdP-@LVrYQw7u zIJM{MrET8vTz*I)ms+H}nO5Lk(35;hiqQ z{6T9A2PpxWPQq6`)|8q-61MeYlM2k_^{=K|6FAXG{Mht#%S48TJ>L)F%oP33*MhL) zM*VcBzlYR&6@-7dQLIB9#IO6>{c6?5C0wR{_7JkcKT**hhi~H?&I?#-w`W4t6v}<${YoBk9+tPl-o%7~)s9!O~#$&7t zO#lC>?xQw$p6fQNC;sb$J#gjygzVk?_y?)Wx#i+7UPpSTw;7Ghi%5Eb9j>RnH-*Gd^U$2#&bD*gm-XVyzfGG-$i1PZkFed zWIkeq5fCoEgIN3*g>zWf!Wvx7=2n24 ROLE_VALUES.get(grantedAuthority.getAuthority()) + 1) { throw new ForbiddenAccessException(); } } diff --git a/authorization/src/main/java/com/ship/authorization/service/UsersService.java b/authorization/src/main/java/com/ship/authorization/service/UsersService.java index 66615d5..176c601 100644 --- a/authorization/src/main/java/com/ship/authorization/service/UsersService.java +++ b/authorization/src/main/java/com/ship/authorization/service/UsersService.java @@ -2,6 +2,7 @@ import org.springframework.stereotype.Service; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -16,6 +17,20 @@ public class UsersService { public static final String ROLE_ENSIGN = "ROLE_ENSIGN"; public static final String ROLE_CREWMAN = "ROLE_CREWMAN"; + public static final Map ROLE_VALUES; + + static { + Map aMap = new HashMap<>(); + aMap.put(ROLE_ADMIRAL, 6); + aMap.put(ROLE_VICE_ADMIRAL, 5); + aMap.put(ROLE_CAPTAIN, 4); + aMap.put(ROLE_COMMANDER, 3); + aMap.put(ROLE_LIEUTENANT, 2); + aMap.put(ROLE_ENSIGN, 1); + aMap.put(ROLE_CREWMAN, 0); + ROLE_VALUES = Collections.unmodifiableMap(aMap); + } + private Map users = new HashMap<>(); public UsersService() { diff --git a/communication/src/main/java/com/ship/communication/controller/MessageController.java b/communication/src/main/java/com/ship/communication/controller/MessageController.java index 1d3d87a..c3d805b 100644 --- a/communication/src/main/java/com/ship/communication/controller/MessageController.java +++ b/communication/src/main/java/com/ship/communication/controller/MessageController.java @@ -3,6 +3,8 @@ import com.ship.communication.model.Message; import com.ship.communication.model.resource.MessageResource; import com.ship.communication.repository.MessageRepository; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; @@ -16,13 +18,14 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.client.RestTemplate; -import javax.servlet.http.HttpSession; import java.util.stream.Collectors; import java.util.stream.StreamSupport; @RestController public class MessageController { + private Logger log = LoggerFactory.getLogger(this.getClass()); + @Autowired private DiscoveryClient discoveryClient; @@ -32,9 +35,19 @@ public class MessageController { @Autowired private MessageRepository messageRepository; + public Message findByRecipientAndSender(String r, String s, MessageRepository mr){ + // stub gg find da message + return null; + } + @RequestMapping(value = "/sendMessage", method = RequestMethod.POST) public Message sendMessage(@RequestBody Message message, @CookieValue("SESSION") String cookie) { - checkAccess(new ActionDto(message.getRecipient()), cookie); + // log message + log.info(message.getTitle().toUpperCase() + ": " + message.getContent()); + // allow the reply to a personal message + if(findByRecipientAndSender(message.getRecipient(), message.getSender()) === null) { + checkAccess(new ActionDto(message.getRecipient()), cookie); + } return messageRepository.save(message); } diff --git a/config-server/src/main/resources/application.yml b/config-server/src/main/resources/application.yml index 8a7b0bc..b716519 100644 --- a/config-server/src/main/resources/application.yml +++ b/config-server/src/main/resources/application.yml @@ -18,7 +18,7 @@ security.user: --- spring: profiles: native - cloud.config.server.native.search-locations: file:///${user.home}/Documents/wilau2/cs-games-2018-relay-cloud/config-server/config + cloud.config.server.native.search-locations: file:///${user.home}/Documents/relay/cs-games-2018-relay-cloud/config-server/config eureka: client: From aa487085317c6462200957bb5f77424bccf29367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobi=20D=C3=A9cary-Larocque?= Date: Sat, 24 Mar 2018 16:22:59 -0400 Subject: [PATCH 4/4] :see_no_evil: --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index f221c54..069ad32 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ BATTLESTARCONCORDIA_SERVICES_HOUR1 - [x] Adds whitespace, rip +^ + + ## Build build all projects ```