13.07.2015 Views

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

Applied XML Programming for Microsoft .NET.pdf - Csbdu.in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

To avoid thread<strong>in</strong>g risks, be aware that load<strong>in</strong>g a style sheet is an unprotectedoperation. Either lock the operation yourself, or avoid spawn<strong>in</strong>g concurrent threads thatper<strong>for</strong>m style sheet load<strong>in</strong>g on the same processor.Security ConsiderationsThe XslTrans<strong>for</strong>m class has a l<strong>in</strong>k demand permission set attached. A l<strong>in</strong>k demandspecifies which permissions direct callers must have to run the code, as shown <strong>in</strong> thefollow<strong>in</strong>g example. Callers' rights are checked dur<strong>in</strong>g just-<strong>in</strong>-time compilation.[PermissionSet(SecurityAction.L<strong>in</strong>kDemand, Name="FullTrust")]public sealed class XslTrans<strong>for</strong>m{}⋮The permission set attribute <strong>for</strong> the XslTrans<strong>for</strong>m class is expressed by name andpo<strong>in</strong>ts to one of the built-<strong>in</strong> permission sets— FullTrust. What does this mean to you?Only callers (direct callers are <strong>in</strong>volved with the check, not caller's callers) with fullytrusted access to all the local resources can safely call <strong>in</strong>to the XSLT processor.Try runn<strong>in</strong>g the XSLT Quick Security Tester sample application over a network.Because of the class security sett<strong>in</strong>gs, a security exception is thrown. Figure 7-5 showsthe security exception dialog box.Figure 7-5: The XSLT processor class works only if called by locally trusted callers. AnXSLT application can work well as long as you <strong>in</strong>voke it locally, but it will raise a securityexception if you run it over a network share.Under the Hood of the XSLT ProcessorIn the overall behavior of the .<strong>NET</strong> Framework XSLT processor, three phases can beclearly identified: load<strong>in</strong>g the style sheet document, sett<strong>in</strong>g up the <strong>in</strong>ternal state, andper<strong>for</strong>m<strong>in</strong>g the trans<strong>for</strong>mations. Although you see, and <strong>in</strong>teract with, only a s<strong>in</strong>gle class(XslTrans<strong>for</strong>m), a lot of <strong>in</strong>ternal classes are <strong>in</strong>volved <strong>in</strong> the process.The first two phases occur with<strong>in</strong> the context of the Load method. Of course, you can'tcall the Trans<strong>for</strong>m method be<strong>for</strong>e a previous call to Load has successfully term<strong>in</strong>ated. Ifyou do, you will experience an XsltException exception on the Trans<strong>for</strong>m method.254

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!