Produced by Araxis Merge on 12/7/2018 11:35:50 AM Central Standard 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:\SCRUB\MHED\MHED\VAR 4.10.0\var-resources-release-4.10@1091a011694\ResourceIntTest\src\resinttest\java\com\agilex\healthcare\veteranappointment\clientapi | JwtClient.java | Thu Oct 18 18:44:32 2018 UTC |
| 2 | C:\MHED-scrubbed\MHED\MHED\VAR 4.10.0\var-resources-release-4.10@1091a011694\ResourceIntTest\src\resinttest\java\com\agilex\healthcare\veteranappointment\clientapi | JwtClient.java | Fri Dec 7 17:02:35 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 200 |
| Changed | 2 | 4 |
| 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 co m.agilex.h ealthcare. veteranapp ointment.c lientapi; | |
| 2 | ||
| 3 | import jav a.io.DataO utputStrea m; | |
| 4 | import jav a.io.IOExc eption; | |
| 5 | import jav a.net.URL; | |
| 6 | import jav a.net.Http URLConnect ion; | |
| 7 | import jav a.net.Cook ieManager; | |
| 8 | import jav a.net.Cook ieHandler; | |
| 9 | import jav a.util.Ite rator; | |
| 10 | import jav a.util.Lis t; | |
| 11 | import jav a.util.Map ; | |
| 12 | import jav a.util.Set ; | |
| 13 | ||
| 14 | public cla ss JwtClie nt { | |
| 15 | privat e static H ttpURLConn ection con n; | |
| 16 | ||
| 17 | private fi nal String JWT_KEY_N AME = " DNS "; | |
| 18 | privat e final St ring HOST = "localho st:9000"; | |
| 19 | privat e final St ring LOGIN _URL = "ht tp://" + H OST + "/ss oeproxy/lo gin"; | |
| 20 | privat e final St ring FAKE_ URL = "htt p://" + HO ST + "/any where"; | |
| 21 | private fi nal String USER_NAME = " PW_reda c t e d "; | |
| 22 | privat e final St ring PASSW ORD = "pas s"; | |
| 23 | privat e final St ring LOGIN _PARAMS = "username= " + USER_N AME + | |
| 24 | "&password =" + PASSW ORD; | |
| 25 | ||
| 26 | public JwtClient () { | |
| 27 | } | |
| 28 | ||
| 29 | public String ge tJwt() thr ows IOExce ption { | |
| 30 | Co okieHandle r.setDefau lt(new Coo kieManager ()); | |
| 31 | ||
| 32 | do Login(); | |
| 33 | cl oseUrlConn ection(); | |
| 34 | do FakeReques t(); | |
| 35 | St ring jwtVa lue = getJ wtValue(); | |
| 36 | cl oseUrlConn ection(); | |
| 37 | ||
| 38 | re turn jwtVa lue; | |
| 39 | } | |
| 40 | ||
| 41 | privat e void doL ogin() thr ows IOExce ption { | |
| 42 | UR L url = ne w URL(LOGI N_URL); | |
| 43 | co nn = (Http URLConnect ion) url.o penConnect ion(); | |
| 44 | co nn.setUseC aches(fals e); | |
| 45 | co nn.setRequ estMethod( "POST"); | |
| 46 | co nn.setRequ estPropert y("Host", HOST); | |
| 47 | co nn.setRequ estPropert y("Connect ion", "kee p-alive"); | |
| 48 | co nn.setRequ estPropert y("Referer ", LOGIN_U RL); | |
| 49 | co nn.setRequ estPropert y("Content -Type", "a pplication /x-www-for m-urlencod ed"); | |
| 50 | co nn.setRequ estPropert y("Content -Length", Integer.to String(LOG IN_PARAMS. length())) ; | |
| 51 | co nn.setDoOu tput(true) ; | |
| 52 | ||
| 53 | Da taOutputSt ream dataO utputStrea m = new Da taOutputSt ream(conn. getOutputS tream()); | |
| 54 | da taOutputSt ream.write Bytes(LOGI N_PARAMS); | |
| 55 | da taOutputSt ream.flush (); | |
| 56 | da taOutputSt ream.close (); | |
| 57 | ||
| 58 | co nn.getResp onseCode() ; | |
| 59 | } | |
| 60 | ||
| 61 | privat e void doF akeRequest () throws IOExceptio n { | |
| 62 | UR L url = ne w URL(FAKE _URL); | |
| 63 | co nn = (Http URLConnect ion) url.o penConnect ion(); | |
| 64 | co nn.setRequ estMethod( "GET"); | |
| 65 | co nn.setUseC aches(fals e); | |
| 66 | co nn.getResp onseCode() ; | |
| 67 | } | |
| 68 | ||
| 69 | privat e String g etJwtValue () { | |
| 70 | St ring jwtVa lue = null ; | |
| 71 | ||
| 72 | Ma p<String, List<Strin g>> header s = conn.g etHeaderFi elds(); | |
| 73 | Se t<String> headerSet = headers. keySet(); | |
| 74 | It erator<Str ing> heade rIterator = headerSe t.iterator (); | |
| 75 | ||
| 76 | wh ile (heade rIterator. hasNext() && jwtValu e == null) { | |
| 77 | String k ey = heade rIterator. next(); | |
| 78 | ||
| 79 | if ("Set -Cookie".e qualsIgnor eCase(key) ) { | |
| 80 | List <String> h eaderValue s = header s.get(key) ; | |
| 81 | ||
| 82 | for (String he aderValue : headerVa lues) { | |
| 83 | String[] v alues = he aderValue. split("=|; "); | |
| 84 | ||
| 85 | if (values .length > 2 && value s[0].conta ins(JWT_KE Y_NAME)) { | |
| 86 | jwtVal ue = value s[1]; | |
| 87 | break; | |
| 88 | } | |
| 89 | } | |
| 90 | } | |
| 91 | } | |
| 92 | ||
| 93 | re turn jwtVa lue; | |
| 94 | } | |
| 95 | ||
| 96 | privat e void clo seUrlConne ction() { | |
| 97 | if (conn != null) { | |
| 98 | conn.dis connect(); | |
| 99 | conn = n ull; | |
| 100 | } | |
| 101 | } | |
| 102 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.