689. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2/1/2017 2:56:56 PM Eastern 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.

689.1 Files compared

# Location File Last Modified
1 C:\Araxis_Merge_Comprasion\Pub_un\BTSSS_CIF_122016.zip\BTSSS_CIF_12_20_16\clean\CRM\trunk\SDK\SampleCode\CS\WsdlBasedProxies\Online OnlineAuthenticationPolicy.cs Tue Dec 20 19:51:47 2016 UTC
2 Wed Feb 1 19:56:56 2017 UTC

689.2 Comparison summary

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

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

689.4 Active regular expressions

No regular expressions were active.

689.5 Comparison detail

1   // ======= ========== ========== ========== ========== ========== ========== ==        
2   //        
3   //  This f ile is par t of the M icrosoft D ynamics CR M SDK code  samples.        
4   //        
5   //  Copyri ght (C) Mi crosoft Co rporation.   All righ ts reserve d.        
6   //        
7   //  This s ource code  is intend ed only as  a supplem ent to Mic rosoft        
8   //  Develo pment Tool s and/or o n-line doc umentation .  See the se other        
9   //  materi als for de tailed inf ormation r egarding M icrosoft c ode sample s.        
10   //        
11   //  THIS C ODE AND IN FORMATION  ARE PROVID ED "AS IS"  WITHOUT W ARRANTY OF  ANY        
12   //  KIND,  EITHER EXP RESSED OR  IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E        
13   //  IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR  A        
14   //  PARTIC ULAR PURPO SE.        
15   //        
16   // ======= ========== ========== ========== ========== ========== ========== ==        
17   using Syst em;        
18   using Syst em.Globali zation;        
19   using Syst em.Net;        
20   using Syst em.Xml;        
21          
22   namespace  Microsoft. Crm.Servic es.Utility        
23   {        
24       /// <s ummary>        
25       /// Mi crosoft On line (Micr osoft acco unt as wel l as Micro soft Offic e 365 a.k. a. OSDP /  OrgId)) Au thenticati on Policy         
26       /// fo r CRM Web  Services.        
27       /// </ summary>        
28       public  sealed cl ass Online Authentica tionPolicy        
29       {        
30           // / <summary >        
31           // / Construc t an Insta nce of the  OnlineAut henticatio nPolicy cl ass        
32           // / </summar y>        
33           // / <param n ame="flatW sdlUrl">UR L to the F lattened W SDL</param >        
34           pu blic Onlin eAuthentic ationPolic y(string f latWsdlUrl )        
35           {        
36                this.Ini tialize(fl atWsdlUrl) ;        
37           }        
38          
39           // / <summary >        
40           // / Construc t an Insta nce of the  OnlineAut henticatio nPolicy cl ass        
41           // / </summar y>        
42           // / <param n ame="appli esTo">Appl iesTo for  the web se rvice</par am>        
43           // / <param n ame="polic y">Microso ft account  Policy th at should  be used</p aram>        
44           // / <param n ame="issue rUri">Issu er URI tha t should b e used for  authentic ating toke ns</param>        
45           pu blic Onlin eAuthentic ationPolic y(string a ppliesTo,  string pol icy, Uri i ssuerUri)        
46           {        
47                this.App liesTo = a ppliesTo;        
48                this.Pol icy = poli cy;        
49                this.Iss uerUri = i ssuerUri;        
50           }        
51          
52           #r egion Prop erties        
53           // / <summary >        
54           // / AppliesT o value th at should  be set on  the servic e        
55           // / </summar y>        
56           pu blic strin g AppliesT o { get; p rivate set ; }        
57          
58           // / <summary >        
59           // / Microsof t account  / Org Id P olicy        
60           // / </summar y>        
61           pu blic strin g Policy {  get; priv ate set; }        
62          
63           // / <summary >        
64           // / Microsof t account  / Org Id I ssuer that  issues th e tokens        
65           // / </summar y>        
66           pu blic Uri I ssuerUri {  get; priv ate set; }        
67           #e ndregion        
68          
69           #r egion Meth ods        
70           pr ivate void  Initializ e(string f latWsdlUrl )        
71           {        
72                if (stri ng.IsNullO rWhiteSpac e(flatWsdl Url))        
73                {        
74                    thro w new Argu mentNullEx ception("f latWsdlUrl ");        
75                }        
76          
77                // Parse  the WSDL        
78                XmlDocum ent wsdl =  DownloadW sdl(flatWs dlUrl);        
79          
80                // Setup  the names pace manag er require d for exec uting quer ies        
81                XmlNames paceManage r namespac eManager =  new XmlNa mespaceMan ager(wsdl. NameTable) ;        
82                namespac eManager.A ddNamespac e("wsdl",  "http://sc hemas.xmls oap.org/ws dl/");        
83                        
84                // Fetch ing target  wsdl uri  from "wsdl :import" n ode.        
85                XmlNode  importNode  = SelectF irstNodeOr Default(ws dl.Documen tElement,  "wsdl:impo rt", names paceManage r);        
86                String t argetWsdlU ri = ReadA ttributeVa lue(import Node, "loc ation");        
87                XmlDocum ent target Wsdl = Dow nloadWsdl( targetWsdl Uri);        
88          
89                // Initi alize with  the downl oaded WSDL        
90                this.Ini tialize(fl atWsdlUrl,  targetWsd l);        
91           }        
92          
93           pr ivate void  Initializ e(string u rl, XmlDoc ument wsdl )        
94           {        
95                const st ring wsp =  "wsp";        
96                const st ring MsXrm  = "ms-xrm ";        
97                const st ring MsXrm 2012 = "ms -xrm2012";        
98                const st ring sp =  "sp";        
99                const st ring ad =  "ad";        
100                const st ring Exact lyOne = ": ExactlyOne /";        
101                const st ring All =  ":All/";        
102                const st ring Authe nticationP olicy = ": Authentica tionPolicy /";        
103                const st ring Secur eTokenServ ice = ":Se cureTokenS ervice/";        
104                const st ring Refer enceParame ters = ":R eferencePa rameters/" ;        
105                const st ring Polic yNodePath  = wsp +":P olicy";        
106                const st ring AllPa thFormat =  "{0}{1}{0 }{2}{3}";        
107                const st ring Trust PathFormat  = AllPath Format + " {4}{3}{5}{ 3}";        
108                const st ring LiveT rustPathFo rmat = Tru stPathForm at + ":Liv eTrust" ;        
109                const st ring OrgTr ustPathFor mat = Trus tPathForma t + ":OrgT rust";        
110                const st ring Issue rContainer PathFormat  = AllPath Format + " :SignedSup portingTok ens/{0}:Po licy/{3}:I ssuedToken /{3}:Issue r";        
111                        
112                const st ring LiveA ppliesToNo deName = M sXrm + ":A ppliesTo";        
113                const st ring OrgAp pliesToNod eName = Ms Xrm2012 +  ":AppliesT o";        
114                const st ring LiveP olicyNodeN ame = MsXr m + ":Live Policy";        
115                const st ring OrgPo licyNodeNa me = MsXrm 2012 + ":L ivePolicy" ;        
116          
117                const st ring LiveI dReference IssuerUriN odeName =  ad + Refer enceParame ters + MsX rm2012 + " :LiveIssue r";        
118                const st ring OrgId ReferenceI ssuerUriNo deName = a d + Refere nceParamet ers + MsXr m2012 + ": OrgIdIssue r";        
119                const st ring Addre ssIssuerUr iNodeName  = ad + ":A ddress";        
120          
121                // Setup  the names pace manag er require d for exec uting quer ies        
122                XmlNames paceManage r namespac eManager =  new XmlNa mespaceMan ager(wsdl. NameTable) ;        
123                namespac eManager.A ddNamespac e(wsp, "ht tp://schem as.xmlsoap .org/ws/20 04/09/poli cy");        
124                namespac eManager.A ddNamespac e(MsXrm, " http://sch emas.micro soft.com/x rm/2011/Co ntracts/Se rvices");        
125                namespac eManager.A ddNamespac e(MsXrm201 2, "http:/ /schemas.m icrosoft.c om/xrm/201 2/Contract s/Services ");        
126                namespac eManager.A ddNamespac e(sp, "htt p://docs.o asis-open. org/ws-sx/ ws-securit ypolicy/20 0702");        
127                namespac eManager.A ddNamespac e(ad, "htt p://www.w3 .org/2005/ 08/address ing");        
128          
129                // Retri eve the ro ot policy  node to fe tch proper ties Appli esTo, Poli cy and Iss uerUri req uired for  authentica tion.         
130                XmlNode  policyNode  = SelectF irstNodeOr Default(ws dl.Documen tElement,  PolicyNode Path, name spaceManag er);        
131                if (null  != policy Node)        
132                {        
133                    // S et authent ication ty pe to Onli neFederati on.        
134                    Bool ean authWi thOrgId =  true;                        
135                            
136                    // C onstruct t he org tru st path.        
137                    Stri ng orgIden tityProvid erTrustPat h = string .Format(Cu ltureInfo. InvariantC ulture,        
138                         OrgTrustPa thFormat,  wsp, Exact lyOne, All , MsXrm201 2, Authent icationPol icy, Secur eTokenServ ice);        
139          
140                    // R etrieve th e OrgId au thenticati on policy  (that cont ains the A ppliesTo a nd LivePol icy values ).        
141                    XmlN ode Identi tyProvider TrustConfi guration =  SelectFir stNodeOrDe fault(poli cyNode,         
142                         orgIdentit yProviderT rustPath,         
143                         namespaceM anager);        
144                                              
145                    // I f OrgId au thenticati on policy  node note  found then  try Micro soft accou nt policy  node.        
146                    if ( null == Id entityProv iderTrustC onfigurati on)        
147                    {        
148                         // Constru ct the Mic rosoft acc ount trust  path.        
149                         String liv eIdentityP roviderTru stPath = s tring.Form at(Culture Info.Invar iantCultur e,        
150                         LiveTrustP athFormat,  wsp, Exac tlyOne, Al l, MsXrm,  Authentica tionPolicy , SecureTo kenService );        
151          
152                         IdentityPr oviderTrus tConfigura tion = Sel ectFirstNo deOrDefaul t(policyNo de, liveId entityProv iderTrustP ath, names paceManage r);        
153                         // Set Onl ineFederat ion authen tication f lag to fal se.        
154                         authWithOr gId = fals e;        
155                    }        
156          
157                    if ( null != Id entityProv iderTrustC onfigurati on)        
158                    {        
159                         // Retriev e AppliesT o value ba sed on Ide ntityProvi der type.        
160                         string app liesTo = R eadNodeVal ue(Identit yProviderT rustConfig uration,         
161                             authWi thOrgId? O rgAppliesT oNodeName  : LiveAppl iesToNodeN ame,         
162                             namesp aceManager );        
163                         // Retriev e LivePoli cy value b ased on Id entityProv ider type.        
164                         string liv ePolicy =  ReadNodeVa lue(Identi tyProvider TrustConfi guration,         
165                             authWi thOrgId? O rgPolicyNo deName : L ivePolicyN odeName,         
166                             namesp aceManager );        
167          
168                         string iss uerContain erPath = s tring.Form at( Cultur eInfo.Inva riantCultu re, Issuer ContainerP athFormat,  wsp, Exac tlyOne, Al l, sp);        
169          
170                         // The iss uer contai ner node c ontains th e Issuer U RI. Since  the Discov ery Servic e exposes  both Offic e 365         
171                         // and Mic rosoft acc ount authe ntication  mechanisms , it lists  multiple  issuers. I n that cas e, the iss uer is         
172                         // listed  under the  reference  parameters . In other  scenarios , it is li sted in th e Address  node inste ad.        
173                         XmlNode is suerContai nerNode =  SelectFirs tNodeOrDef ault(polic yNode, iss uerContain erPath, na mespaceMan ager);        
174                         if (null ! = issuerCo ntainerNod e)        
175                         {        
176                             // Rea d the valu e from the  reference  parameter s. If it i s not set,  check the  Address n ode.        
177                             string  issuerUri  = ReadNod eValue(iss uerContain erNode,        
178                                 au thWithOrgI d? OrgIdRe ferenceIss uerUriNode Name : Liv eIdReferen ceIssuerUr iNodeName,        
179                                 na mespaceMan ager);        
180                                    
181                             // Try  Address n ode to fin d issuer U ri.        
182                             if (st ring.IsNul lOrWhiteSp ace(issuer Uri))        
183                             {        
184                                 is suerUri =  ReadNodeVa lue(issuer ContainerN ode, Addre ssIssuerUr iNodeName,  namespace Manager);        
185                             }        
186                             // If  the issuer  was disco vered, it  means that  all of th e required  informati on has bee n found.        
187                             if (!s tring.IsNu llOrWhiteS pace(issue rUri))        
188                             {        
189                                 th is.Initial ize(applie sTo, liveP olicy, new  Uri(issue rUri));        
190                                 re turn;        
191                             }        
192                         }        
193                    }        
194                }        
195          
196                // Some  piece of i nformation  could not  be found.        
197                throw ne w InvalidO perationEx ception(st ring.Forma t(CultureI nfo.Invari antCulture ,        
198                    "Una ble to par se the aut henticatio n policy f rom the WS DL \"{0}\" .", url));        
199           }        
200          
201           pr ivate void  Initializ e(string a ppliesTo,  string pol icy, Uri i ssuerUri)        
202           {        
203                if (stri ng.IsNullO rWhiteSpac e(appliesT o))        
204                {        
205                    thro w new Argu mentNullEx ception("a ppliesTo") ;        
206                }        
207                else if  (string.Is NullOrWhit eSpace(pol icy))        
208                {        
209                    thro w new Argu mentNullEx ception("p olicy");        
210                }        
211                else if  (null == i ssuerUri)        
212                {        
213                    thro w new Argu mentNullEx ception("i ssuerUri") ;        
214                }        
215          
216                this.App liesTo = a ppliesTo;        
217                this.Pol icy = poli cy;        
218                this.Iss uerUri = i ssuerUri;        
219           }        
220          
221           pr ivate XmlD ocument Do wnloadWsdl (string fl atWsdlUrl)        
222           {        
223                // Downl oad the Fl at WSDL to  determine  the authe ntication  policy inf ormation        
224                WebClien t client =  new WebCl ient();        
225                string w sdl;        
226                try        
227                {        
228                    wsdl  = client. DownloadSt ring(flatW sdlUrl);        
229                }        
230                catch (W ebExceptio n ex)        
231                {        
232                    thro w new Inva lidOperati onExceptio n(string.F ormat(Cult ureInfo.In variantCul ture,        
233                         "Unable to  download  the authen tication p olicy from  WSDL \"{0 }\".", fla tWsdlUrl),  ex);        
234                }        
235          
236                // Parse  the XML i nto a docu ment        
237                XmlDocum ent wsdlDo c = new Xm lDocument( );        
238                try        
239                {        
240                    wsdl Doc.LoadXm l(wsdl);        
241                }        
242                catch (X mlExceptio n ex)        
243                {        
244                    thro w new Inva lidOperati onExceptio n(string.F ormat(Cult ureInfo.In variantCul ture,        
245                         "Unable to  parse the  WSDL \"{0 }\".", fla tWsdlUrl),  ex);        
246                }        
247          
248                return w sdlDoc;        
249           }        
250          
251           pr ivate XmlN ode Select FirstNodeO rDefault(X mlNode roo t, string  path, XmlN amespaceMa nager name spaceManag er)        
252           {        
253                XmlNodeL ist nodes  = root.Sel ectNodes(p ath, names paceManage r);        
254                if (0 ==  nodes.Cou nt)        
255                {        
256                    retu rn null;        
257                }        
258          
259                return n odes[0];        
260           }        
261          
262           pr ivate stri ng ReadNod eValue(Xml Node paren t, string  nodeName,  XmlNamespa ceManager  namespaceM anager)        
263           {        
264                XmlNode  node = Sel ectFirstNo deOrDefaul t(parent,  nodeName,  namespaceM anager);        
265                if (null  != node)        
266                {        
267                    retu rn node.In nerText;        
268                }        
269          
270                return n ull;        
271           }        
272          
273           pr ivate stri ng ReadAtt ributeValu e(XmlNode  parent, st ring attri buteName)        
274           {        
275                XmlAttri bute attri bute = par ent.Attrib utes[attri buteName];        
276                if (null  != attrib ute)        
277                {        
278                    retu rn attribu te.InnerTe xt;        
279                }        
280                return n ull;        
281           }        
282           #e ndregion        
283       }        
284   }