160. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/5/2017 12:06:40 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.

160.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\DxDataSourceProvider\main\src\java\gov\va\med\imaging\dx\rest\proxy RestTest.java Mon Dec 4 21:35:24 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\DxDataSourceProvider\main\src\java\gov\va\med\imaging\dx\rest\proxy RestTest.java Tue Dec 5 12:46:09 2017 UTC

160.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 418
Changed 1 4
Inserted 0 0
Removed 0 0

160.3 Comparison options

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

160.4 Active regular expressions

No regular expressions were active.

160.5 Comparison detail

  1   package go v.va.med.i maging.dx. rest.proxy ;
  2  
  3  
  4   import jav a.io.IOExc eption;
  5   import jav a.io.Input Stream;
  6   import jav a.io.Print Writer;
  7   import jav a.io.Strin gWriter;
  8   import jav a.net.URL;
  9   import jav a.security .GeneralSe curityExce ption;
  10   import jav a.security .KeyStore;
  11   import jav a.security .KeyStoreE xception;
  12   import jav a.security .NoSuchAlg orithmExce ption;
  13   import jav a.security .Unrecover ableKeyExc eption;
  14   import jav a.security .cert.Cert ificateExc eption;
  15  
  16   import jav ax.net.ssl .HostnameV erifier;
  17   import jav ax.net.ssl .HttpsURLC onnection;
  18   import jav ax.net.ssl .KeyManage r;
  19   import jav ax.net.ssl .KeyManage rFactory;
  20   import jav ax.net.ssl .SSLContex t;
  21   import jav ax.net.ssl .TrustMana ger;
  22   import jav ax.net.ssl .TrustMana gerFactory ;
  23   import jav ax.ws.rs.c ore.MediaT ype;
  24  
  25   import org .apache.lo gging.log4 j.LogManag er;
  26   import org .apache.lo gging.log4 j.Logger;
  27  
  28   import com .sun.jerse y.api.clie nt.Client;
  29   import com .sun.jerse y.api.clie nt.ClientR esponse;
  30   import com .sun.jerse y.api.clie nt.WebReso urce;
  31   import com .sun.jerse y.api.clie nt.config. ClientConf ig;
  32   import com .sun.jerse y.api.clie nt.config. DefaultCli entConfig;
  33   import com .sun.jerse y.client.a pache.Apac heHttpClie nt;
  34   import com .sun.jerse y.client.u rlconnecti on.HTTPSPr operties;
  35  
  36   /**
  37    * @author  vhaisltja hjb
  38    *
  39    */
  40   public abs tract clas s RestTest
  41   {
  42           pr ivate fina l static L ogger logg er = LogMa nager.getL ogger(Rest Test.class );
  43           
  44           pu blic RestT est()
  45           {
  46                    logg er.debug(  "Creating  Rest Test! ");
  47       }
  48           
  49           pr ivate stat ic KeyStor e createKe yStore(fin al URL url , final St ring passw ord) 
  50                             throws  KeyStoreE xception,  NoSuchAlgo rithmExcep tion, Cert ificateExc eption, IO Exception
  51           {
  52                    if ( url == nul l)
  53                             throw  new Illega lArgumentE xception(" Keystore u rl may not  be null") ;
  54  
  55                    KeyS tore keyst ore = KeyS tore.getIn stance("jk s");
  56                    Inpu tStream is  = null;
  57                    try
  58                    {
  59                             is = u rl.openStr eam();
  60                             keysto re.load(is , password  != null ?  password. toCharArra y() : null );
  61                    }
  62                    fina lly
  63                    {
  64                             if (is  != null)
  65                                      is.close ();
  66                    }
  67                    retu rn keystor e;
  68           }
  69                        
  70       privat e static S SLContext  createSSLC ontext(Str ing keysto refile, St ring keyst orePasswor d, 
  71                    Stri ng trustst orefile, S tring trus tstorepwd)  
  72           {
  73                    try
  74                    {
  75                             URL tr uststoreUr l = new UR L(truststo refile);
  76                             KeyMan ager[] key managers =  null;
  77                             logger .debug("ke ystoreurl= " + keysto refile);
  78                             if (ke ystorefile  != null) 
  79                             {
  80                                      URL keys toreUrl =  new URL(ke ystorefile );
  81                                      KeyStore  keystore  = createKe yStore(key storeUrl,  keystorePa ssword);
  82                                      keymanag ers = crea teKeyManag ers(keysto re, keysto rePassword );
  83                             }
  84                             
  85                             KeySto re trustst ore = crea teKeyStore (truststor eUrl, trus tstorepwd) ;
  86                             TrustM anager[] t rustmanage rs = creat eTrustMana gers(trust store);
  87                             
  88                             SSLCon text sslco ntext = SS LContext.g etInstance ("SSL");
  89                             sslcon text.init( keymanager s, trustma nagers, nu ll);
  90                             return  sslcontex t;
  91                    }
  92                    catc h (NoSuchA lgorithmEx ception e)
  93                    {
  94                             String Writer sw  = new Stri ngWriter() ;
  95                             e.prin tStackTrac e(new Prin tWriter(sw ));
  96                             logger .debug("Cr eate SSL C ontext Err or: " + sw .toString( ));
  97                    }
  98                    catc h (KeyStor eException  e)
  99                    {
  100                             String Writer sw  = new Stri ngWriter() ;
  101                             e.prin tStackTrac e(new Prin tWriter(sw ));
  102                             logger .debug("Cr eate SSL C ontext Err or: " + sw .toString( ));
  103                    }
  104                    catc h (General SecurityEx ception e)
  105                    {
  106                             String Writer sw  = new Stri ngWriter() ;
  107                             e.prin tStackTrac e(new Prin tWriter(sw ));
  108                             logger .debug("Cr eate SSL C ontext Err or: " + sw .toString( ));
  109                    }
  110                    catc h (IOExcep tion e)
  111                    {
  112                             String Writer sw  = new Stri ngWriter() ;
  113                             e.prin tStackTrac e(new Prin tWriter(sw ));
  114                             logger .debug("Cr eate SSL C ontext Err or: " + sw .toString( ));
  115                    }
  116                    
  117                    retu rn null;
  118           }
  119  
  120       privat e static K eyManager[ ] createKe yManagers( final KeyS tore keyst ore, final  String pa ssword)
  121                    thro ws KeyStor eException , NoSuchAl gorithmExc eption, Un recoverabl eKeyExcept ion
  122           {
  123                    if ( keystore = = null)
  124                             throw  new Illega lArgumentE xception(" Keystore m ay not be  null");
  125  
  126                    KeyM anagerFact ory kmfact ory = KeyM anagerFact ory.getIns tance(KeyM anagerFact ory.getDef aultAlgori thm());
  127                    kmfa ctory.init (keystore,  password  != null ?  password.t oCharArray () : null) ;
  128                    retu rn kmfacto ry.getKeyM anagers();
  129           }
  130  
  131           pr ivate stat ic TrustMa nager[] cr eateTrustM anagers(fi nal KeySto re keystor e)
  132                             throws  KeyStoreE xception,
  133                    NoSu chAlgorith mException
  134           {
  135                    if ( keystore = = null)
  136                             throw  new Illega lArgumentE xception(" Keystore m ay not be  null");
  137  
  138                    Trus tManagerFa ctory tmfa ctory = Tr ustManager Factory.ge tInstance( TrustManag erFactory. getDefault Algorithm( ));
  139                    tmfa ctory.init (keystore) ;
  140                    tmfa ctory.getT rustManage rs();
  141                    retu rn tmfacto ry.getTrus tManagers( );
  142           }
  143           
  144           pr otected Cl ientRespon se execute SslRequest (
  145                             MediaT ype mediaT ypex,
  146                             String  urlx,
  147                             String  truststor eUrl, 
  148                             String  truststor ePassword,
  149                             String  keystoreU rl, 
  150                             String  keystoreP assword)
  151           {
  152                    logg er.debug(  "Https Res t Test!");
  153           lo gger.debug ( "---- tr uststorefi le:" + tru ststoreUrl  + " pwd:  " + trusts torePasswo rd);
  154           lo gger.debug ( "---- ke ystorefile :" + keyst oreUrl + "  pwd: " +  keystorePa ssword);
  155           
  156                    Host nameVerifi er hostnam eVerifier  = HttpsURL Connection .getDefaul tHostnameV erifier();
  157           Cl ientConfig  config =  new Defaul tClientCon fig();
  158           
  159           SS LContext s slContext  = createSS LContext(n ull, null,  truststor eUrl, trus tstorePass word);
  160           co nfig.getPr operties() .put(HTTPS Properties .PROPERTY_ HTTPS_PROP ERTIES, ne w HTTPSPro perties(ho stnameVeri fier, sslC ontext));
  161                    conf ig.getProp erties().p ut(
  162                                      ClientCo nfig.PROPE RTY_CONNEC T_TIMEOUT,  30000);
  163                    conf ig.getProp erties().p ut(
  164                                      ClientCo nfig.PROPE RTY_READ_T IMEOUT, 60 000);
  165  
  166                    // A ccording t o http://j ersey.java .net/nonav /apidocs/1 .2/contrib s/jersey-a pache-clie nt/com/sun /jersey/cl ient/apach e/ApacheHt tpClient.h tml
  167                    // s ome proper ties must  be provide d in const ructor of  ApacheHttp Client           
  168                    Clie nt client  = ApacheHt tpClient.c reate(conf ig);
  169                    ((Ap acheHttpCl ient)clien t).getClie ntHandler( ).getHttpC lient().ge tParams(). setConnect ionManager Timeout(60 000);
  170                    ((Ap acheHttpCl ient)clien t).getClie ntHandler( ).getHttpC lient().ge tHttpConne ctionManag er().getPa rams().set DefaultMax Connection sPerHost(5 0);
  171                    ((Ap acheHttpCl ient)clien t).getClie ntHandler( ).getHttpC lient().ge tHttpConne ctionManag er().getPa rams().set MaxTotalCo nnections( 200);
  172           
  173           St ring url =  
  174                               "https://d as-test. DNS     /des_proxy _adapter/v 1/filter/d mix/datase rvice/v4.0 /mhs/query /123/ICN:1 008689409V 873033/347 94-8?query StartDate= 19000101&q ueryEndDat e=20170609 &requestSo urce=VADAS ";
  175                               //"http:// localhost: PORT /csp/sampl es/docserv er/v1/filt er/dmix/da taservice/ v4.0/mhs/q uery/ DNS    VIDER/:icn /:loinc";
  176     
  177                    Stri ng mediaTy pe = Media Type.APPLI CATION_JSO N;
  178  
  179           lo gger.debug ( "---- Cr eating Web Resource") ;
  180                    WebR esource we bResource  = client.r esource(ur l);
  181  
  182                    logg er.debug(  "---- Crea ting WebRe source.Bui lder reque st");
  183                    WebR esource.Bu ilder requ est = webR esource.ac cept(media Type);
  184  
  185                    logg er.debug(  "---- Exec uting get  request fo r url:" +  url + " me diaType: "  + mediaTy pe);
  186                    
  187                    try
  188                    {
  189                             Client Response r es = reque st.get(Cli entRespons e.class);
  190                             if (re s == null)
  191                             {
  192                                      logger.d ebug("****  DAS respo nse: null" );
  193                             }
  194                             else
  195                             {
  196                                      logger.d ebug("****  DAS respo nse: "  +  res.getEnt ity(String .class));
  197                             }
  198                    }
  199                    catc h (Excepti on e)
  200                    {
  201                             String Writer sw  = new Stri ngWriter() ;
  202                             e.prin tStackTrac e(new Prin tWriter(sw ));
  203                             logger .debug("Ge t Request  exception:  " + sw.to String());
  204                    }
  205                    
  206           re turn null;
  207           }
  208           
  209           
  210  
  211   }