377. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 7/6/2017 8:23:02 PM 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.

377.1 Files compared

# Location File Last Modified
1 OSCIF_CTT_v4_build 1.zip\ISAAC-rest\src\main\java\gov\vha\isaac\rest\session PrismeIntegratedUserService.java Wed May 31 03:58:36 2017 UTC
2 OSCIF_CTT_v4_build 1.zip\ISAAC-rest\src\main\java\gov\vha\isaac\rest\session PrismeIntegratedUserService.java Mon Jul 3 21:58:55 2017 UTC

377.2 Comparison summary

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

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

377.4 Active regular expressions

No regular expressions were active.

377.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   package go v.vha.isaa c.rest.ses sion;
  20  
  21   import jav a.io.IOExc eption;
  22   import jav a.net.URL;
  23   import jav a.util.Col lections;
  24   import jav a.util.Has hSet;
  25   import jav a.util.Opt ional;
  26   import jav a.util.Set ;
  27   import jav a.util.UUI D;
  28  
  29   import jav ax.inject. Singleton;
  30  
  31   import org .apache.lo gging.log4 j.LogManag er;
  32   import org .apache.lo gging.log4 j.Logger;
  33   import org .glassfish .hk2.api.R ank;
  34   import org .jvnet.hk2 .annotatio ns.Service ;
  35  
  36   import com .fasterxml .jackson.c ore.JsonPa rseExcepti on;
  37   import com .fasterxml .jackson.d atabind.Js onMappingE xception;
  38  
  39   import gov .vha.isaac .ochre.api .LookupSer vice;
  40   import gov .vha.isaac .ochre.api .User;
  41   import gov .vha.isaac .ochre.api .UserCache ;
  42   import gov .vha.isaac .ochre.api .UserRole;
  43  
  44   /**
  45    * The Cla ss PrismeI ntegratedU serService
  46    *
  47    * {@link  PrismeInte gratedUser Service}
  48    * 
  49    * @author  <a href=" mailto:joe l.kniaz.li st@gmail.c om">Joel K niaz</a>
  50    */
  51   @Service(n ame="rest- prismeUser Service")
  52   @Rank(valu e = 10)
  53   @Singleton
  54   public cla ss PrismeI ntegratedU serService  implement s PrismeUs erService  {
  55           pr ivate stat ic Logger  log = LogM anager.get Logger(Pri smeIntegra tedUserSer vice.class );
  56           
  57           // private Pr operties p rismePrope rties_ = n ull;
  58  
  59           pr otected Pr ismeIntegr atedUserSe rvice() {
  60                    //fo r HK2
  61           }
  62  
  63           /*  (non-Java doc)
  64            *  @see gov. vha.isaac. rest.sessi on.PrismeU serService #getUser(j ava.lang.S tring)
  65            *  
  66            *  This impl ementation  will fail  if PRISME  is not co nfigured
  67            * /
  68           @O verride
  69           pu blic Optio nal<User>  getUser(St ring ssoTo ken) {
  70                    try  {
  71                             return  getUserFr omPrisme(s soToken);
  72                    } ca tch (IOExc eption e)  {
  73                             throw  new Runtim eException (e);
  74                    }
  75           }
  76  
  77           /*  (non-Java doc)
  78            *  @see gov. vha.isaac. ochre.api. UserRoleSe rvice#getU serRoles(j ava.util.U UID)
  79            *  
  80            *  This meth od should  throw exce ption if t he user ha s not alre ady been c ached
  81            * /
  82           /*  (non-Java doc)
  83            *  @see gov. vha.isaac. rest.sessi on.PrismeU serService #getUserRo les(java.u til.UUID)
  84            * /
  85           @O verride
  86           pu blic Set<U serRole> g etUserRole s(UUID use rId)
  87           {
  88                    retu rn LookupS ervice.get Service(Us erCache.cl ass).get(u serId).get ().getRole s();
  89           }
  90  
  91           /*  (non-Java doc)
  92            *  @see gov. vha.isaac. ochre.api. UserRoleSe rvice#getA llUserRole s()
  93            *  
  94            *  This impl ementation  gets all  roles from  PRISME IF F prisme.p roperties  is in clas spath
  95            *  and conta ins a valu e for prop erty "pris me_all_rol es_url", o therwise i t returns  all of the
  96            *  UserRole  text value s except f or "automa ted"
  97            * /
  98           /*  (non-Java doc)
  99            *  @see gov. vha.isaac. rest.sessi on.PrismeU serService #getAllUse rRoles()
  100            * /
  101           @O verride
  102           pu blic Set<U serRole> g etAllUserR oles()
  103           {
  104                    if ( usePrismeF orAllRoles ()) {
  105                             try {
  106                                      return g etAllRoles FromPrisme ();
  107                             } catc h (IOExcep tion e) {
  108                                      throw ne w RuntimeE xception(e );
  109                             }
  110                    } el se {
  111                             Set<Us erRole> av ailableRol es = new H ashSet<>() ;
  112  
  113                             for (U serRole ro le : UserR ole.values ()) {
  114                                      if (role  != UserRo le.AUTOMAT ED) { // A UTOMATED w ill not be  a PRISME  role
  115                                               availableR oles.add(r ole);
  116                                      }
  117                             }
  118  
  119                             return  Collectio ns.unmodif iableSet(a vailableRo les);
  120                    }
  121           }
  122  
  123           pr otected St ring getPr ismeAllRol esUrl() {
  124                    retu rn PrismeS erviceUtil s.getPrism ePropertie s().getPro perty("pri sme_all_ro les_url");
  125           }
  126           /*  (non-Java doc)
  127            *  @see gov. vha.isaac. rest.sessi on.PrismeU serService #usePrisme ForAllRole s()
  128            * /
  129           @O verride
  130           pu blic boole an usePris meForAllRo les() {
  131                    retu rn getPris meAllRoles Url() != n ull;
  132           }
  133           pr otected St ring getPr ismeRolesB yTokenUrl( ) {
  134                    retu rn PrismeS erviceUtil s.getPrism ePropertie s().getPro perty("pri sme_roles_ by_token_u rl");
  135           }
  136           /*  (non-Java doc)
  137            *  @see gov. vha.isaac. rest.sessi on.PrismeU serService #usePrisme ForRolesBy Token()
  138            * /
  139           @O verride
  140           pu blic boole an usePris meForRoles ByToken()  {
  141                    retu rn getPris meRolesByT okenUrl()  != null;
  142           }
  143           pr otected St ring getSs oTokenByNa meUrl() {
  144                    retu rn PrismeS erviceUtil s.getPrism ePropertie s().getPro perty("pri sme_roles_ user_url") ;
  145           }
  146           /*  (non-Java doc)
  147            *  @see gov. vha.isaac. rest.sessi on.PrismeU serService #usePrisme ForSsoToke nByName()
  148            * /
  149           @O verride
  150           pu blic boole an usePris meForSsoTo kenByName( ) {
  151                    retu rn getSsoT okenByName Url() != n ull;
  152           }
  153           /*  (non-Java doc)
  154            *  @see gov. vha.isaac. rest.sessi on.PrismeU serService #safeGetTo ken(java.l ang.String , java.lan g.String)
  155            * /
  156           @O verride
  157           pu blic Optio nal<String > safeGetT oken(Strin g id, Stri ng passwor d) {
  158                    try  {
  159                             return  Optional. of(getToke n(id, pass word));
  160                    } ca tch (Excep tion e) {
  161                             System .err.print ln(e);
  162                             e.prin tStackTrac e();
  163                             return  Optional. empty();
  164                    } 
  165           }
  166           /*  (non-Java doc)
  167            *  @see gov. vha.isaac. rest.sessi on.PrismeU serService #getToken( java.lang. String, ja va.lang.St ring)
  168            * /
  169           @O verride
  170           pu blic Strin g getToken (String id , String p assword) t hrows Exce ption {            
  171                    if ( usePrismeF orSsoToken ByName())  {
  172                             return  getUserSs oTokenFrom Prisme(id,  password) ;
  173                    } el se {
  174                             throw  new Runtim eException ("Cannot g enerate SS O token fo r " + id +  " without  access to  PRISME");
  175                    }
  176           }
  177  
  178           //  Private h elpers
  179           pr otected Op tional<Use r> getUser FromPrisme (String ss oToken) th rows JsonP arseExcept ion, JsonM appingExce ption, IOE xception {
  180   //               /*
  181   //                * E xample URL  for get_r oles_by_to ken
  182   //                 * URL url  = new URL( "https:// DNS                        get_roles_ by_token.j son?token= " + token) ;
  183   //                */
  184   //               /*
  185   //                * E xample SSO  Token
  186   //                * % 5B%22u%5Cf %5Cx8F%5Cx B1X%5C%22% 5CxC2%5CxE E%5CxFA%5C xE1%5Cx94% 5CxBF3%5Cx A9%5Cx16K% 22%2C+%22% 7EK%5CxC4% 5CxEFXk%5C x80%5CxB1% 5CxA3%5CxF 3%5Cx8D%5C xB1%5Cx7F% 5CxBC%5Cx0 2K%22%2C+% 22k%5Cf%5C xDC%5CxF7% 2CP%5CxB2% 5Cx97%5Cx9 9%5Cx99%5C xE0%5CxE1% 7C%5CxBF%5 Cx1DK%22%2 C+%22J%5Cf %5Cx9B%5Cx D8w%5Cx15% 5CxFE%5CxD 3%5CxC7%5C xDC%5CxAC% 5Cx9E%5Cx1 C%5CxD0bG% 22%5D
  187   //                */
  188   //                //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\ ":\"
D NS     \",\"type\ ":\"ssoi\" ,\"id\":10 005}";
  189                    Stri ng prismeR olesByToke nUrlStr =  getPrismeR olesByToke nUrl();
  190                    log. trace("Ret rieved fro m prisme.p roperties  prismeRole sByTokenUr lStr=\"" +  prismeRol esByTokenU rlStr + "\ "");
  191                    URL  url = new  URL(prisme RolesByTok enUrlStr);
  192                    Opti onal<User>  user = Us erServiceU tils.getUs erFromUrl( url, ssoTo ken);
  193                    log. trace("Ret rieved fro m " + pris meRolesByT okenUrlStr  + " user= \"" + user  + "\"");
  194  
  195                    if ( ! user.isP resent())  {
  196                             log.er ror("FAILE D retrievi ng User fr om " + pri smeRolesBy TokenUrlSt r);
  197                    }
  198                    retu rn user;
  199           }
  200           pr otected Se t<UserRole > getAllRo lesFromPri sme() thro ws JsonPar seExceptio n, JsonMap pingExcept ion, IOExc eption {
  201                    Stri ng prismeA llRolesUrl Str = getP rismeAllRo lesUrl();
  202                    log. trace("Ret rieved fro m prisme.p roperties  prismeAllR olesUrlStr =\"" + pri smeAllRole sUrlStr +  "\"");
  203                    URL  url = new  URL(prisme AllRolesUr lStr);
  204                    Set< UserRole>  allRolesFr omFromPris me = UserS erviceUtil s.getAllRo lesFromUrl (url);
  205                    log. trace("Ret rieved fro m " + pris meAllRoles UrlStr + "  allRolesF romFromPri sme=" + al lRolesFrom FromPrisme );
  206                    retu rn allRole sFromFromP risme;
  207           }
  208           
  209           pr otected St ring getUs erSsoToken FromPrisme (String id , String p assword) t hrows Exce ption {
  210                    Stri ng ssoToke nByNameUrl Str = getS soTokenByN ameUrl();
  211                    log. trace("Ret rieved fro m prisme.p roperties  ssoTokenBy NameUrlStr =\"" + sso TokenByNam eUrlStr +  "\"");
  212                    URL  url = new  URL(ssoTok enByNameUr lStr);
  213                    Stri ng ssoToke n = UserSe rviceUtils .getUserSs oTokenFrom Url(url, i d, passwor d);
  214                    log. trace("Ret rieved fro m " + ssoT okenByName UrlStr + "  ssoToken= \"" + ssoT oken + "\" ");
  215                    retu rn ssoToke n;
  216           }
  217   }