1. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 1/25/2018 6:22:42 AM 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.

1.1 Files compared

# Location File Last Modified
1 CIF Build 5 Sprint 4.zip\CIF B5S4\VA.PPMS.DataWebServiceSwaggerVersioning.zip\VA.PPMS.DataWebServiceSwaggerVersioning\VA.PPMS.DataWebServiceSwaggerVersioning\PpmsDataService\VA.PPMS.Context PpmsContextHelper.cs Wed Jan 17 22:57:26 2018 UTC
2 CIF Build 5 Sprint 4.zip\CIF B5S4\VA.PPMS.DataWebServiceSwaggerVersioning.zip\VA.PPMS.DataWebServiceSwaggerVersioning\VA.PPMS.DataWebServiceSwaggerVersioning\PpmsDataService\VA.PPMS.Context PpmsContextHelper.cs Tue Jan 23 14:55:49 2018 UTC

1.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 5 222
Changed 4 16
Inserted 0 0
Removed 0 0

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

1.4 Active regular expressions

No regular expressions were active.

1.5 Comparison detail

  1   using Syst em;
  2   using Micr osoft.Xrm. Sdk.Client ;
  3   using Syst em.Service Model.Desc ription;
  4   using VA.P PMS.Contex t;
  5   using Micr osoft.Azur e.KeyVault ;
  6   using Syst em.Web.Con figuration ;
  7   using Micr osoft.Iden tityModel. Clients.Ac tiveDirect ory;
  8   using Syst em.Threadi ng.Tasks;
  9   using Micr osoft.Xrm. Sdk;
  10   using Micr osoft.Xrm. Sdk.Query;
  11   using Micr osoft.Xrm. Sdk.WebSer viceClient ;
  12  
  13  
  14   namespace  PpmsDataSe rvice.VA.P PMS.Contex t
  15   {
  16       public  class Ppm sContextHe lper
  17       {
  18           /*
  19           pr ivate cons t string O rganizatio nServiceUr i = "https ://dvagov- ppms-dev.a pi.crm9.dy namics.com /XRMServic es/2011/Or ganization .svc";
  20             private co nst string  UserName  = " REDACTED ";
  21             private co nst string  UserSecre t = " REDACTED ";
  22           */
  23  
  24           pu blic stati c async Ta sk<PpmsCon text> GetC ontext()
  25           {
  26                //return  new PpmsC ontext(Get Organizati onServiceP roxy());
  27                return n ew PpmsCon text(await  GetProxy( ));
  28           }
  29  
  30           /*
  31           pu blic stati c Organiza tionServic eProxy Get Organizati onServiceP roxy()
  32           {
  33                //var se cret =  Ge tSecretAsy nc(WebConf igurationM anager.App Settings[" SecretUri" ]);
  34  
  35                var uri  = new Uri( Organizati onServiceU ri);
  36                var clie ntCredenti als = new  ClientCred entials();
  37                  clientCred entials.Us erName.Use rName =  REDACTED ;
  38                  clientCred entials.Us erName.Pas sword =  REDACTED ;
  39  
  40                var prox y = new Or ganization ServicePro xy(uri, nu ll, client Credential s, null);
  41                proxy.En ableProxyT ypes(typeo f(Account) .Assembly) ;
  42  
  43                return p roxy;
  44           }
  45           */
  46  
  47           pu blic stati c async Ta sk<IOrgani zationServ ice> GetPr oxy()
  48           {
  49                var ap =  await Aut henticatio nParameter s.CreateFr omResource UrlAsync(n ew Uri("ht tps://dvag ov-ppms-de v.crm9.dyn amics.com/ api/data/" ));
  50                var auth orityUrl =  ap.Author ity;
  51                var reso urceUrl =  ap.Resourc e;
  52  
  53                // TODO  Substitute  your app  registrati on values  that can b e obtained  after you  register  the app in  Active Di rectory on  the Micro soft Azure  portal.
  54                  const stri ng clientI d = " REDACTED ";
  55                  const stri ng clientS ecret = "
R
E D A CTED ";
  56  
  57                //var au thContext  = new Micr osoft.Iden tityModel. Clients.Ac tiveDirect ory.Authen ticationCo ntext("htt ps://login .microsoft online.us/ e95f1b23-a baf-45ee-8 21d-b7ab25 1ab3bf", t rue);
  58                //var au thContext  = new Micr osoft.Iden tityModel. Clients.Ac tiveDirect ory.Authen ticationCo ntext("htt ps://login .microsoft online.us/ e95f1b23-a baf-45ee-8 21d-b7ab25 1ab3bf/oau th2/author ize", true );
  59                var auth Context =  new Micros oft.Identi tyModel.Cl ients.Acti veDirector y.Authenti cationCont ext(author ityUrl, tr ue, TokenC ache.Defau ltShared);
  60  
  61                var clie ntCredenti al = new C lientCrede ntial(clie ntId, clie ntSecret);
  62                //var to ken = auth Context.Ac quireToken Async("htt ps://dvago v-ppms-dev .crm9.dyna mics.com",  clientCre dential).G etAwaiter( ).GetResul t();
  63                var toke n = await  authContex t.AcquireT okenAsync( resourceUr l, clientC redential) ;
  64                var resu lt = token .AccessTok en;
  65  
  66                var clie nt = new O rganizatio nWebProxyC lient(
  67                         new Uri("h ttps://dva gov-ppms-d ev.crm9.dy namics.com /XRMServic es/2011/Or ganization .svc/web") ,
  68                         typeof(Acc ount).Asse mbly)
  69                    { He aderToken  = result } ;
  70  
  71                return c lient;
  72           }
  73  
  74           pu blic stati c async Ta sk<String>  GetToken( )
  75           {
  76                var ap =  await Aut henticatio nParameter s.CreateFr omResource UrlAsync(n ew Uri("ht tps://dvag ov-ppms-de v.crm9.dyn amics.com/ api/data/" ));
  77                var auth orityUrl =  ap.Author ity;
  78                var reso urceUrl =  ap.Resourc e;
  79  
  80                // TODO  Substitute  your app  registrati on values  that can b e obtained  after you  register  the app in  Active Di rectory on  the Micro soft Azure  portal.
  81                  const stri ng clientI d = " REDACTED ";
  82                  const stri ng clientS ecret = "
R
E D A CTED ";
  83                var auth Context =  new Authen ticationCo ntext(auth orityUrl,  true, Toke nCache.Def aultShared );
  84  
  85                var clie ntCredenti al = new C lientCrede ntial(clie ntId, clie ntSecret);
  86                var toke n = await  authContex t.AcquireT okenAsync( resourceUr l, clientC redential) ;
  87                var resu lt = token .AccessTok en;
  88                return r esult;
  89           }
  90  
  91           pu blic stati c async Ta sk<string>  GetSecret Async(stri ng secretU ri)
  92           {
  93                try
  94                {
  95                    var  keyVaultCl ient = new  KeyVaultC lient(GetT oken);
  96                    var  result = a wait keyVa ultClient. GetSecretA sync(secre tUri);
  97                    var  secret = r esult.Valu e;
  98                    retu rn secret;
  99                }
  100                catch (E xception e x)
  101                {
  102                    thro w ex;
  103                }
  104           }
  105  
  106           pu blic stati c async Ta sk<string>  GetToken( string aut hority, st ring resou rce, strin g scope)
  107           {
  108                var auth Context =  new Authen ticationCo ntext(auth ority);
  109                ClientCr edential c lientCred  = new Clie ntCredenti al(WebConf igurationM anager.App Settings[" ClientId"] ,
  110                    WebC onfigurati onManager. AppSetting s["ClientS ecret"]);
  111                Authenti cationResu lt result  = await au thContext. AcquireTok enAsync(re source, cl ientCred);
  112  
  113                if (resu lt == null )
  114                    thro w new Inva lidOperati onExceptio n("Failed  to obtain  the JWT to ken");
  115  
  116                return r esult.Acce ssToken;
  117           }
  118       }
  119   }