Produced by Araxis Merge on 3/1/2018 12:13:15 PM 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 | ehealth_xchange_cif.zip\NHIN_adapter\AdapterEJB\src\main\java\gov\va\med\nhin\adapter\policyengine | AdapterPolicyEngine.java | Thu Feb 22 14:26:30 2018 UTC |
| 2 | ehealth_xchange_cif.zip\NHIN_adapter\AdapterEJB\src\main\java\gov\va\med\nhin\adapter\policyengine | AdapterPolicyEngine.java | Wed Feb 28 17:49:30 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 662 |
| 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.n hin.adapte r.policyen gine; | |
| 2 | ||
| 3 | import gov .hhs.fha.n hinc.commo n.nhinccom mon.Assert ionType; | |
| 4 | import gov .hhs.fha.n hinc.commo n.nhinccom mon.Person NameType; | |
| 5 | import gov .hhs.fha.n hinc.commo n.nhinccom monadapter .CheckPoli cyRequestT ype; | |
| 6 | import gov .hhs.fha.n hinc.commo n.nhinccom monadapter .CheckPoli cyResponse Type; | |
| 7 | import gov .va.med.nh in.adapter .audit.Aud it; | |
| 8 | import gov .va.med.nh in.adapter .audit.Aud itManager; | |
| 9 | import gov .va.med.nh in.adapter .audit.Aud itManagerL ocal; | |
| 10 | import gov .va.med.nh in.adapter .datamanag er.DataMan ager; | |
| 11 | import gov .va.med.nh in.adapter .datamanag er.DataQue ry; | |
| 12 | import gov .va.med.nh in.adapter .datamanag er.ejb.Dat aManagerLo cal; | |
| 13 | import gov .va.med.nh in.adapter .documentr epository. Document; | |
| 14 | import gov .va.med.nh in.adapter .documentr epository. DocumentRe pository; | |
| 15 | import gov .va.med.nh in.adapter .documentr epository. DocumentRe positoryLo cal; | |
| 16 | import gov .va.med.nh in.adapter .facilitym anager.Fac ilityManag er; | |
| 17 | import gov .va.med.nh in.adapter .facilitym anager.Fac ilityManag erLocal; | |
| 18 | import gov .va.med.nh in.adapter .policyeng ine.pdppro xy.PDPProx y; | |
| 19 | import gov .va.med.nh in.adapter .policyeng ine.pdppro xy.PDPProx yLocal; | |
| 20 | import gov .va.med.nh in.adapter .propertyl ookup.Prop ertyLookup ; | |
| 21 | import gov .va.med.nh in.adapter .propertyl ookup.Prop ertyLookup Local; | |
| 22 | import gov .va.med.nh in.adapter .utils.Aud itUtil; | |
| 23 | import gov .va.med.nh in.adapter .utils.Nul lChecker; | |
| 24 | ||
| 25 | import jav a.util.Dat e; | |
| 26 | import jav a.util.Lis t; | |
| 27 | import jav a.util.Map ; | |
| 28 | ||
| 29 | import jav ax.ejb.EJB ; | |
| 30 | import jav ax.ejb.*; | |
| 31 | import jav ax.jws.Web Service; | |
| 32 | ||
| 33 | import org .slf4j.Log ger; | |
| 34 | import org .slf4j.Log gerFactory ; | |
| 35 | ||
| 36 | import oas is.names.t c.xacml._2 _0.context .schema.os .ActionTyp e; | |
| 37 | import oas is.names.t c.xacml._2 _0.context .schema.os .Attribute Type; | |
| 38 | import oas is.names.t c.xacml._2 _0.context .schema.os .Attribute ValueType; | |
| 39 | import oas is.names.t c.xacml._2 _0.context .schema.os .RequestTy pe; | |
| 40 | import oas is.names.t c.xacml._2 _0.context .schema.os .ResourceT ype; | |
| 41 | import oas is.names.t c.xacml._2 _0.context .schema.os .ResponseT ype; | |
| 42 | import oas is.names.t c.xacml._2 _0.context .schema.os .SubjectTy pe; | |
| 43 | ||
| 44 | /** | |
| 45 | * | |
| 46 | * @author David Vaz quez | |
| 47 | * | |
| 48 | * inputs checkPolic yRequest | |
| 49 | * | |
| 50 | * returns boolean t rue author ized => De cisionType .PERMIT fa lse not au thorized | |
| 51 | * => Deci sionType.D ENY | |
| 52 | * | |
| 53 | * if the passed in ICN from t he request is found in the OPT EDIN patie nt list | |
| 54 | * then th ey are aut horized | |
| 55 | * | |
| 56 | * | |
| 57 | */ | |
| 58 | // No need for this to be a we b service right now. | |
| 59 | //@WebServ ice(servic eName = "A dapterPoli cyEngine", portName = "Adapter PolicyEngi nePortSoap ", endpoin tInterface = "gov.hh s.fha.nhin c.adapterp olicyengin e.AdapterP olicyEngin ePortType" , targetNa mespace = "urn:gov:h hs:fha:nhi nc:adapter policyengi ne", wsdlL ocation = "META-INF/ wsdl/Adapt erPolicyEn gine.wsdl" ) | |
| 60 | @Transacti onAttribut e(value = Transactio nAttribute Type.SUPPO RTS) | |
| 61 | @Stateless (name = "A dapterPoli cyEngine") | |
| 62 | public cla ss Adapter PolicyEngi ne impleme nts Adapte rPolicyEng inePortTyp eLocal | |
| 63 | { | |
| 64 | privat e static L ogger logg er = Logge rFactory.g etLogger(A dapterPoli cyEngine.c lass.getNa me()); | |
| 65 | ||
| 66 | static private f inal Strin g ACTION_A TTRIBUTE_I D = "urn:o asis:names :tc:xacml: 1.0:action :action-id "; | |
| 67 | static private f inal Strin g RESOURCE _ATTRIBUTE _ID = "urn :oasis:nam es:tc:xacm l:1.0:reso urce:resou rce-id"; | |
| 68 | static private f inal Strin g RESOURCE _DOCUMENT_ ATTRIBUTE_ ID = "urn: gov:hhs:fh a:nhinc:do cument-id" ; | |
| 69 | static private f inal Strin g RESOURCE _HOME_COMM UNITY_ATTR IBUTE_ID = "urn:gov: hhs:fha:nh inc:home-c ommunity-i d"; | |
| 70 | ||
| 71 | privat e Property Lookup pro pertyLooku p; | |
| 72 | privat e Document Repository documentR epository; | |
| 73 | privat e AuditMan ager audit Manager; | |
| 74 | privat e Facility Manager fa cilityMana ger; | |
| 75 | privat e PDPProxy pdpProxy; | |
| 76 | privat e DataMana ger dataMa nager; | |
| 77 | ||
| 78 | @EJB(b eanInterfa ce = Docum entReposit oryLocal.c lass, bean Name = "Do cumentRepo sitory") | |
| 79 | public void setD ocumentRep ository(Do cumentRepo sitory doc umentRepos itory) | |
| 80 | { | |
| 81 | th is.documen tRepositor y = docume ntReposito ry; | |
| 82 | } | |
| 83 | ||
| 84 | @EJB(b eanInterfa ce = Prope rtyLookupL ocal.class , beanName = "Proper tyFileLook up") | |
| 85 | public void setP ropertyLoo kup(Proper tyLookup p ropertyLoo kup) | |
| 86 | { | |
| 87 | th is.propert yLookup = propertyLo okup; | |
| 88 | } | |
| 89 | ||
| 90 | @EJB(b eanInterfa ce = Facil ityManager Local.clas s, beanNam e = "Facil ityManager ") | |
| 91 | public void setF acilityMan ager(Facil ityManager facilityM anager) | |
| 92 | { | |
| 93 | th is.facilit yManager = facilityM anager; | |
| 94 | } | |
| 95 | ||
| 96 | @EJB(b eanInterfa ce = Audit ManagerLoc al.class, beanName = "AuditMan ager") | |
| 97 | public void setA uditManage r(AuditMan ager audit Manager) | |
| 98 | { | |
| 99 | th is.auditMa nager = au ditManager ; | |
| 100 | } | |
| 101 | ||
| 102 | @EJB(b eanInterfa ce = PDPPr oxyLocal.c lass, bean Name = "PD PProxyVAP" ) | |
| 103 | public void setP dpProxy(PD PProxy pdp Proxy) | |
| 104 | { | |
| 105 | th is.pdpProx y = pdpPro xy; | |
| 106 | } | |
| 107 | ||
| 108 | @EJB(b eanInterfa ce = DataM anagerLoca l.class, b eanName = "DataManag er") | |
| 109 | public void setD ataManager (DataManag er dataMan ager) | |
| 110 | { | |
| 111 | th is.dataMan ager = dat aManager; | |
| 112 | } | |
| 113 | ||
| 114 | public CheckPoli cyResponse Type check Policy(Che ckPolicyRe questType checkPolic yRequest) | |
| 115 | { | |
| 116 | lo gger.debug ("checkPol icy() requ est {}", c heckPolicy Request); | |
| 117 | ||
| 118 | Re questType requestTyp e = checkP olicyReque st.getRequ est(); | |
| 119 | St ring actio n = extrac tValueFrom Action(req uestType.g etAction() , ACTION_A TTRIBUTE_I D); | |
| 120 | ||
| 121 | if (action.e qualsIgnor eCase("Doc umentRetri eveIn")) { | |
| 122 | fixResou rces(reque stType); | |
| 123 | } | |
| 124 | ||
| 125 | // FIXME - u se next 4 lines in D EV until c onnection issue is | |
| 126 | // resolved. ..and need to commen t out the pdpProxy.c heckPolicy line when | |
| 127 | // deploying to DEV. | |
| 128 | // Error sni ppet: "... but could not connec t over HTT P to serve r: | |
| 129 | // 'labws. iam. DNS ', port: ' XX '" | |
| 130 | // ResponseT ype respon se = new R esponseTyp e(); | |
| 131 | // ResultTyp e policyRe sult = new ResultTyp e(); | |
| 132 | // policyRes ult.setDec ision(Deci sionType.P ERMIT); | |
| 133 | // response. getResult( ).add(poli cyResult); | |
| 134 | Re sponseType response = pdpProxy .checkPoli cy(request Type); | |
| 135 | ||
| 136 | go v.hhs.fha. nhinc.comm on.nhincco mmonadapte r.ObjectFa ctory objF actory = n ew gov.hhs .fha.nhinc .common.nh inccommona dapter.Obj ectFactory (); | |
| 137 | ||
| 138 | Ch eckPolicyR esponseTyp e checkPol icyRespons e = objFac tory.creat eCheckPoli cyResponse Type(); | |
| 139 | ch eckPolicyR esponse.se tResponse( response); | |
| 140 | ||
| 141 | // PD Audit Report - B egin | |
| 142 | if (action.e qualsIgnor eCase("Pat ientDiscov eryOut") | | action.e qualsIgnor eCase("Pat ientDiscov eryIn")) { | |
| 143 | Audit au dit = new Audit(); | |
| 144 | audit.se tAction("C heckPolicy "); | |
| 145 | audit.se tAuditTime (new Date( )); | |
| 146 | audit.se tPatientId (extractVa lueFromRes ource(requ estType.ge tResource( ).get(0), RESOURCE_A TTRIBUTE_I D).substri ng(0, 17)) ; | |
| 147 | ||
| 148 | DataQuer y query = dataManage r.getQuery ("Composit e.findDemo graphics2" ); | |
| 149 | String i cn = extra ctValueFro mResource( requestTyp e.getResou rce().get( 0), RESOUR CE_ATTRIBU TE_ID); | |
| 150 | query.se tParameter ("icn", ic n); | |
| 151 | List<Map > results = query.ge tResults() ; | |
| 152 | if (!Nul lChecker.i sNullOrEmp ty(results )) { | |
| 153 | Map result = r esults.get (0); | |
| 154 | Map demographi cs = (Map) result.get ("demograp hics"); | |
| 155 | audi t.setPatie ntLastName ((String)d emographic s.get("nam eFamily")) ; | |
| 156 | audi t.setPatie ntGivenNam e((String) demographi cs.get("na meGiven")) ; | |
| 157 | audi t.setPatie ntSSN((Str ing)demogr aphics.get ("SSN")); | |
| 158 | audi t.setPatie ntFacility Number((St ring)resul t.get("pat ientPrefer redFacilit yNumber")) ; | |
| 159 | audi t.setPatie ntFacility Name((Stri ng)result. get("patie ntPreferre dFacilityN ame")); | |
| 160 | } | |
| 161 | ||
| 162 | String o rganizatio n = null; | |
| 163 | String d emographic Details = "icn=" + e xtractValu eFromResou rce(reques tType.getR esource(). get(0), RE SOURCE_ATT RIBUTE_ID) + ", "; | |
| 164 | ||
| 165 | Assertio nType asse rtion = ch eckPolicyR equest.get Assertion( ); | |
| 166 | if (asse rtion != n ull) { | |
| 167 | if ( assertion. getHomeCom munity() ! = null && !NullCheck er.isNullO rEmpty(ass ertion.get HomeCommun ity().getH omeCommuni tyId())) { | |
| 168 | organizati on = asser tion.getHo meCommunit y().getHom eCommunity Id(); | |
| 169 | } | |
| 170 | ||
| 171 | /* | |
| 172 | * Comme nted out f or now due to lack o f data if | |
| 173 | * (!Nul lChecker.i sNullOrEmp ty(asserti on.getSSN( ))) { | |
| 174 | * demog raphicDeta ils += "ss n=" + asse rtion.getS SN(); | |
| 175 | * demog raphicDeta ils += ", "; } else { demograp hicDetails += | |
| 176 | * "ssn= , "; } | |
| 177 | * | |
| 178 | * if (a ssertion.g etPersonNa me() != nu ll && | |
| 179 | * !Null Checker.is NullOrEmpt y(assertio n.getPerso nName(). | |
| 180 | * getFa milyName() )) { demog raphicDeta ils += "la stName=" + | |
| 181 | * asser tion.getPe rsonName() .getFamily Name(); de mographicD etails | |
| 182 | * += ", "; } else { demogra phicDetail s += "last Name=, "; } if | |
| 183 | * (asse rtion.getP ersonName( ) != null && | |
| 184 | * !Null Checker.is NullOrEmpt y(assertio n.getPerso nName(). | |
| 185 | * getGi venName()) ) { demogr aphicDetai ls += "fir stName=" + | |
| 186 | * asser tion.getPe rsonName() .getGivenN ame(); dem ographicDe tails | |
| 187 | * += ", "; } else { demogra phicDetail s += "firs tName=, "; } if | |
| 188 | * (!Nul lChecker.i sNullOrEmp ty(asserti on.getDate OfBirth()) ) { | |
| 189 | * demog raphicDeta ils += "do b=" + asse rtion.getD ateOfBirth (); | |
| 190 | * demog raphicDeta ils += ", "; } else { demograp hicDetails += | |
| 191 | * "dob= , "; } | |
| 192 | */ | |
| 193 | audi t.setUserI d(assertio n.getUserI nfo().getU serName()) ; | |
| 194 | ||
| 195 | audi t.setSyste mId(AuditU til.checkS ystemId(as sertion)); | |
| 196 | ||
| 197 | audi t.setUserR ole(assert ion.getUse rInfo().ge tRoleCoded ().getCode ()); | |
| 198 | audi t.setPurpo seForUse(a ssertion.g etPurposeO fDisclosur eCoded().g etCode()); | |
| 199 | audi t.setUserF acilityNum ber(assert ion.getUse rInfo().ge tOrg().get HomeCommun ityId()); | |
| 200 | audi t.setUserF acilityNam e(assertio n.getUserI nfo().getO rg().getNa me()); | |
| 201 | if ( assertion. getUserInf o().getPer sonName() != null) { | |
| 202 | PersonName Type perso nName = as sertion.ge tUserInfo( ).getPerso nName(); | |
| 203 | if (!NullC hecker.isN ullOrEmpty (personNam e.getFullN ame())) { | |
| 204 | audit. setUserNam e(personNa me.getFull Name()); | |
| 205 | } | |
| 206 | else { | |
| 207 | String Builder us erName = n ew StringB uilder(); | |
| 208 | ||
| 209 | if (Nu llChecker. isNotNullO rEmpty(per sonName.ge tGivenName ())) { | |
| 210 | us erName.app end(person Name.getGi venName()) ; | |
| 211 | } | |
| 212 | ||
| 213 | if (Nu llChecker. isNotNullO rEmpty(per sonName.ge tFamilyNam e())) { | |
| 214 | if (userName .length() > 0) { | |
| 215 | userName .append(' '); | |
| 216 | } | |
| 217 | ||
| 218 | us erName.app end(person Name.getFa milyName() ); | |
| 219 | } | |
| 220 | ||
| 221 | audit. setUserNam e(userName .toString( )); | |
| 222 | } | |
| 223 | } | |
| 224 | } | |
| 225 | ||
| 226 | // If As sertion Or ganization is empty, assume VA | |
| 227 | if (Null Checker.is NullOrEmpt y(organiza tion)) { | |
| 228 | orga nization = facilityM anager.get FacilityBy FacilityNu mber("VA") .getFullHo meCommunit yId(); | |
| 229 | } | |
| 230 | audit.se tOrganizat ionId(orga nization); | |
| 231 | ||
| 232 | // PD Ou t External Org | |
| 233 | String e xternalOrg anization = null; | |
| 234 | if (acti on.equalsI gnoreCase( "PatientDi scoveryOut ")) { | |
| 235 | exte rnalOrgani zation = " urn:oid:" + extractV alueFromRe source(req uestType.g etResource ().get(0), RESOURCE_ HOME_COMMU NITY_ATTRI BUTE_ID); | |
| 236 | } | |
| 237 | else { | |
| 238 | exte rnalOrgani zation = f acilityMan ager.getFa cilityByFa cilityNumb er("VA").g etFullHome CommunityI d(); | |
| 239 | } | |
| 240 | audit.se tRemoteOrg anizationI d(external Organizati on); | |
| 241 | ||
| 242 | // Get C heckPolicy Decision | |
| 243 | String r esponseVal ue = null; | |
| 244 | if (chec kPolicyRes ponse != n ull && che ckPolicyRe sponse.get Response() != null & & checkPol icyRespons e.getRespo nse().getR esult() != null && c heckPolicy Response.g etResponse ().getResu lt().get(0 ) != null && checkPo licyRespon se.getResp onse().get Result().g et(0).getD ecision() != null && !NullChec ker.isNull OrEmpty(ch eckPolicyR esponse.ge tResponse( ).getResul t().get(0) .getDecisi on().value ())) { | |
| 245 | resp onseValue = checkPol icyRespons e.getRespo nse().getR esult().ge t(0).getDe cision().v alue(); | |
| 246 | } | |
| 247 | ||
| 248 | // Build Details F ield | |
| 249 | String d etails = " "; | |
| 250 | if (!Nul lChecker.i sNullOrEmp ty(respons eValue)) { | |
| 251 | deta ils += res ponseValue + " "; | |
| 252 | } | |
| 253 | ||
| 254 | if (!Nul lChecker.i sNullOrEmp ty(action) ) { | |
| 255 | deta ils += act ion + " "; | |
| 256 | } | |
| 257 | ||
| 258 | if (!Nul lChecker.i sNullOrEmp ty(externa lOrganizat ion)) { | |
| 259 | deta ils += "Re mote Facil ity=" + ex ternalOrga nization + " "; | |
| 260 | } | |
| 261 | ||
| 262 | if (!Nul lChecker.i sNullOrEmp ty(demogra phicDetail s)) { | |
| 263 | deta ils += dem ographicDe tails + " "; | |
| 264 | } | |
| 265 | ||
| 266 | audit.se tDetails(d etails); | |
| 267 | ||
| 268 | auditMan ager.store Audit(audi t); | |
| 269 | } | |
| 270 | ||
| 271 | // PD Audit Report - E nd | |
| 272 | re turn check PolicyResp onse; | |
| 273 | } | |
| 274 | ||
| 275 | privat e void fix Resources( RequestTyp e requestT ype) | |
| 276 | { | |
| 277 | fo r (Resourc eType reso urceType : requestTy pe.getReso urce()) { | |
| 278 | String p atientId = extractVa lueFromRes ource(reso urceType, RESOURCE_A TTRIBUTE_I D); | |
| 279 | ||
| 280 | if (Null Checker.is NullOrEmpt y(patientI d)) { | |
| 281 | Stri ng documen tId = extr actValueFr omResource (resourceT ype, RESOU RCE_DOCUME NT_ATTRIBU TE_ID); | |
| 282 | if ( !NullCheck er.isNullO rEmpty(doc umentId)) { | |
| 283 | Document d ocument = documentRe pository.g etDocument ByDocument UniqueId(d ocumentId) ; | |
| 284 | if (docume nt != null ) { | |
| 285 | Attrib uteType at tribute = new Attrib uteType(); | |
| 286 | attrib ute.setAtt ributeId(R ESOURCE_AT TRIBUTE_ID ); | |
| 287 | ||
| 288 | Attrib uteValueTy pe attribu teValue = new Attrib uteValueTy pe(); | |
| 289 | attrib uteValue.g etContent( ).add(qual ifyPatient Id(documen t.getPatie ntId())); | |
| 290 | attrib ute.getAtt ributeValu e().add(at tributeVal ue); | |
| 291 | ||
| 292 | resour ceType.get Attribute( ).add(attr ibute); | |
| 293 | } | |
| 294 | } | |
| 295 | } | |
| 296 | } | |
| 297 | } | |
| 298 | ||
| 299 | privat e String e xtractValu eFromActio n(ActionTy pe actionT ype, Strin g key) | |
| 300 | { | |
| 301 | re turn extra ctValueFro mAttribute s(actionTy pe.getAttr ibute(), k ey); | |
| 302 | } | |
| 303 | ||
| 304 | privat e String e xtractValu eFromSubje ct(Subject Type subje ctType, St ring key) | |
| 305 | { | |
| 306 | re turn extra ctValueFro mAttribute s(subjectT ype.getAtt ribute(), key); | |
| 307 | } | |
| 308 | ||
| 309 | privat e String e xtractValu eFromResou rce(Resour ceType res ourceType, String ke y) | |
| 310 | { | |
| 311 | re turn extra ctValueFro mAttribute s(resource Type.getAt tribute(), key); | |
| 312 | } | |
| 313 | ||
| 314 | privat e String e xtractValu eFromAttri butes(List <Attribute Type> attr ibutes, St ring key) | |
| 315 | { | |
| 316 | St ring ret = null; | |
| 317 | ||
| 318 | fo r (Attribu teType att ribute : a ttributes) { | |
| 319 | if (attr ibute != n ull && att ribute.get AttributeI d() != nul l && attri bute.getAt tributeId( ).equalsIg noreCase(k ey) && !Nu llChecker. isNullOrEm pty(attrib ute.getAtt ributeValu e()) && !N ullChecker .isNullOrE mpty(attri bute.getAt tributeVal ue().get(0 )) && !Nul lChecker.i sNullOrEmp ty(attribu te.getAttr ibuteValue ().get(0). getContent ())) { | |
| 320 | ret = attribut e.getAttri buteValue( ).get(0).g etContent( ).get(0).t oString(); | |
| 321 | brea k; | |
| 322 | } | |
| 323 | } | |
| 324 | ||
| 325 | re turn ret; | |
| 326 | } | |
| 327 | ||
| 328 | privat e String q ualifyPati entId(Stri ng icn) | |
| 329 | { | |
| 330 | re turn "'" + icn + "^^ ^&" + prop ertyLookup .getProper ty("HomeCo mmunityId" ) + "&ISO' "; | |
| 331 | } | |
| 332 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.