Produced by Araxis Merge on 4/9/2018 11:14:59 AM 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 | PS_INB_ERX_3.0.1.011.zip\PS_INB_ERX_WS\src\main\java\gov\va\med\pharmacy\jaxrs\eAnde\services\impl | EESummary_Client.java | Wed Dec 20 23:47:04 2017 UTC |
| 2 | PS_INB_ERX_3.0.1.011.zip\PS_INB_ERX_WS\src\main\java\gov\va\med\pharmacy\jaxrs\eAnde\services\impl | EESummary_Client.java | Fri Apr 6 15:13:18 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 366 |
| 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.p harmacy.ja xrs.eAnde. services.i mpl; | |
| 2 | ||
| 3 | import jav a.io.File; | |
| 4 | import jav a.io.FileI nputStream ; | |
| 5 | import jav a.io.FileN otFoundExc eption; | |
| 6 | import jav a.io.IOExc eption; | |
| 7 | import jav a.io.Input Stream; | |
| 8 | import jav a.net.Malf ormedURLEx ception; | |
| 9 | import jav a.net.URL; | |
| 10 | import jav a.security .GeneralSe curityExce ption; | |
| 11 | import jav a.security .KeyStore; | |
| 12 | import jav a.security .KeyStoreE xception; | |
| 13 | import jav a.security .NoSuchAlg orithmExce ption; | |
| 14 | import jav a.util.Has hMap; | |
| 15 | import jav a.util.Map ; | |
| 16 | import jav a.util.Pro perties; | |
| 17 | ||
| 18 | import jav ax.net.ssl .KeyManage rFactory; | |
| 19 | import jav ax.net.ssl .TrustMana ger; | |
| 20 | import jav ax.net.ssl .TrustMana gerFactory ; | |
| 21 | import jav ax.xml.nam espace.QNa me; | |
| 22 | import jav ax.xml.ws. BindingPro vider; | |
| 23 | ||
| 24 | import org .apache.cx f.configur ation.jsse .TLSClient Parameters ; | |
| 25 | import org .apache.cx f.endpoint .Client; | |
| 26 | import org .apache.cx f.endpoint .Endpoint; | |
| 27 | import org .apache.cx f.frontend .ClientPro xy; | |
| 28 | import org .apache.cx f.transpor t.http.HTT PConduit; | |
| 29 | import org .apache.cx f.ws.secur ity.wss4j. WSS4JOutIn terceptor; | |
| 30 | import org .apache.ws s4j.dom.WS Constants; | |
| 31 | import org .apache.ws s4j.dom.ha ndler.WSHa ndlerConst ants; | |
| 32 | ||
| 33 | import gov .va.med.ph armacy.uti lity.Strea mUtilities ; | |
| 34 | import gov .va.med.ph armacy.wsc lients.eAn de.ClientP asswordCal lback; | |
| 35 | import gov .va.med.ph armacy.wsc lients.eAn de.EeSumma ryPort; | |
| 36 | import gov .va.med.ph armacy.wsc lients.eAn de.EeSumma ryPortServ ice; | |
| 37 | import gov .va.med.ph armacy.wsc lients.eAn de.GetEESu mmaryReque st; | |
| 38 | import gov .va.med.ph armacy.wsc lients.eAn de.getEESu mmaryRespo nse; | |
| 39 | ||
| 40 | ||
| 41 | /** | |
| 42 | * DN S Client for EESummary (Enrollme nt and Eli gibility S ervice). | |
| 43 | * | |
| 44 | */ | |
| 45 | public fin al class E ESummary_C lient { | |
| 46 | ||
| 47 | pr ivate stat ic final o rg.apache. logging.lo g4j.Logger LOG = org .apache.lo gging.log4 j.LogManag er.getLogg er(EESumma ry_Client. class); | |
| 48 | privat e static f inal Strin g E_AND_E_ REQUEST_NA ME = "eAnd e.request. name"; | |
| 49 | pr ivate stat ic final S tring E_AN D_E_USERNA ME = "eAnd e.username "; | |
| 50 | pr ivate stat ic final S tring E_AN D_E_CLIENT _ENDPOINT = "eAnde.c lient.endp oint"; | |
| 51 | pr ivate stat ic final Q Name SERVI CE_NAME = new QName( "http:// URL /schemas", "eeSummar yPortServi ce"); | |
| 52 | pr ivate stat ic final S tring KEYS TORE_FILE_ TYPE = "JK S"; | |
| 53 | pr ivate stat ic final S tring KEYS TORE_FILE_ NAME_PROPE RTY = "key store.file name"; | |
| 54 | pr ivate stat ic final S tring KEYS TORE_PASSW D_PROPERTY = "keysto re.passwor d"; | |
| 55 | ||
| 56 | public getEESumm aryRespons e returnRe sponse(Str ing key) t hrows java .lang.Exce ption { | |
| 57 | ||
| 58 | Pr operties p roperties = new Prop erties(); | |
| 59 | ||
| 60 | St ring usern ame = null ; | |
| 61 | St ring eAnde Endpoint = null; | |
| 62 | St ring eAnde RequestNam e = null; | |
| 63 | ||
| 64 | Inpu tStream in putStream = null; | |
| 65 | try{ | |
| 66 | inputS tream = th is.getClas s().getCla ssLoader() .getResour ceAsStream ("gov.va.m ed.pharmac y.wsclient s.properti es"); | |
| 67 | if(nul l != input Stream){ | |
| 68 | properti es.load(in putStream) ; | |
| 69 | } else | |
| 70 | { | |
| 71 | LOG.erro r("Propert y file not loaded/fo und."); | |
| 72 | } | |
| 73 | } | |
| 74 | fina lly{ | |
| 75 | StreamUt ilities.sa feClose(in putStream) ; | |
| 76 | } | |
| 77 | ||
| 78 | ||
| 79 | eAnd eEndpoint = properti es.getProp erty(E_AND _E_CLIENT_ ENDPOINT). trim(); | |
| 80 | ||
| 81 | user name = pro perties.ge tProperty( E_AND_E_US ERNAME).tr im(); | |
| 82 | ||
| 83 | eAnd eRequestNa me = prope rties.getP roperty(E_ AND_E_REQU EST_NAME). trim(); | |
| 84 | ||
| 85 | Stri ng url = " "; | |
| 86 | ||
| 87 | ||
| 88 | UR L wsdlURL = EeSummar yPortServi ce.WSDL_LO CATION; | |
| 89 | ||
| 90 | if (wsdlURL != null && !"".equal s(wsdlURL) ) { | |
| 91 | File wsd lFile = ne w File(url ); | |
| 92 | try { | |
| 93 | if ( wsdlFile.e xists()) { | |
| 94 | wsdlURL = wsdlFile.t oURI().toU RL(); | |
| 95 | } el se { | |
| 96 | wsdlURL = new URL(ur l); | |
| 97 | } | |
| 98 | } catch (Malformed URLExcepti on e) { | |
| 99 | ||
| 100 | thro w new Exce ption(e); // let the exception go all th e way up. | |
| 101 | } | |
| 102 | } | |
| 103 | ||
| 104 | EeS ummaryPort Service ss = new EeS ummaryPort Service(ws dlURL, SER VICE_NAME) ; | |
| 105 | ||
| 106 | EeS ummaryPort port = ss .getEeSumm aryPortSoa p11(); | |
| 107 | ||
| 108 | set upTLS(port , properti es); | |
| 109 | ||
| 110 | ((B indingProv ider)port) .getReques tContext() .put(Bindi ngProvider .ENDPOINT_ ADDRESS_PR OPERTY,eAn deEndpoint ); | |
| 111 | ||
| 112 | Get EESummaryR equest eeS ummaryRequ est = null ; | |
| 113 | ||
| 114 | Cli ent client = ClientP roxy.getCl ient(port) ; | |
| 115 | End point cxfE ndpoint = client.get Endpoint() ; | |
| 116 | ||
| 117 | Ma p<String, Object> ou tProps = n ew HashMap <String, O bject>(); | |
| 118 | ou tProps.put (WSHandler Constants. ACTION, WS HandlerCon stants.USE RNAME_TOKE N); | |
| 119 | ou tProps.put (WSHandler Constants. USER, user name); | |
| 120 | ou tProps.put (WSHandler Constants. PASSWORD_T YPE, WSCon stants.PW_ TEXT); | |
| 121 | Cl ientPasswo rdCallback handler = new Clien tPasswordC allback(); | |
| 122 | ou tProps.put (WSHandler Constants. PW_CALLBAC K_REF, han dler); | |
| 123 | ||
| 124 | WS S4JOutInte rceptor ws sOut = new WSS4JOutI nterceptor (outProps) ; | |
| 125 | ||
| 126 | cx fEndpoint. getOutInte rceptors() .add(wssOu t); | |
| 127 | ||
| 128 | ee SummaryReq uest= new GetEESumma ryRequest( ); | |
| 129 | ||
| 130 | ee SummaryReq uest.setKe y(key); | |
| 131 | ||
| 132 | ee SummaryReq uest.setRe questName( eAndeReque stName); | |
| 133 | ||
| 134 | ge tEESummary Response e eSummaryRe sponse = p ort.getEES ummary(eeS ummaryRequ est); | |
| 135 | ||
| 136 | re turn eeSum maryRespon se; | |
| 137 | ||
| 138 | } | |
| 139 | ||
| 140 | /** | |
| 141 | * The metho d to setup TLS relat ed setting s. | |
| 142 | * | |
| 143 | * @param po rt | |
| 144 | * @throws F ileNotFoun dException | |
| 145 | * @throws I OException | |
| 146 | * @throws G eneralSecu rityExcept ion | |
| 147 | * / | |
| 148 | pr ivate void setupTLS( EeSummaryP ort port, Properties propertie s) throws FileNotFou ndExceptio n, IOExcep tion, Gene ralSecurit yException { | |
| 149 | ||
| 150 | if ( this.getCl ass().getC lassLoader () != null ){ | |
| 151 | Clas sLoader cl assloader = this.get Class().ge tClassLoad er(); | |
| 152 | File file = ne w File(cla ssloader.g etResource (propertie s.getPrope rty(KEYSTO RE_FILE_NA ME_PROPERT Y).trim()) .getFile() ); | |
| 153 | ||
| 154 | HTTP Conduit ht tpConduit = (HTTPCon duit) Clie ntProxy.ge tClient(po rt).getCon duit(); | |
| 155 | ||
| 156 | File InputStrea m fileIn2 = null; | |
| 157 | TLSC lientParam eters tlsC P = new TL SClientPar ameters(); | |
| 158 | Stri ng keyPass wd = prope rties.getP roperty(KE YSTORE_PAS SWD_PROPER TY).trim() ; | |
| 159 | ||
| 160 | try { | |
| 161 | file In2 = new FileInputS tream(file ); | |
| 162 | KeyS tore trust Store = Ke yStore.get Instance(K EYSTORE_FI LE_TYPE); | |
| 163 | trus tStore.loa d(fileIn2, keyPasswd .toCharArr ay()); | |
| 164 | Trus tManager[] myTrustSt oreKeyMana gers = get TrustManag ers(trustS tore); | |
| 165 | tlsC P.setTrust Managers(m yTrustStor eKeyManage rs); | |
| 166 | http Conduit.se tTlsClient Parameters (tlsCP); | |
| 167 | } fi nally { | |
| 168 | if (nu ll != file In2) { | |
| 169 | StreamUt ilities.sa feClose(fi leIn2); | |
| 170 | } | |
| 171 | file = null; | |
| 172 | tlsCP = null; | |
| 173 | } | |
| 174 | } | |
| 175 | } | |
| 176 | ||
| 177 | pr ivate Trus tManager[] getTrustM anagers(Ke yStore tru stStore) t hrows NoSu chAlgorith mException , KeyStore Exception { | |
| 178 | Stri ng alg = K eyManagerF actory.get DefaultAlg orithm(); | |
| 179 | Trus tManagerFa ctory fac = TrustMan agerFactor y.getInsta nce(alg); | |
| 180 | fac. init(trust Store); | |
| 181 | retu rn fac.get TrustManag ers(); | |
| 182 | } | |
| 183 | ||
| 184 | ||
| 185 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.