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\mvi\dao\impl | MVIClient.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\mvi\dao\impl | MVIClient.java | Fri Apr 6 15:13:47 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1588 |
| 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.p harmacy.ja xrs.mvi.da o.impl; | |
| 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.io.Seria lizable; | |
| 9 | import jav a.math.Big Integer; | |
| 10 | import jav a.net.URL; | |
| 11 | import jav a.security .GeneralSe curityExce ption; | |
| 12 | import jav a.security .KeyStore; | |
| 13 | import jav a.security .KeyStoreE xception; | |
| 14 | import jav a.security .NoSuchAlg orithmExce ption; | |
| 15 | import jav a.text.Sim pleDateFor mat; | |
| 16 | import jav a.util.Dat e; | |
| 17 | import jav a.util.Lis t; | |
| 18 | import jav a.util.Pro perties; | |
| 19 | import jav a.util.UUI D; | |
| 20 | ||
| 21 | import jav ax.net.ssl .KeyManage r; | |
| 22 | import jav ax.net.ssl .KeyManage rFactory; | |
| 23 | import jav ax.net.ssl .TrustMana ger; | |
| 24 | import jav ax.net.ssl .TrustMana gerFactory ; | |
| 25 | import jav ax.xml.bin d.JAXBElem ent; | |
| 26 | import jav ax.xml.nam espace.QNa me; | |
| 27 | import jav ax.xml.ws. BindingPro vider; | |
| 28 | ||
| 29 | import org .apache.cx f.common.u til.String Utils; | |
| 30 | import org .apache.cx f.configur ation.jsse .TLSClient Parameters ; | |
| 31 | import org .apache.cx f.frontend .ClientPro xy; | |
| 32 | import org .apache.cx f.transpor t.http.HTT PConduit; | |
| 33 | ||
| 34 | import gov .va.med.ph armacy.jax rs.mvi.mod el.Patient ; | |
| 35 | import gov .va.med.ph armacy.uti lity.Strea mUtilities ; | |
| 36 | import gov .va.med.ph armacy.wsc lients.mvi .AD; | |
| 37 | import gov .va.med.ph armacy.wsc lients.mvi .ActClassC ontrolAct; | |
| 38 | import gov .va.med.ph armacy.wsc lients.mvi .CD; | |
| 39 | import gov .va.med.ph armacy.wsc lients.mvi .CE; | |
| 40 | import gov .va.med.ph armacy.wsc lients.mvi .COCTMT090 100UV01Ass ignedPerso n; | |
| 41 | import gov .va.med.ph armacy.wsc lients.mvi .COCTMT090 100UV01Per son; | |
| 42 | import gov .va.med.ph armacy.wsc lients.mvi .CS; | |
| 43 | import gov .va.med.ph armacy.wsc lients.mvi .Communica tionFuncti onType; | |
| 44 | import gov .va.med.ph armacy.wsc lients.mvi .EN; | |
| 45 | import gov .va.med.ph armacy.wsc lients.mvi .EntityCla ssDevice; | |
| 46 | import gov .va.med.ph armacy.wsc lients.mvi .II; | |
| 47 | import gov .va.med.ph armacy.wsc lients.mvi .INT; | |
| 48 | import gov .va.med.ph armacy.wsc lients.mvi .IVLTS; | |
| 49 | import gov .va.med.ph armacy.wsc lients.mvi .MCCIMT000 100UV01Age nt; | |
| 50 | import gov .va.med.ph armacy.wsc lients.mvi .MCCIMT000 100UV01Dev ice; | |
| 51 | import gov .va.med.ph armacy.wsc lients.mvi .MCCIMT000 100UV01Org anization; | |
| 52 | import gov .va.med.ph armacy.wsc lients.mvi .MCCIMT000 100UV01Rec eiver; | |
| 53 | import gov .va.med.ph armacy.wsc lients.mvi .MCCIMT000 100UV01Sen der; | |
| 54 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAIN201 305UV02; | |
| 55 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAIN201 305UV02QUQ IMT021001U V01Control ActProcess ; | |
| 56 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAIN201 306UV02; | |
| 57 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAIN201 306UV02MFM IMT700711U V01Registr ationEvent ; | |
| 58 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 306UV02Liv ingSubject Administra tiveGender ; | |
| 59 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 306UV02Liv ingSubject BirthTime; | |
| 60 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 306UV02Liv ingSubject Id; | |
| 61 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 306UV02Liv ingSubject Name; | |
| 62 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 306UV02Par ameterList ; | |
| 63 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 306UV02Pat ientAddres s; | |
| 64 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 306UV02Pat ientTeleco m; | |
| 65 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 306UV02Que ryByParame ter; | |
| 66 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 310UV02Oth erIDs; | |
| 67 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 310UV02Pat ient; | |
| 68 | import gov .va.med.ph armacy.wsc lients.mvi .PRPAMT201 310UV02Per son; | |
| 69 | import gov .va.med.ph armacy.wsc lients.mvi .QUQIMT021 001UV01Dat aEnterer; | |
| 70 | import gov .va.med.ph armacy.wsc lients.mvi .SXCMTS; | |
| 71 | import gov .va.med.ph armacy.wsc lients.mvi .TEL; | |
| 72 | import gov .va.med.ph armacy.wsc lients.mvi .TS; | |
| 73 | import gov .va.med.ph armacy.wsc lients.mvi .VAIdM; | |
| 74 | import gov .va.med.ph armacy.wsc lients.mvi .VAIdMPort ; | |
| 75 | import gov .va.med.ph armacy.wsc lients.mvi .XActMoodI ntentEvent ; | |
| 76 | ||
| 77 | /** | |
| 78 | * MVI Cli ent Class, A JAXWS C lient Clas s for MVI Web Servic e. | |
| 79 | * | |
| 80 | */ | |
| 81 | //@Configu ration | |
| 82 | //@Propert ySource("c lasspath:g ov.va.med. pharmacy.w sclients.p roperties" ) | |
| 83 | public cla ss MVIClie nt { | |
| 84 | ||
| 85 | // Constant Strings | |
| 86 | ||
| 87 | pr ivate stat ic final S tring PHYS ICAL_CONST = "PHYS"; | |
| 88 | pr ivate stat ic final S tring COMM A_REGEX_CO NST = "\\, "; | |
| 89 | pr ivate stat ic final S tring HOME _PHONE_CON ST = "HP"; | |
| 90 | pr ivate stat ic final S tring COUN TRY_CONST = "country "; | |
| 91 | pr ivate stat ic final S tring POST AL_CODE_CO NST = "pos talCode"; | |
| 92 | pr ivate stat ic final S tring STAT E_CONST = "state"; | |
| 93 | pr ivate stat ic final S tring CITY _CONST = " city"; | |
| 94 | pr ivate stat ic final S tring STRE ET_ADDRESS _LINE_CONS T = "stree tAddressLi ne"; | |
| 95 | pr ivate stat ic final S tring MVI_ CLIENT_END POINT_PROP ERTY = "mv i.client.e ndpoint"; | |
| 96 | pr ivate stat ic final S tring KEYS TORE_FILE_ TYPE = "JK S"; | |
| 97 | pr ivate stat ic final S tring KEYS TORE_FILE_ NAME_PROPE RTY = "key store.file name"; | |
| 98 | pr ivate stat ic final S tring KEYS TORE_PASSW D_PROPERTY = "keysto re.passwor d"; | |
| 99 | pr ivate stat ic final S tring LEGA L_NAME = " Legal Name "; | |
| 100 | pr ivate stat ic final S tring L_CH ARACTER = "L"; | |
| 101 | pr ivate stat ic final S tring EMPT Y_STRING = ""; | |
| 102 | pr ivate stat ic final S tring CAP_ REGEX_CONS T = "\\^"; | |
| 103 | pr ivate stat ic final S tring CONS T_ESR = "E SR"; | |
| 104 | pr ivate stat ic final S tring CAP_ CHARACTER = "^"; | |
| 105 | pr ivate stat ic final S tring SSN_ ROOT = "2. 16.840.1.1 13883.4.1" ; | |
| 106 | pr ivate stat ic final S tring DATE _OF_BIRTH_ CONST = "D ate of Bir th"; | |
| 107 | pr ivate stat ic final S tring GEND ER_CONST = "Gender"; | |
| 108 | pr ivate stat ic final S tring MVI_ COMP1_CONS T = "MVI.C OMP1"; | |
| 109 | pr ivate stat ic final S tring NF_S TATUS = "N F"; | |
| 110 | pr ivate stat ic final S tring AE_S TATUS = "A E"; | |
| 111 | pr ivate stat ic final S tring QE_S TATUS = "Q E"; | |
| 112 | pr ivate stat ic final S tring SSN_ CONST = "S SN"; | |
| 113 | pr ivate stat ic final S tring OK_S TATUS = "O K"; | |
| 114 | pr ivate stat ic final S tring QUER Y_BY_PARAM ETER_CONST = "queryB yParameter "; | |
| 115 | pr ivate stat ic final S tring FAMI LY_NAME_CO NST = "fam ily"; | |
| 116 | pr ivate stat ic final S tring GIVE N_NAME_CON ST = "give n"; | |
| 117 | pr ivate stat ic final S tring ASSI GNED_PERSO N_ID_EXTEN SION = "bf user001"; | |
| 118 | pr ivate stat ic final S tring CONT ROL_ACT_PR OCESS_CODE = "PRPA_T E201305UV0 2"; | |
| 119 | pr ivate stat ic final S tring ITS_ VERSION = "XML_1.0"; | |
| 120 | pr ivate stat ic final S tring TELE COM_CONST = "http:// serviceloc ation/PDQu ery"; | |
| 121 | pr ivate stat ic final S tring AP_C ONST = "AP "; | |
| 122 | pr ivate stat ic final S tring ENT_ CONST = "E NT"; | |
| 123 | pr ivate stat ic final S tring ASSI GNED_CONST = "ASSIGN ED"; | |
| 124 | pr ivate stat ic final S tring PSN_ CONST = "P SN"; | |
| 125 | pr ivate stat ic final S tring ASSI GNED_PERSO N_HL7_QNAM E = "assig nedPerson" ; | |
| 126 | pr ivate stat ic final S tring QUER Y_ID_EXTEN SION = "0b 0be46c-86d f-4811-b2c 1-fd9bf9f1 09c5"; | |
| 127 | pr ivate stat ic final S tring QUER Y_ID_ROOT = "1.2.840 .114350.1. 13.28.1.18 .5.999"; | |
| 128 | pr ivate stat ic final S tring ORG_ CONST = "O RG"; | |
| 129 | pr ivate stat ic final S tring REPR ESENTED_OR GANIZATION _CONST = " represente dOrganizat ion"; | |
| 130 | pr ivate stat ic final S tring SEND ER_AGENT_C LASS_CODE = "AGNT"; | |
| 131 | pr ivate stat ic final S tring VHA_ ID_VALUE = "2.16.840 .1.113883. 4.349"; | |
| 132 | pr ivate stat ic final S tring DETE RMINER_COD E = "INSTA NCE"; | |
| 133 | pr ivate stat ic final S tring QUER Y_STATUS = "NEW"; | |
| 134 | pr ivate stat ic final S tring INB_ ERX_SENDER _CODE = "2 00PERX"; | |
| 135 | pr ivate stat ic final S tring MVI_ HL7_QNAME = "urn:hl7 -org:v3"; | |
| 136 | pr ivate stat ic final S tring AS_A GENT = "as Agent"; | |
| 137 | pr ivate stat ic final S tring ALWA YS = "AL"; | |
| 138 | pr ivate stat ic final S tring WS_E NVIROMENT = "T"; | |
| 139 | pr ivate stat ic final S tring MVI_ WS_VERSION = "3.0"; | |
| 140 | pr ivate stat ic final S tring REQU EST_ID_ROO T = "1.2.8 40.114350. 1.13.0.1.7 .1.1"; | |
| 141 | pr ivate stat ic final S tring FIND _CANDIDATE _OPERATION = "PRPA_I N201305UV0 2"; | |
| 142 | pr ivate stat ic final S tring REQU EST_INTERA CTION_ID = "2.16.840 .1.113883. 1.6"; | |
| 143 | pr ivate stat ic final Q Name SERVI CE_NAME = new QName( "http:// URL ", "VAIdM" ); | |
| 144 | ||
| 145 | ||
| 146 | ||
| 147 | // @Autowired | |
| 148 | // private En vironment environmen t; | |
| 149 | ||
| 150 | pu blic Patie nt getMVID ata(Patien t patientS earchObj) throws jav a.lang.Exc eption { | |
| 151 | ||
| 152 | // T he followi ng prints out a lot of debug i nformation . | |
| 153 | // I t should o nly be unc ommented i n dev envi ronment or for | |
| 154 | // t roubleshoo ting purpo ses only. | |
| 155 | ||
| 156 | // S ystem.setP roperty("j avax.net.d ebug", "ss l, handsha ke"); | |
| 157 | ||
| 158 | Prop erties pro perties = new Proper ties(); | |
| 159 | ||
| 160 | Inpu tStream in putStream = null; | |
| 161 | try { | |
| 162 | inputS tream = th is.getClas s().getCla ssLoader() | |
| 163 | .getResour ceAsStream ("gov.va.m ed.pharmac y.wsclient s.properti es"); | |
| 164 | if (nu ll != inpu tStream) { | |
| 165 | properti es.load(in putStream) ; | |
| 166 | } | |
| 167 | } fi nally { | |
| 168 | if (nu ll != inpu tStream) { | |
| 169 | StreamUt ilities.sa feClose(in putStream) ; | |
| 170 | } | |
| 171 | } | |
| 172 | ||
| 173 | Stri ng mviClie ntEndpoint = null; | |
| 174 | ||
| 175 | Pati ent patien tSearchRes ults = new Patient() ; | |
| 176 | ||
| 177 | // g enerate ne w query da te and tim e | |
| 178 | Date queryCrea tionDate = new Date( ); | |
| 179 | Simp leDateForm at dateFor mat = new SimpleDate Format("yy MMddhhmmss "); | |
| 180 | Stri ng queryDa te = dateF ormat.form at(queryCr eationDate ); | |
| 181 | ||
| 182 | // g enerate ne w random U UID | |
| 183 | ||
| 184 | UUID queryUUID = UUID.ra ndomUUID() ; | |
| 185 | ||
| 186 | URL wsdlURL = VAIdM.WSDL _LOCATION; | |
| 187 | ||
| 188 | VAId M ss = new VAIdM(wsd lURL, SERV ICE_NAME); | |
| 189 | VAId MPort port = ss.getV AIdMPort() ; | |
| 190 | ||
| 191 | ||
| 192 | mviC lientEndpo int = prop erties.get Property(M VI_CLIENT_ ENDPOINT_P ROPERTY).t rim(); // trim the v alue for a ny potenti al whitesp ace. | |
| 193 | // S ecure Dev | |
| 194 | ((Bi ndingProvi der) port) .getReques tContext() .put(Bindi ngProvider .ENDPOINT_ ADDRESS_PR OPERTY, mviClien tEndpoint) ; | |
| 195 | ||
| 196 | // c all method to setup TLS securi ty paramet ers. | |
| 197 | setu pTLS(port, propertie s); | |
| 198 | ||
| 199 | ||
| 200 | PRPA IN201305UV 02 mviRequ estObj = n ew PRPAIN2 01305UV02( ); | |
| 201 | II t estRequest Id = new I I(); | |
| 202 | test RequestId. setExtensi on(queryUU ID.toStrin g()); | |
| 203 | test RequestId. setRoot(RE QUEST_ID_R OOT); | |
| 204 | ||
| 205 | II i nteraction Id = new I I(); | |
| 206 | inte ractionId. setExtensi on(FIND_CA NDIDATE_OP ERATION); | |
| 207 | inte ractionId. setRoot(RE QUEST_INTE RACTION_ID ); | |
| 208 | ||
| 209 | TS c reateTime = new TS() ; | |
| 210 | crea teTime.set Value(quer yDate); | |
| 211 | ||
| 212 | CS v ersionCode = new CS( ); | |
| 213 | vers ionCode.se tCode(MVI_ WS_VERSION ); | |
| 214 | ||
| 215 | CS p rocessingC ode = new CS(); | |
| 216 | ||
| 217 | // T for Test, P for Pro duction | |
| 218 | proc essingCode .setCode(W S_ENVIROME NT); | |
| 219 | ||
| 220 | CS p rocessingM odeCode = new CS(); | |
| 221 | proc essingMode Code.setCo de(WS_ENVI ROMENT); | |
| 222 | ||
| 223 | CS a cceptAckCo de = new C S(); | |
| 224 | ||
| 225 | // V alues can be AL, ER, NE, AL is default f or request | |
| 226 | acce ptAckCode. setCode(AL WAYS); | |
| 227 | ||
| 228 | mviR equestObj. setITSVers ion(ITS_VE RSION); | |
| 229 | mviR equestObj. setId(test RequestId) ; | |
| 230 | mviR equestObj. setCreatio nTime(crea teTime); | |
| 231 | mviR equestObj. setVersion Code(versi onCode); | |
| 232 | mviR equestObj. setInterac tionId(int eractionId ); | |
| 233 | mviR equestObj. setProcess ingCode(pr ocessingCo de); | |
| 234 | mviR equestObj. setProcess ingModeCod e(processi ngModeCode ); | |
| 235 | mviR equestObj. setAcceptA ckCode(acc eptAckCode ); | |
| 236 | ||
| 237 | // r eceiver st art | |
| 238 | MCCI MT000100UV 01Receiver receiver = new MCCI MT000100UV 01Receiver (); | |
| 239 | rece iver.setTy peCode(Com munication FunctionTy pe.RCV); | |
| 240 | ||
| 241 | MCCI MT000100UV 01Device r eceiverDev ice = new MCCIMT0001 00UV01Devi ce(); | |
| 242 | rece iverDevice .setClassC ode(Entity ClassDevic e.DEV); | |
| 243 | rece iverDevice .setDeterm inerCode(D ETERMINER_ CODE); | |
| 244 | ||
| 245 | II r eceiverDev iceID = ne w II(); | |
| 246 | rece iverDevice ID.setRoot (VHA_ID_VA LUE); | |
| 247 | ||
| 248 | rece iverDevice .getId().a dd(receive rDeviceID) ; | |
| 249 | ||
| 250 | TEL telecom = new TEL(); | |
| 251 | tele com.setVal ue(TELECOM _CONST); | |
| 252 | ||
| 253 | rece iverDevice .getTeleco m().add(te lecom); | |
| 254 | ||
| 255 | rece iver.setDe vice(recei verDevice) ; | |
| 256 | ||
| 257 | // r eceiver en d | |
| 258 | ||
| 259 | mviR equestObj. getReceive r().add(re ceiver); | |
| 260 | ||
| 261 | // s ender star t | |
| 262 | ||
| 263 | MCCI MT000100UV 01Sender m ccSender = new MCCIM T000100UV0 1Sender(); | |
| 264 | mccS ender.setT ypeCode(Co mmunicatio nFunctionT ype.SND); | |
| 265 | ||
| 266 | MCCI MT000100UV 01Device s enderDevic e = new MC CIMT000100 UV01Device (); | |
| 267 | send erDevice.s etClassCod e(EntityCl assDevice. DEV); | |
| 268 | send erDevice.s etDetermin erCode(DET ERMINER_CO DE); | |
| 269 | ||
| 270 | II s enderDevic eID = new II(); | |
| 271 | send erDeviceID .setRoot(V HA_ID_VALU E); | |
| 272 | send erDeviceID .setExtens ion(INB_ER X_SENDER_C ODE); | |
| 273 | ||
| 274 | send erDevice.g etId().add (senderDev iceID); | |
| 275 | ||
| 276 | MCCI MT000100UV 01Agent se nderAsAgen t = new MC CIMT000100 UV01Agent( ); | |
| 277 | ||
| 278 | MCCI MT000100UV 01Organiza tion repre sentedOrga nization = new MCCIM T000100UV0 1Organizat ion(); | |
| 279 | repr esentedOrg anization. setClassCo de(ORG_CON ST); | |
| 280 | repr esentedOrg anization. setDetermi nerCode(DE TERMINER_C ODE); | |
| 281 | ||
| 282 | II r epresented Organizati onID = new II(); | |
| 283 | repr esentedOrg anizationI D.setRoot( VHA_ID_VAL UE); | |
| 284 | repr esentedOrg anizationI D.setExten sion(INB_E RX_SENDER_ CODE); | |
| 285 | ||
| 286 | repr esentedOrg anization. getId().ad d(represen tedOrganiz ationID); | |
| 287 | ||
| 288 | QNam e organiza tionQName = new QNam e(MVI_HL7_ QNAME, REP RESENTED_O RGANIZATIO N_CONST); | |
| 289 | JAXB Element<MC CIMT000100 UV01Organi zation> or gs = new J AXBElement <MCCIMT000 100UV01Org anization> ( | |
| 290 | organiza tionQName, MCCIMT000 100UV01Org anization. class, rep resentedOr ganization ); | |
| 291 | ||
| 292 | Stri ng senderA gentClassC ode = new String(SEN DER_AGENT_ CLASS_CODE ); | |
| 293 | ||
| 294 | send erAsAgent. getClassCo de().add(s enderAgent ClassCode) ; | |
| 295 | ||
| 296 | send erAsAgent. setReprese ntedOrgani zation(org s); | |
| 297 | ||
| 298 | QNam e agentsQn ame = new QName(MVI_ HL7_QNAME, AS_AGENT) ; | |
| 299 | ||
| 300 | JAXB Element<MC CIMT000100 UV01Agent> agents = new JAXBEl ement<MCCI MT000100UV 01Agent>(a gentsQname , MCCIMT00 0100UV01Ag ent.class, senderAsA gent); | |
| 301 | ||
| 302 | send erDevice.s etAsAgent( agents); | |
| 303 | ||
| 304 | mccS ender.setD evice(send erDevice); | |
| 305 | ||
| 306 | // s ender end | |
| 307 | ||
| 308 | // C ontrolActP rocess sta rt | |
| 309 | PRPA IN201305UV 02QUQIMT02 1001UV01Co ntrolActPr ocess cont rolActProc ess = new PRPAIN2013 05UV02QUQI MT021001UV 01ControlA ctProcess( ); | |
| 310 | ||
| 311 | cont rolActProc ess.setCla ssCode(Act ClassContr olAct.CACT ); | |
| 312 | cont rolActProc ess.setMoo dCode(XAct MoodIntent Event.EVN) ; | |
| 313 | ||
| 314 | CD c ontrolActP rocessCode = new CD( ); | |
| 315 | ||
| 316 | cont rolActProc essCode.se tCodeSyste m(REQUEST_ INTERACTIO N_ID); | |
| 317 | cont rolActProc essCode.se tCode(CONT ROL_ACT_PR OCESS_CODE ); | |
| 318 | cont rolActProc ess.setCod e(controlA ctProcessC ode); | |
| 319 | ||
| 320 | QUQI MT021001UV 01DataEnte rer dataEn terer = ne w QUQIMT02 1001UV01Da taEnterer( ); | |
| 321 | data Enterer.se tContextCo ntrolCode( AP_CONST); | |
| 322 | data Enterer.ge tTypeCode( ).add(ENT_ CONST); | |
| 323 | ||
| 324 | COCT MT090100UV 01Assigned Person ass ignedPerso n = new CO CTMT090100 UV01Assign edPerson() ; | |
| 325 | assi gnedPerson .setClassC ode(ASSIGN ED_CONST); | |
| 326 | ||
| 327 | II a ssignedPer sonId = ne w II(); | |
| 328 | assi gnedPerson Id.setRoot (VHA_ID_VA LUE); | |
| 329 | assi gnedPerson Id.setExte nsion(ASSI GNED_PERSO N_ID_EXTEN SION); | |
| 330 | ||
| 331 | assi gnedPerson .getId().a dd(assigne dPersonId) ; | |
| 332 | ||
| 333 | COCT MT090100UV 01Person s earchAssig nedPerson = new COCT MT090100UV 01Person() ; | |
| 334 | sear chAssigned Person.get ClassCode( ).add(PSN_ CONST); | |
| 335 | sear chAssigned Person.set Determiner Code(DETER MINER_CODE ); | |
| 336 | ||
| 337 | EN s earchName = new EN() ; | |
| 338 | ||
| 339 | Stri ng givenNa me = patie ntSearchOb j.getFirst Name().toU pperCase() ; | |
| 340 | Stri ng family = patientS earchObj.g etLastName ().toUpper Case(); | |
| 341 | ||
| 342 | QNam e givenNam eQName = n ew QName(M VI_HL7_QNA ME, GIVEN_ NAME_CONST ); | |
| 343 | QNam e familyNa meQName = new QName( MVI_HL7_QN AME, FAMIL Y_NAME_CON ST); | |
| 344 | ||
| 345 | JAXB Element<St ring> give nNameEleme nt = new J AXBElement <String>(g ivenNameQN ame, Strin g.class, E N.class,gi venName); | |
| 346 | JAXB Element<St ring> fami lyNameElem ent = new JAXBElemen t<String>( familyName QName, Str ing.class, EN.class, family); | |
| 347 | ||
| 348 | sear chName.get Content(). add(givenN ameElement ); | |
| 349 | sear chName.get Content(). add(family NameElemen t); | |
| 350 | sear chAssigned Person.get Name().add (searchNam e); | |
| 351 | ||
| 352 | QNam e personQn ame = new QName(MVI_ HL7_QNAME, ASSIGNED_ PERSON_HL7 _QNAME); | |
| 353 | JAXB Element<CO CTMT090100 UV01Person > persons = new JAXB Element<CO CTMT090100 UV01Person >(personQn ame, COCTMT0901 00UV01Pers on.class, searchAssi gnedPerson ); | |
| 354 | ||
| 355 | assi gnedPerson .setAssign edPerson(p ersons); | |
| 356 | ||
| 357 | data Enterer.se tAssignedP erson(assi gnedPerson ); | |
| 358 | ||
| 359 | cont rolActProc ess.getDat aEnterer() .add(dataE nterer); | |
| 360 | ||
| 361 | // q uery by pa rameter st art | |
| 362 | ||
| 363 | PRPA MT201306UV 02QueryByP arameter q ueryByPara meter = ne w PRPAMT20 1306UV02Qu eryByParam eter(); | |
| 364 | ||
| 365 | II q ueryId = n ew II(); | |
| 366 | quer yId.setExt ension(QUE RY_ID_EXTE NSION); | |
| 367 | quer yId.setRoo t(QUERY_ID _ROOT); | |
| 368 | ||
| 369 | quer yByParamet er.setQuer yId(queryI d); | |
| 370 | ||
| 371 | CS q uerySstatu sCode = ne w CS(); | |
| 372 | quer ySstatusCo de.setCode (QUERY_STA TUS); | |
| 373 | ||
| 374 | quer yByParamet er.setStat usCode(que rySstatusC ode); | |
| 375 | ||
| 376 | CS q ueryModify Code = new CS(); | |
| 377 | quer yModifyCod e.setCode( MVI_COMP1_ CONST); // can be T or MVI.COM P1 for get CorIds. | |
| 378 | ||
| 379 | quer yByParamet er.setModi fyCode(que ryModifyCo de); | |
| 380 | ||
| 381 | INT queryIniti alQuantity = new INT (); | |
| 382 | quer yInitialQu antity.set Value(BigI nteger.val ueOf(1)); | |
| 383 | ||
| 384 | quer yByParamet er.setInit ialQuantit y(queryIni tialQuanti ty); | |
| 385 | ||
| 386 | PRPA MT201306UV 02Paramete rList quer yParameter List = new PRPAMT201 306UV02Par ameterList (); | |
| 387 | ||
| 388 | // s et Gender | |
| 389 | if ( null != pa tientSearc hObj.getGe nder()) { | |
| 390 | ||
| 391 | PRPAMT 201306UV02 LivingSubj ectAdminis trativeGen der person Gender = n ew PRPAMT2 01306UV02L ivingSubje ctAdminist rativeGend er(); | |
| 392 | CE gen derValue = new CE(); | |
| 393 | gender Value.setC ode(patien tSearchObj .getGender ()); | |
| 394 | person Gender.get Value().ad d(genderVa lue); | |
| 395 | person Gender.set SemanticsT ext(GENDER _CONST); | |
| 396 | ||
| 397 | queryP arameterLi st.getLivi ngSubjectA dministrat iveGender( ).add(pers onGender); | |
| 398 | } | |
| 399 | ||
| 400 | // s et DOB | |
| 401 | if ( null != pa tientSearc hObj.getDa teOfBirth( )) { | |
| 402 | ||
| 403 | PRPAMT 201306UV02 LivingSubj ectBirthTi me personD OB = new P RPAMT20130 6UV02Livin gSubjectBi rthTime(); | |
| 404 | IVLTS birthDateA ndTime = n ew IVLTS() ; | |
| 405 | birthD ateAndTime .setValue( patientSea rchObj.get DateOfBirt h()); | |
| 406 | person DOB.getVal ue().add(b irthDateAn dTime); | |
| 407 | person DOB.setSem anticsText (DATE_OF_B IRTH_CONST ); | |
| 408 | queryP arameterLi st.getLivi ngSubjectB irthTime() .add(perso nDOB); | |
| 409 | } | |
| 410 | ||
| 411 | // s et SSN | |
| 412 | if ( null != pa tientSearc hObj.getSo cSecNum()) { | |
| 413 | ||
| 414 | PRPAMT 201306UV02 LivingSubj ectId pers onSSN = ne w PRPAMT20 1306UV02Li vingSubjec tId(); | |
| 415 | II SSN Value = ne w II(); | |
| 416 | SSNVal ue.setRoot (SSN_ROOT) ; | |
| 417 | ||
| 418 | SSNVal ue.setExte nsion(pati entSearchO bj.getSocS ecNum()); | |
| 419 | ||
| 420 | person SSN.getVal ue().add(S SNValue); | |
| 421 | person SSN.setSem anticsText (SSN_CONST ); | |
| 422 | queryP arameterLi st.getLivi ngSubjectI d().add(pe rsonSSN); | |
| 423 | } | |
| 424 | ||
| 425 | // s et name | |
| 426 | if ( null != pa tientSearc hObj.getFi rstName() && null != patientSe archObj.ge tLastName( )){ | |
| 427 | ||
| 428 | PRPAMT 201306UV02 LivingSubj ectName pe rsonName = new PRPAM T201306UV0 2LivingSub jectName() ; | |
| 429 | ||
| 430 | EN sea rchLegalNa me = new E N(); | |
| 431 | ||
| 432 | search LegalName. getContent ().add(giv enNameElem ent); | |
| 433 | search LegalName. getContent ().add(fam ilyNameEle ment); | |
| 434 | ||
| 435 | search LegalName. getUse().a dd(L_CHARA CTER); | |
| 436 | ||
| 437 | person Name.getVa lue().add( searchLega lName); | |
| 438 | person Name.setSe manticsTex t(LEGAL_NA ME); | |
| 439 | ||
| 440 | queryP arameterLi st.getLivi ngSubjectN ame().add( personName ); | |
| 441 | } | |
| 442 | ||
| 443 | // s et address | |
| 444 | ||
| 445 | if ( null != pa tientSearc hObj.getAd dress()) { | |
| 446 | ||
| 447 | PRPAMT 201306UV02 PatientAdd ress patie ntAddresss = new PRP AMT201306U V02Patient Address(); | |
| 448 | ||
| 449 | AD val ue = new A D(); | |
| 450 | ||
| 451 | value. getUse().a dd(PHYSICA L_CONST); | |
| 452 | ||
| 453 | String streetAdd ressLine = null; | |
| 454 | String city = nu ll; | |
| 455 | String state = n ull; | |
| 456 | String postalCod e = null; | |
| 457 | String country = null; | |
| 458 | String [] address Tokens = n ull; | |
| 459 | ||
| 460 | ||
| 461 | addres sTokens = patientSea rchObj.get Address(). split(COMM A_REGEX_CO NST); | |
| 462 | ||
| 463 | if (ad dressToken s != null && address Tokens.len gth > 0) { | |
| 464 | ||
| 465 | // run t he loop on ly once. | |
| 466 | for (int i = 0; i < addressT okens.leng th; i++) { | |
| 467 | streetAddr essLine = addressTok ens[i].tri m(); | |
| 468 | ||
| 469 | // to avoi d string i ndex out o f bound ex ception. | |
| 470 | if(address Tokens.len gth>=4){ | |
| 471 | ||
| 472 | ci ty = addre ssTokens[i +1].trim() ; | |
| 473 | ||
| 474 | st ate = addr essTokens[ i+2].trim( ); | |
| 475 | ||
| 476 | po stalCode = addressTo kens[i+3]. trim(); | |
| 477 | ||
| 478 | } | |
| 479 | ||
| 480 | if(address Tokens.len gth==5){ | |
| 481 | ||
| 482 | co untry = ad dressToken s[i+4].tri m(); | |
| 483 | } | |
| 484 | ||
| 485 | break; | |
| 486 | ||
| 487 | } | |
| 488 | } | |
| 489 | ||
| 490 | ||
| 491 | QName streetAddr essLineQNa me = new Q Name(MVI_H L7_QNAME, STREET_ADD RESS_LINE_ CONST); | |
| 492 | QName cityQName = new QNam e(MVI_HL7_ QNAME, CIT Y_CONST); | |
| 493 | QName stateQName = new QNa me(MVI_HL7 _QNAME, ST ATE_CONST) ; | |
| 494 | QName postalCode QName = ne w QName(MV I_HL7_QNAM E, POSTAL_ CODE_CONST ); | |
| 495 | QName countryQNa me = new Q Name(MVI_H L7_QNAME, COUNTRY_CO NST); | |
| 496 | ||
| 497 | JAXBEl ement<Stri ng> street AddressLin eElement = new JAXBE lement<Str ing>(stree tAddressLi neQName, S tring.clas s, AD.cla ss,streetA ddressLine ); | |
| 498 | JAXBEl ement<Stri ng> cityEl ement = ne w JAXBElem ent<String >(cityQNam e, String. class, AD .class,cit y); | |
| 499 | JAXBEl ement<Stri ng> stateE lement = n ew JAXBEle ment<Strin g>(stateQN ame, Strin g.class, AD.class,s tate); | |
| 500 | JAXBEl ement<Stri ng> postal CodeElemen t = new JA XBElement< String>(po stalCodeQN ame, Strin g.class, AD.class,p ostalCode) ; | |
| 501 | JAXBEl ement<Stri ng> countr yElement = null; | |
| 502 | ||
| 503 | if(nul l!=country ){ | |
| 504 | countryE lement = n ew JAXBEle ment<Strin g>(country QName, Str ing.class, AD.class ,country); | |
| 505 | } | |
| 506 | ||
| 507 | ||
| 508 | value. getContent ().add(str eetAddress LineElemen t); | |
| 509 | value. getContent ().add(cit yElement); | |
| 510 | value. getContent ().add(sta teElement) ; | |
| 511 | value. getContent ().add(pos talCodeEle ment); | |
| 512 | if(nul l!=country ){ | |
| 513 | value.ge tContent() .add(count ryElement) ; | |
| 514 | } | |
| 515 | ||
| 516 | patien tAddresss. getValue() .add(value ); | |
| 517 | ||
| 518 | queryP arameterLi st.getPati entAddress ().add(pat ientAddres ss); | |
| 519 | ||
| 520 | } | |
| 521 | ||
| 522 | ||
| 523 | // s et telepho ne. | |
| 524 | ||
| 525 | if ( null != pa tientSearc hObj.getTe lephone()) { | |
| 526 | ||
| 527 | PRPAMT 201306UV02 PatientTel ecom patie ntTelephon e = new PR PAMT201306 UV02Patien tTelecom() ; | |
| 528 | ||
| 529 | TEL te lephone = new TEL(); | |
| 530 | teleph one.getUse ().add(HOM E_PHONE_CO NST);// Ho me Phone | |
| 531 | ||
| 532 | SXCMTS value = n ew SXCMTS( ); | |
| 533 | value. setValue(p atientSear chObj.getT elephone() ); | |
| 534 | ||
| 535 | teleph one.getUse ablePeriod ().add(val ue); | |
| 536 | ||
| 537 | patien tTelephone .getValue( ).add(tele phone); | |
| 538 | ||
| 539 | queryP arameterLi st.getPati entTelecom ().add(pat ientTeleph one); | |
| 540 | ||
| 541 | } | |
| 542 | ||
| 543 | quer yByParamet er.setPara meterList( queryParam eterList); | |
| 544 | ||
| 545 | // q uery by pa rameter en d | |
| 546 | QNam e queryQNa me = new Q Name(MVI_H L7_QNAME, QUERY_BY_P ARAMETER_C ONST); | |
| 547 | JAXB Element<PR PAMT201306 UV02QueryB yParameter > queries = new JAXB Element<PR PAMT201306 UV02QueryB yParameter >( | |
| 548 | queryQNa me, PRPAMT 201306UV02 QueryByPar ameter.cla ss, queryB yParameter ); | |
| 549 | ||
| 550 | cont rolActProc ess.setQue ryByParame ter(querie s); | |
| 551 | // C ontrolActP rocess end | |
| 552 | ||
| 553 | mviR equestObj. setSender( mccSender) ; | |
| 554 | mviR equestObj. setControl ActProcess (controlAc tProcess); | |
| 555 | ||
| 556 | // W S Response and data filtering below. | |
| 557 | ||
| 558 | PRPA IN201306UV 02 mviResp onseObj = port.prpaI N201305UV0 2(mviReque stObj); | |
| 559 | ||
| 560 | Stri ng acknowl edgementCo de = mviRe sponseObj. getControl ActProcess ().getQuer yAck().get QueryRespo nseCode(). getCode(); | |
| 561 | ||
| 562 | // H appy Path | |
| 563 | if ( OK_STATUS. equalsIgno reCase(ack nowledgeme ntCode)) { | |
| 564 | ||
| 565 | // loo ks like re turning mu ltiple. | |
| 566 | PRPAIN 201306UV02 MFMIMT7007 11UV01Regi strationEv ent regist ertrationE vent = mvi ResponseOb j.getContr olActProce ss().getSu bject().ge t(0).getRe gistration Event(); | |
| 567 | ||
| 568 | PRPAMT 201310UV02 Patient pa tient = re gistertrat ionEvent.g etSubject1 ().getPati ent(); | |
| 569 | ||
| 570 | List<I I> ids = p atient.get Id(); | |
| 571 | ||
| 572 | String ICN = nul l; | |
| 573 | String Buffer sta tiondIdBuf fer = new StringBuff er(); | |
| 574 | String [] station Tokens = n ull; | |
| 575 | String stationId s = null; | |
| 576 | ||
| 577 | for (I I id : ids ) { | |
| 578 | if (id.g etExtensio n().contai ns(CONST_E SR)) { | |
| 579 | ||
| 580 | ICN = id.g etExtensio n(); | |
| 581 | ||
| 582 | } | |
| 583 | // get I CN only on ce. | |
| 584 | else if (StringUti ls.isEmpty (ICN)) { | |
| 585 | ||
| 586 | ICN = id.g etExtensio n(); | |
| 587 | } | |
| 588 | ||
| 589 | stationT okens = id .getExtens ion().spli t(CAP_REGE X_CONST); | |
| 590 | ||
| 591 | if (stat ionTokens != null && stationTo kens.lengt h > 0) { | |
| 592 | ||
| 593 | for (int i = 0; i < stationTok ens.length ; i++) { | |
| 594 | ||
| 595 | if (i == 2) { | |
| 596 | stat iondIdBuff er.append( stationTok ens[i]); | |
| 597 | if ( stationdId Buffer.len gth() > 0) { | |
| 598 | ||
| 599 | statio ndIdBuffer .append(CA P_CHARACTE R); | |
| 600 | } | |
| 601 | ||
| 602 | brea k; | |
| 603 | ||
| 604 | } else { | |
| 605 | ||
| 606 | cont inue; | |
| 607 | } | |
| 608 | } | |
| 609 | } | |
| 610 | ||
| 611 | } | |
| 612 | ||
| 613 | statio nIds = sta tiondIdBuf fer.toStri ng(); | |
| 614 | ||
| 615 | if (st ationIds.e ndsWith(CA P_CHARACTE R)) { | |
| 616 | stationI ds = stati onIds.subs tring(0, s tationIds. length() - 1); | |
| 617 | } | |
| 618 | if (IC N != null) { | |
| 619 | ICN = IC N.substrin g(0, ICN.i ndexOf(CAP _CHARACTER )); | |
| 620 | }; | |
| 621 | ||
| 622 | patien tSearchRes ults.setSt ationIds(s tationIds) ; | |
| 623 | ||
| 624 | patien tSearchRes ults.setIC N(ICN); | |
| 625 | ||
| 626 | PRPAMT 201310UV02 Person per son = pati ent.getPat ientPerson ().getValu e(); | |
| 627 | ||
| 628 | List<S erializabl e> objs = person.get Name().get (0).getCon tent(); | |
| 629 | ||
| 630 | JAXBEl ement<Stri ng> return edElement = new JAXB Element<St ring>(give nNameQName , String.c lass, EN.c lass,EMPTY _STRING); | |
| 631 | JAXBEl ement<Stri ng> return edGivenNam eElement = new JAXBE lement<Str ing>(given NameQName, String.cl ass, EN.cl ass, EMPTY _STRING); | |
| 632 | JAXBEl ement<Stri ng> return edFamilyNa meElement = new JAXB Element<St ring>(fami lyNameQNam e, String. class,EN.c lass, EMPT Y_STRING); | |
| 633 | ||
| 634 | for (S erializabl e obj : ob js) { | |
| 635 | ||
| 636 | returned Element = (JAXBEleme nt) obj; | |
| 637 | ||
| 638 | if (give nNameQName .equals(re turnedElem ent.getNam e()) | |
| 639 | && StringUti ls.isEmpty (patientSe archResult s.getFirst Name())) { | |
| 640 | ||
| 641 | returnedGi venNameEle ment = ret urnedEleme nt; | |
| 642 | patientSea rchResults .setFirstN ame(return edGivenNam eElement.g etValue()) ; | |
| 643 | ||
| 644 | } else i f (givenNa meQName.eq uals(retur nedElement .getName() ) | |
| 645 | && StringUti ls.isEmpty (patientSe archResult s.getMiddl eName())) { | |
| 646 | ||
| 647 | returnedGi venNameEle ment = ret urnedEleme nt; | |
| 648 | patientSea rchResults .setMiddle Name(retur nedGivenNa meElement. getValue() ); | |
| 649 | ||
| 650 | } | |
| 651 | else if (familyNam eQName.equ als(return edElement. getName()) | |
| 652 | && StringUti ls.isEmpty (patientSe archResult s.getLastN ame())) { | |
| 653 | ||
| 654 | returnedFa milyNameEl ement = re turnedElem ent; | |
| 655 | patientSea rchResults .setLastNa me(returne dFamilyNam eElement.g etValue()) ; | |
| 656 | } | |
| 657 | ||
| 658 | } | |
| 659 | ||
| 660 | // get date of b irth | |
| 661 | String dateOfBir th = perso n.getBirth Time().get Value(); | |
| 662 | ||
| 663 | if (nu ll != date OfBirth) { | |
| 664 | ||
| 665 | patientS earchResul ts.setDate OfBirth(da teOfBirth) ; | |
| 666 | } | |
| 667 | ||
| 668 | // Soc ial SN | |
| 669 | String socSecNum = EMPTY_S TRING; | |
| 670 | List<P RPAMT20131 0UV02Other IDs> other IDs = pers on.getAsOt herIDs(); | |
| 671 | ||
| 672 | for (P RPAMT20131 0UV02Other IDs id : o therIDs) { | |
| 673 | if (SSN_ CONST.equa lsIgnoreCa se(id.getC lassCode() .get(0))) { | |
| 674 | socSecNum = id.getId ().get(0). getExtensi on(); | |
| 675 | patientSea rchResults .setSocSec Num(socSec Num); | |
| 676 | break; | |
| 677 | } | |
| 678 | ||
| 679 | } | |
| 680 | ||
| 681 | // bui ld up the result obj ect. | |
| 682 | patien tSearchRes ults.setQu eryReturnC ode(acknow ledgementC ode); | |
| 683 | ||
| 684 | // cle an up. | |
| 685 | return edElement = null; | |
| 686 | return edGivenNam eElement = null; | |
| 687 | return edFamilyNa meElement = null; | |
| 688 | statio nIds = nul l; | |
| 689 | givenN ameQName = null; | |
| 690 | family NameQName = null; | |
| 691 | ||
| 692 | ICN = null; | |
| 693 | mviReq uestObj = null; | |
| 694 | mviRes ponseObj = null; | |
| 695 | acknow ledgementC ode = null ; | |
| 696 | dateOf Birth = nu ll; | |
| 697 | ||
| 698 | } // End Happy Path | |
| 699 | else if (QE_ST ATUS.equal sIgnoreCas e(acknowle dgementCod e)) { | |
| 700 | // Que ry Error | |
| 701 | patien tSearchRes ults.setQu eryReturnC ode(acknow ledgementC ode); | |
| 702 | } | |
| 703 | ||
| 704 | else if (AE_ST ATUS.equal sIgnoreCas e(acknowle dgementCod e)) { | |
| 705 | // App lication E rror | |
| 706 | patien tSearchRes ults.setQu eryReturnC ode(acknow ledgementC ode); | |
| 707 | } | |
| 708 | ||
| 709 | else if (NF_ST ATUS.equal sIgnoreCas e(acknowle dgementCod e)) { | |
| 710 | // No Record Fou nd | |
| 711 | patien tSearchRes ults.setQu eryReturnC ode(acknow ledgementC ode); | |
| 712 | } | |
| 713 | ||
| 714 | retu rn patient SearchResu lts; | |
| 715 | ||
| 716 | } | |
| 717 | ||
| 718 | /* | |
| 719 | * TLS Setti ngs. The r eason why it's down within jav a and not cxf xml is | |
| 720 | * because o f more fle xibility i n terms of file path s and othe r variable s. | |
| 721 | * / | |
| 722 | ||
| 723 | /* * | |
| 724 | * The metho d to setup TLS relat ed setting s. | |
| 725 | * | |
| 726 | * @param po rt | |
| 727 | * @throws F ileNotFoun dException | |
| 728 | * @throws I OException | |
| 729 | * @throws G eneralSecu rityExcept ion | |
| 730 | * / | |
| 731 | pr ivate void setupTLS( VAIdMPort port, Prop erties pro perties) t hrows File NotFoundEx ception, I OException , GeneralS ecurityExc eption { | |
| 732 | ||
| 733 | Clas sLoader cl assloader = this.get Class().ge tClassLoad er(); | |
| 734 | ||
| 735 | File file = ne w File(cla ssloader.g etResource (propertie s.getPrope rty(KEYSTO RE_FILE_NA ME_PROPERT Y).trim()) .getFile() ); | |
| 736 | HTTP Conduit ht tpConduit = (HTTPCon duit) Clie ntProxy.ge tClient(po rt).getCon duit(); | |
| 737 | ||
| 738 | // W e do two F ileInpustr eams other wise it gi ves EOFExc eption as the file | |
| 739 | // i s read twi ce. | |
| 740 | ||
| 741 | ||
| 742 | File InputStrea m fileIn1 = null; | |
| 743 | File InputStrea m fileIn2 = null; | |
| 744 | TLSC lientParam eters tlsC P = new TL SClientPar ameters(); | |
| 745 | Stri ng keyPass wd = prope rties.getP roperty(KE YSTORE_PAS SWD_PROPER TY).trim() ; | |
| 746 | KeyS tore keySt ore = KeyS tore.getIn stance(KEY STORE_FILE _TYPE); | |
| 747 | ||
| 748 | try { | |
| 749 | file In1 = new FileInputS tream(file ); | |
| 750 | keyS tore.load( fileIn1, k eyPasswd.t oCharArray ()); | |
| 751 | KeyM anager[] m yKeyManage rs = getKe yManagers( keyStore, keyPasswd) ; | |
| 752 | tlsC P.setKeyMa nagers(myK eyManagers ); | |
| 753 | } fi nally { | |
| 754 | if (nu ll != file In1) { | |
| 755 | StreamUt ilities.sa feClose(fi leIn1); | |
| 756 | } | |
| 757 | } | |
| 758 | ||
| 759 | try { | |
| 760 | file In2 = new FileInputS tream(file ); | |
| 761 | KeyS tore trust Store = Ke yStore.get Instance(K EYSTORE_FI LE_TYPE); | |
| 762 | trus tStore.loa d(fileIn2, keyPasswd .toCharArr ay()); | |
| 763 | Trus tManager[] myTrustSt oreKeyMana gers = get TrustManag ers(trustS tore); | |
| 764 | tlsC P.setTrust Managers(m yTrustStor eKeyManage rs); | |
| 765 | http Conduit.se tTlsClient Parameters (tlsCP); | |
| 766 | } fi nally { | |
| 767 | if (nu ll != file In2) { | |
| 768 | StreamUt ilities.sa feClose(fi leIn2); | |
| 769 | } | |
| 770 | } | |
| 771 | ||
| 772 | file = null; | |
| 773 | tlsC P = null; | |
| 774 | ||
| 775 | } | |
| 776 | ||
| 777 | pr ivate Trus tManager[] getTrustM anagers(Ke yStore tru stStore) t hrows NoSu chAlgorith mException , KeyStore Exception { | |
| 778 | Stri ng alg = K eyManagerF actory.get DefaultAlg orithm(); | |
| 779 | Trus tManagerFa ctory fac = TrustMan agerFactor y.getInsta nce(alg); | |
| 780 | fac. init(trust Store); | |
| 781 | retu rn fac.get TrustManag ers(); | |
| 782 | } | |
| 783 | ||
| 784 | pr ivate KeyM anager[] g etKeyManag ers(KeySto re keyStor e, String keyPasswor d) | |
| 785 | throws GeneralSe curityExce ption, IOE xception { | |
| 786 | Stri ng alg = K eyManagerF actory.get DefaultAlg orithm(); | |
| 787 | char [] keyPass = keyPass word != nu ll ? keyPa ssword.toC harArray() : null; | |
| 788 | KeyM anagerFact ory fac = KeyManager Factory.ge tInstance( alg); | |
| 789 | fac. init(keySt ore, keyPa ss); | |
| 790 | retu rn fac.get KeyManager s(); | |
| 791 | } | |
| 792 | ||
| 793 | ||
| 794 | ||
| 795 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.