Produced by Araxis Merge on 4/2/2019 1:06:54 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | C:\AraxisMergeCompare\Pri_un\ARS_Backend\ars_app\src\main\java\gov\va\med\ars\controller | AuthenticatorController.java | Wed Mar 27 19:21:10 2019 UTC |
2 | C:\AraxisMergeCompare\Pri_re\ARS_Backend\ars_app\src\main\java\gov\va\med\ars\controller | AuthenticatorController.java | Thu Mar 28 17:50:40 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 408 |
Changed | 1 | 2 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | package go v.va.med.a rs.control ler; | |
2 | ||
3 | import jav a.util.Lis t; | |
4 | ||
5 | import org .apache.lo gging.log4 j.LogManag er; | |
6 | import org .apache.lo gging.log4 j.Logger; | |
7 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
8 | import org .springfra mework.bea ns.factory .annotatio n.Value; | |
9 | import org .springfra mework.htt p.HttpStat us; | |
10 | import org .springfra mework.htt p.Response Entity; | |
11 | import org .springfra mework.web .bind.anno tation.Req uestMappin g; | |
12 | import org .springfra mework.web .bind.anno tation.Req uestMethod ; | |
13 | import org .springfra mework.web .bind.anno tation.Req uestParam; | |
14 | import org .springfra mework.web .bind.anno tation.Res tControlle r; | |
15 | ||
16 | import gov .va.med.ar s.exceptio ns.Generic Exception; | |
17 | import gov .va.med.ar s.model.re sponse.Use rInfoRespo nse; | |
18 | import gov .va.med.ar s.model.re sponse.Ver sionInfoRe sponse; | |
19 | import gov .va.med.ar s.service. IAuthentic atorServic e; | |
20 | import net .minidev.j son.JSONOb ject; | |
21 | ||
22 | /** | |
23 | * This is a control ler that w ill handle the User Authentica tion and s end Roles | |
24 | * of the User | |
25 | * | |
26 | */ | |
27 | ||
28 | @RestContr oller | |
29 | @RequestMa pping("/ap i/v1") | |
30 | public cla ss Authent icatorCont roller { | |
31 | ||
32 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(Auth enticatorC ontroller. class); | |
33 | ||
34 | @A utowired | |
35 | IA uthenticat orService authentica torService ; | |
36 | ||
37 | @V alue("${ve rsion.ars} ") | |
38 | St ring versi onArs; | |
39 | ||
40 | /* * | |
41 | * This meth od return the list o f UserRole s | |
42 | * | |
43 | * @param gu id | |
44 | * @return R esponseEnt ity<List<U serRoles>> | |
45 | * @throws G enericExce ption | |
46 | * / | |
47 | ||
48 | @R equestMapp ing(value = "/roles" , method = RequestMe thod.GET, produces = "applicat ion/json") | |
49 | pu blic Respo nseEntity< UserInfoRe sponse> ge tUserRoles (@RequestP aram Strin g guid) th rows Gener icExceptio n { | |
50 | logg er.info("g etUserRole s : " + "g etting use rroles for " + guid) ; | |
51 | ||
52 | try { | |
53 | // Aut henticate the User F irst | |
54 | //bool ean isAuth enticated = authenti catorServi ce.authent icate(guid ); | |
55 | UserIn foResponse userRoles Response; | |
56 | //if ( isAuthenti cated) { | |
57 | // Get U serRoles | |
58 | userRole sResponse = authenti catorServi ce.getUser Roles(guid ); | |
59 | if (user RolesRespo nse != nul l && !(use rRolesResp onse.getUs erRoles(). isEmpty()) ) { | |
60 | return new ResponseE ntity<>(us erRolesRes ponse, Htt pStatus.OK ); | |
61 | } else { | |
62 | logger.war n("getUser Roles : 0 Roles foun d for " + guid); | |
63 | return new ResponseE ntity<>(Ht tpStatus.F ORBIDDEN); | |
64 | } | |
65 | /*} el se { | |
66 | logger.e rror("getU serRoles : Authentic ation fail ed for GUI D: " + gui d); | |
67 | throw ne w GenericE xception(" ", "", Htt pStatus.FO RBIDDEN); | |
68 | }*/ | |
69 | } ca tch (Gener icExceptio n u) { | |
70 | logger .error("ge tUserRoles : Excepti on is rais ed "); | |
71 | throw u; | |
72 | } | |
73 | ||
74 | } | |
75 | ||
76 | /* * | |
77 | * This meth od return the list o f UserRole s | |
78 | * | |
79 | * @param us erName | |
80 | * @return R esponseEnt ity<List<U serRoles>> | |
81 | * @throws G enericExce ption | |
82 | * / | |
83 | @R equestMapp ing(value = "/userRo les", meth od = Reque stMethod.G ET, produc es = "appl ication/js on") | |
84 | pu blic Respo nseEntity< ?> authent icateAndge tRoles(@Re questParam String us erName) th rows Gener icExceptio n { | |
85 | logg er.info("a uthenticat eAndgetRol es : " + " getting us erroles fo r " + user Name); | |
86 | ||
87 | try { | |
88 | // Aut henticate the User F irst | |
89 | //bool ean isAuth enticated = authenti catorServi ce.authent icateUser( userName); | |
90 | UserIn foResponse userRoles Response; | |
91 | JSONOb ject respo nse = null ; | |
92 | //if ( isAuthenti cated) { | |
93 | // Get U serRoles | |
94 | userRole sResponse = authenti catorServi ce.getUser Roles(user Name); | |
95 | if (user RolesRespo nse != nul l && !(use rRolesResp onse.getUs erRoles(). isEmpty()) ) { | |
96 | return new ResponseE ntity<>(us erRolesRes ponse, Htt pStatus.OK ); | |
97 | } else { | |
98 | response = new JSONO bject(); | |
99 | logger.war n("getUser Roles : 0 Roles foun d for " + userName); | |
100 | response.p ut("errorC ode", "Un- Authorized "); | |
101 | response.p ut("messag e", "The e ntered use r has no a ccess to t he applica tion"); | |
102 | return new ResponseE ntity<>(re sponse, Ht tpStatus.N OT_FOUND); | |
103 | } | |
104 | /*} el se { | |
105 | response = new JSO NObject(); | |
106 | logger.err or("getUse rRoles : A uthenticat ion failed for userN ame: AI + userNam e); | |
107 | response .put("erro rCode", "I nvalid Use r"); | |
108 | response .put("mess age", "The entered u ser has no access to the appli cation"); | |
109 | return n ew Respons eEntity<>( response, HttpStatus .NOT_FOUND ); | |
110 | }*/ | |
111 | } ca tch (Gener icExceptio n u) { | |
112 | logger .error("ge tUserRoles : Excepti on is rais ed "); | |
113 | throw u; | |
114 | } | |
115 | ||
116 | } | |
117 | ||
118 | /* | |
119 | * returns t he list of users wit h differen t roles | |
120 | * / | |
121 | @R equestMapp ing(value = "/users" , method = RequestMe thod.GET, produces = "applicat ion/json") | |
122 | pu blic Respo nseEntity< ?> getUser s() { | |
123 | logg er.info("g et all use rs method request re cieved "); | |
124 | Resp onseEntity <?> respon se = null; | |
125 | try { | |
126 | List<S tring> use rs = authe nticatorSe rvice.getU sers(); | |
127 | respon se = new R esponseEnt ity<List<S tring>>(us ers, HttpS tatus.OK); | |
128 | logger .info("get all users " + users ); | |
129 | } ca tch (Excep tion e) { | |
130 | logger .error("Er ror occure d getting userroles : " + e.ge tMessage() ); | |
131 | } | |
132 | retu rn respons e; | |
133 | } | |
134 | ||
135 | @R equestMapp ing(value = "/versio n", method = Request Method.GET , produces = "applic ation/json ") | |
136 | pu blic Respo nseEntity< ?> getVers ion() { | |
137 | logg er.info("i nside /api /v1/versio n"); | |
138 | ||
139 | if ( isNullish( versionArs )) { | |
140 | versio nArs = "N/ A"; | |
141 | } | |
142 | ||
143 | Vers ionInfoRes ponse vers ionInfoRes ponse = ne w VersionI nfoRespons e(versionA rs); | |
144 | ||
145 | retu rn new Res ponseEntit y<>(versio nInfoRespo nse, HttpS tatus.OK); | |
146 | ||
147 | } | |
148 | ||
149 | pr ivate bool ean isNull ish(String str) { | |
150 | retu rn str == null || st r.trim().i sEmpty(); | |
151 | } | |
152 | ||
153 | /* * | |
154 | * This meth od return the User D etails | |
155 | * | |
156 | * @param us erName | |
157 | * @return R esponseEnt ity<UserDe tailsRespo nse> | |
158 | * @throws G enericExce ption | |
159 | * / | |
160 | ||
161 | /* *//* * | |
162 | * Get authentic ation para m's that a re require d to invok e third pa rty servic e | |
163 | * | |
164 | * @pa ram reques t | |
165 | * Ht tp servlet request o bject | |
166 | * @re turn Authe ntication parameters (encrypte dDefaultUr l, encrypt edPostBack Url, | |
167 | * sessi onId, aspC heckPageUr l and erro rPageUrl) | |
168 | * @th rows Gener icExceptio n | |
169 | *//* | |
170 | * @Requ estMapping (value="/a uthParams" ,method = RequestMet hod.GET, p roduces = | |
171 | * "appl ication/js on") publi c Response Entity<Aut henticatio nParamResp onse> | |
172 | * getAu thParams(H ttpServlet Request re quest) thr ows Generi cException { | |
173 | * logge r.info("Re ceived the request f or authPar am"); Stri ng session Id = | |
174 | * getSe ssionId(re quest); Au thenticati onParamRes ponse | |
175 | * authe nticationP aramRespon se = null; try { aut henticatio nParamResp onse = | |
176 | * authe nticatorSe rvice.getA uthParams( sessionId) ; } catch (Exception e) { | |
177 | * logge r.error("E rror in ge tting auth params" + e); e.pri ntStackTra ce(); } | |
178 | * | |
179 | * retur n new | |
180 | * Respo nseEntity< Authentica tionParamR esponse>(a uthenticat ionParamRe sponse, | |
181 | * HttpS tatus.OK); } | |
182 | */ | |
183 | ||
184 | /* *//* * | |
185 | * Thi s service is added t o get the latest sta tion and c laim count details f or | |
186 | * the logged-in user | |
187 | * | |
188 | * @pa ram userNa me | |
189 | * @re turn | |
190 | * @th rows Gener icExceptio n | |
191 | *//* | |
192 | * @Requ estMapping (value="/r efreshStat s/{userNam e}", metho d = Reques tMethod.GE T, | |
193 | * produ ces = "app lication/j son") publ ic Respons eEntity<Us erStationD etails> | |
194 | * getUp datedStats (@PathVari able Strin g userName ) throws G enericExce ption { | |
195 | * logge r.info("Re ceived the request t o get the updated co unts for u serName " | |
196 | * +user Name); try { UserSta tionDetail s userStat ionDetails = | |
197 | * authe nticatorSe rvice.getU pdatedUser StationDet ails(userN ame); retu rn new | |
198 | * Respo nseEntity< >(userStat ionDetails ,HttpStatu s.OK); } c atch(Gener icExceptio n | |
199 | * e) { logger.err or("getUpd atedStats : Exceptio n is raise d "); thro w e; } } | |
200 | * | |
201 | * priva te String getSession Id(HttpSer vletReques t hreq){ H ttpSession session = | |
202 | * hreq. getSession (); return session.g etId() + s ession.has hCode(); } | |
203 | */ | |
204 | ||
205 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.