122. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/18/2018 3:37:04 PM Eastern 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.

122.1 Files compared

# Location File Last Modified
1 CTT_DM2_v7.zip\VUID-rest\src\main\java\gov\vha\vuid\rest\session UserServiceUtils.java Tue Jun 12 16:41:56 2018 UTC
2 CTT_DM2_v7.zip\VUID-rest\src\main\java\gov\vha\vuid\rest\session UserServiceUtils.java Fri Jun 15 21:23:30 2018 UTC

122.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 4 214
Changed 3 6
Inserted 0 0
Removed 0 0

122.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

122.4 Active regular expressions

No regular expressions were active.

122.5 Comparison detail

  1   /**
  2    * Copyrig ht Notice
  3    *
  4    * This is  a work of  the U.S.  Government  and is no t subject  to copyrig ht
  5    * protect ion in the  United St ates. Fore ign copyri ghts may a pply.
  6    * 
  7    * License d under th e Apache L icense, Ve rsion 2.0  (the "Lice nse");
  8    * you may  not use t his file e xcept in c ompliance  with the L icense.
  9    * You may  obtain a  copy of th e License  at
  10    *
  11    * http:// www.apache .org/licen ses/LICENS E-2.0
  12    *
  13    * Unless  required b y applicab le law or  agreed to  in writing , software
  14    * distrib uted under  the Licen se is dist ributed on  an "AS IS " BASIS,
  15    * WITHOUT  WARRANTIE S OR CONDI TIONS OF A NY KIND, e ither expr ess or imp lied.
  16    * See the  License f or the spe cific lang uage gover ning permi ssions and
  17    * limitat ions under  the Licen se.
  18    */
  19  
  20   package go v.vha.vuid .rest.sess ion;
  21  
  22   import jav a.io.IOExc eption;
  23   import jav a.net.URL;
  24   import jav a.util.Col lection;
  25   import jav a.util.Has hMap;
  26   import jav a.util.Has hSet;
  27   import jav a.util.Map ;
  28   import jav a.util.Opt ional;
  29   import jav a.util.Set ;
  30   import jav a.util.UUI D;
  31  
  32   import org .apache.lo gging.log4 j.LogManag er;
  33   import org .apache.lo gging.log4 j.Logger;
  34  
  35   import com .fasterxml .jackson.c ore.JsonPa rseExcepti on;
  36   import com .fasterxml .jackson.d atabind.Js onMappingE xception;
  37   import com .fasterxml .jackson.d atabind.Ob jectMapper ;
  38  
  39   import gov .vha.isaac .ochre.api .User;
  40   import gov .vha.isaac .ochre.api .Get;
  41   import gov .vha.isaac .ochre.api .PrismeRol e;
  42   import gov .vha.isaac .ochre.api .bootstrap .TermAux;
  43   import gov .vha.isaac .ochre.api .util.Uuid T5Generato r;
  44   import gov .vha.isaac .rest.util s.CommonPr ismeServic eUtils;
  45  
  46   /**
  47    * 
  48    * {@link  UserServic eUtils}
  49    *
  50    * @author  <a href=" mailto:joe l.kniaz.li st@gmail.c om">Joel K niaz</a>
  51    *
  52    */
  53   public cla ss UserSer viceUtils  {
  54           
  55           pr ivate stat ic Logger  log = LogM anager.get Logger(Use rServiceUt ils.class) ;
  56           
  57           st atic User  getUserFro mJson(Stri ng jsonToU se, String  ssoToken)  throws Js onParseExc eption, Js onMappingE xception,  IOExceptio n {
  58                    Obje ctMapper m apper = ne w ObjectMa pper();
  59                    Map< ?, ?> map  = null;
  60                    map  = mapper.r eadValue(j sonToUse,  Map.class) ;
  61                    
  62                    Stri ng userNam e = (Strin g)map.get( "user");
  63                    Set< PrismeRole > roleSet  = new Hash Set<>();
  64                    Coll ection<?>  roles = (C ollection< ?>)map.get ("roles");
  65                    for  (Object ro leMapObjec t : roles)  {
  66                             Map<?, ?> roleMap  = (Map<?, ?>)roleMap Object;
  67                             String  roleName  = (String) roleMap.ge t("name");
  68                             Option al<PrismeR ole> found Role = Pri smeRole.sa feValueOf( roleName);
  69                             
  70                             if (fo undRole.is Present())  {
  71                                      roleSet. add(foundR ole.get()) ;
  72                             }
  73                             else
  74                             {
  75                                      log.warn ("Not addi ng unknown  role '{}'  to user ' {}'", role Name, user Name);
  76                             }
  77                    }
  78                    
  79                    fina l UUID uui dFromUserF sn = UserS erviceUtil s.getUuidF romUserNam e(userName );;
  80           
  81                    User  newUser =  new User( userName,  uuidFromUs erFsn, sso Token, rol eSet);
  82                    
  83                    retu rn newUser ;
  84           }
  85  
  86           st atic UUID  getUuidFro mUserName( String use rName) {
  87                    retu rn UuidT5G enerator.g et(TermAux .USER.getP rimordialU uid(), use rName);
  88           }
  89  
  90           st atic User  getUserFro mUrl(URL u rl, String  ssoToken)  throws Js onParseExc eption, Js onMappingE xception,  IOExceptio n {
  91   //               /*
  92   //                * E xample URL  for get_r oles_by_to ken
  93   //                 * URL url  = new URL( "https:// DNS                        /rails_pri sme/roles/ get_roles_ by_token.j son?token= " + token) ;
  94   //                */
  95   //               /*
  96   //                * E xample SSO  Token
  97   //                * A I
  98   //                */
  99   //                //String j son = "{\" roles\":[{ \"id\":100 00,\"name\ ":\"read_o nly\",\"re source_id\ ":null,\"r esource_ty pe\":null, \"created_ at\":\"201 6-09-13T14 :48:18.000 Z\",\"upda ted_at\":\ "2016-09-1 3T14:48:18 .000Z\"}], \"token_pa rsed?\":tr ue,\"user\ ":\" DN S      ArmbrD\",\ "type\":\" ssoi\",\"i d\":10005} ";
  100  
  101                    log. info("Atte mpting to  read user  from url ' {}'", url) ;
  102                    Map< String, St ring> para ms = new H ashMap<>() ;   
  103                    para ms.put("to ken", ssoT oken);  
  104                    para ms.put("is aac_db_uui d", "");   //We don't  know the  datastore  ID, and in  the vuid  server, we  don't car e - the vu id generat e role is  global.
  105                    log. debug("Usi ng token ' {}' and no  DB", ssoT oken);
  106                    Stri ng jsonRes ultString  = PrismeSe rviceUtils .getResult JsonFromPr isme(Commo nPrismeSer viceUtils. getTargetF romUrl(url ), url.get Path(), pa rams);
  107                    
  108                    retu rn UserSer viceUtils. getUserFro mJson(json ResultStri ng, ssoTok en);
  109           }
  110   }