Produced by Araxis Merge on 3/9/2018 10:32:16 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 | CIF_MHV_2018.2.0.0.zip\CIF_MHV_2018.2.0.0_Sprint2_SM_legacy.zip\mhv_sms_ng\mhv-sm-admin\src\main\java\gov\va\med\mhv\sm\web\actions | AuthenticateTest.java | Wed Feb 14 06:23:36 2018 UTC |
| 2 | CIF_MHV_2018.2.0.0.zip\CIF_MHV_2018.2.0.0_Sprint2_SM_legacy.zip\mhv_sms_ng\mhv-sm-admin\src\main\java\gov\va\med\mhv\sm\web\actions | AuthenticateTest.java | Thu Mar 8 19:54:19 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 236 |
| 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 go v.va.med.m hv.sm.web. actions; | |
| 2 | ||
| 3 | import org .apache.co mmons.logg ing.Log; | |
| 4 | import org .apache.co mmons.logg ing.LogFac tory; | |
| 5 | ||
| 6 | import gov .va.med.mh v.foundati on.service .response. ServiceRes ponse; | |
| 7 | import gov .va.med.mh v.foundati on.util.Lo gSanitizer ; | |
| 8 | import gov .va.med.mh v.sm.model .Administr ator; | |
| 9 | import gov .va.med.mh v.sm.model .MhvAuthen ticationSu bject; | |
| 10 | import gov .va.med.mh v.sm.model .decorator .MhvAuthen ticationSu bjectDecor ator; | |
| 11 | import gov .va.med.mh v.sm.servi ce.Authent icationSer vice; | |
| 12 | import gov .va.med.mh v.sm.util. MhvIntegra tionUtils; | |
| 13 | ||
| 14 | import com .opensymph ony.xwork2 .Preparabl e; | |
| 15 | ||
| 16 | public cla ss Authent icateTest extends Ba seSMAdminA ction impl ements Pre parable { | |
| 17 | ||
| 18 | pr ivate stat ic final l ong serial VersionUID = 1527699 2436766223 66L; | |
| 19 | ||
| 20 | pr ivate stat ic final L og LOG = L ogFactory. getLog(Aut henticateT est.class) ; | |
| 21 | ||
| 22 | pr ivate stat ic final S tring LOGI NFAILED_RE SULT = "LO GINFAILED" ; | |
| 23 | ||
| 24 | pr ivate Auth entication Service au thenticati onService = null; | |
| 25 | pr ivate MhvI ntegration Utils util s = null; | |
| 26 | ||
| 27 | pr ivate int userid = 0 ; | |
| 28 | ||
| 29 | pu blic void prepare() throws Exc eption { | |
| 30 | supe r.prepare( ); | |
| 31 | auth entication Service = (Authentic ationServi ce) getBea n( | |
| 32 | "authe nticationS ervice"); | |
| 33 | util s = (MhvIn tegrationU tils) getB ean("mhvIn tegrationU tils"); | |
| 34 | } | |
| 35 | ||
| 36 | ||
| 37 | pu blic void setUserid( String use rid) { | |
| 38 | try { | |
| 39 | this.u serid = In teger.pars eInt(useri d); | |
| 40 | } ca tch (Numbe rFormatExc eption e) { | |
| 41 | LOG.er ror(LogSan itizer.cle anText("Fa iled to ge t admin id from [" + userid + "]"), e); | |
| 42 | this.u serid = 0; | |
| 43 | } | |
| 44 | } | |
| 45 | ||
| 46 | /* * | |
| 47 | * Login as an adminis trator wit h a couple of facili ties to ad min only | |
| 48 | * | |
| 49 | * @return | |
| 50 | * / | |
| 51 | pu blic Strin g loginAdm in() { | |
| 52 | if ( utils.getS ettings(). isProducti onMode()) { | |
| 53 | addAct ionError(" Unable to validated your crede ntials"); | |
| 54 | return LOGINFAIL ED_RESULT; | |
| 55 | } | |
| 56 | MhvA uthenticat ionSubject subject = createSub ject(); | |
| 57 | if ( subject == null) { | |
| 58 | LOG.er ror("Unkno wn adminis trator use rid=" + us erid); | |
| 59 | return LOGINFAIL ED_RESULT; | |
| 60 | } | |
| 61 | Serv iceRespons e<Administ rator> res ponse = au thenticati onService. | |
| 62 | authen ticateAdmi nistrator( subject); | |
| 63 | if ( hasError(r esponse)) { | |
| 64 | LOG.er ror(getErr orText(res ponse)); | |
| 65 | return LOGINFAIL ED_RESULT; | |
| 66 | } | |
| 67 | setS essionAttr ibute(CURR ENT_USER, response.g etPayload( )); | |
| 68 | if ( getSession Attribute( CURRENT_US ER) == nul l) { | |
| 69 | LOG.er ror("Admin istrator n ot found") ; | |
| 70 | return LOGINFAIL ED_RESULT; | |
| 71 | } | |
| 72 | ||
| 73 | retu rn SUCCESS ; | |
| 74 | } | |
| 75 | ||
| 76 | pr ivate MhvA uthenticat ionSubject createSub ject() { | |
| 77 | swit ch (userid ) { | |
| 78 | ||
| 79 | case 1 : return c reateSubje ct("jkr", "JK", "Row lings", | |
| 80 | new Stri ng[] {"991 ","994"}, new String [] {}, fal se); | |
| 81 | ||
| 82 | case 2: re turn creat eSubject(" DNS ", "SM", " Visn", | |
| 83 | new String [] {"989", "979"}, ne w String[] {"VISN 19 "}, false) ; | |
| 84 | ||
| 85 | case 3: re turn creat eSubject(" DNS ", "SM", " National", | |
| 86 | new Stri ng[] { }, | |
| 87 | new Stri ng[] { }, true); | |
| 88 | ||
| 89 | case 5 : return c reateSubje ct("jkr", "JK", "Row lings", | |
| 90 | new String [] {"989", "979"}, ne w String[] {}, false ); | |
| 91 | ||
| 92 | defaul t: { | |
| 93 | LOG.erro r("Cannot create aut henticatio n subject for userid =" + | |
| 94 | userid); | |
| 95 | return n ull; | |
| 96 | } | |
| 97 | } | |
| 98 | } | |
| 99 | ||
| 100 | pr ivate MhvA uthenticat ionSubject createSub ject(Strin g userName , | |
| 101 | Stri ng firstNa me, String lastName, String[] facilities , String[] visns, | |
| 102 | Bool ean isNati onal) | |
| 103 | { | |
| 104 | MhvA uthenticat ionSubject subject = new MhvAu thenticati onSubject( ); | |
| 105 | Long timestamp = System. currentTim eMillis() + 5000; | |
| 106 | subj ect.setTim estamp(tim estamp); | |
| 107 | subj ect.setUse rName(user Name); | |
| 108 | subj ect.setFir stName(fir stName); | |
| 109 | subj ect.setLas tName(last Name); | |
| 110 | subj ect.setFac ilities(fa cilities); | |
| 111 | subj ect.setVis ns(visns); | |
| 112 | subj ect.setNat ional(isNa tional); | |
| 113 | subj ect.setSou rce(utils. getSetting s().getAdm inistrator Source()); | |
| 114 | subj ect.setAut henticated (true); | |
| 115 | subj ect.setChe cksum(new MhvAuthent icationSub jectDecora tor(subjec t, | |
| 116 | utils) .createChe cksum()); | |
| 117 | retu rn subject ; | |
| 118 | } | |
| 119 | ||
| 120 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.