Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

XmlSecureResolver Constructor

.NET Framework 1.1
Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Initializes a new instance of the XmlSecureResolver class.

Overload List

Initializes a new instance of the XmlSecureResolver class with the XmlResolver and System.Security.Policy.Evidence specified.

[Visual Basic] Public Sub New(XmlResolver, Evidence)
[C#] public XmlSecureResolver(XmlResolver, Evidence);
[C++] public: XmlSecureResolver(XmlResolver*, Evidence*);
[JScript] public function XmlSecureResolver(XmlResolver, Evidence);

Initializes a new instance of the XmlSecureResolver class with the XmlResolver and System.Security.PermissionSet specified.

[Visual Basic] Public Sub New(XmlResolver, PermissionSet)
[C#] public XmlSecureResolver(XmlResolver, PermissionSet);
[C++] public: XmlSecureResolver(XmlResolver*, PermissionSet*);
[JScript] public function XmlSecureResolver(XmlResolver, PermissionSet);

Initializes a new instance of the XmlSecureResolver class with the XmlResolver and URL provided.

[Visual Basic] Public Sub New(XmlResolver, String)
[C#] public XmlSecureResolver(XmlResolver, string);
[C++] public: XmlSecureResolver(XmlResolver*, String*);
[JScript] public function XmlSecureResolver(XmlResolver, String);

Example

[Visual Basic, C#, C++] The following example constructs an XmlSecureResolver object using a customized permission set.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of the XmlSecureResolver constructor. For other examples that might be available, see the individual overload topics.
[Visual Basic] 

   public shared function GetFile (fileURL as String , resolver as XmlResolver) as Object
    
     '  Generate the default PermissionSet using the file URL.
     Dim evidence as Evidence = XmlSecureResolver.CreateEvidenceForUrl(fileURL)
     Dim myPermissions as PermissionSet = SecurityManager.ResolvePolicy(evidence)

     '  Modify the PermissionSet to only allow access to http://www.contoso.com.
     '  Create a WebPermission that only allows access to http://www.contoso.com.
     Dim myWebPermission as WebPermission = new WebPermission(NetworkAccess.Connect, "http://www.contoso.com")
     '  Replace the existing WebPermission in myPermissions with the updated WebPermission.
     myPermissions.SetPermission(myWebPermission)

     '  Use the modified PermissionSet to construct the XmlSecureResolver.
     Dim sResolver as XmlSecureResolver = new XmlSecureResolver(resolver, myPermissions)

     '  Get the object.
     Dim fullUri as Uri = sResolver.ResolveUri(nothing, fileURL)
     return sResolver.GetEntity(fullUri, nothing, nothing)
   end function 

[C#] 

   public static Object GetFile (String fileURL, XmlResolver resolver) {
    
     // Generate the default PermissionSet using the file URL.
     Evidence evidence = XmlSecureResolver.CreateEvidenceForUrl(fileURL);
     PermissionSet myPermissions = SecurityManager.ResolvePolicy(evidence);

     // Modify the PermissionSet to only allow access to http://www.contoso.com.
     // Create a WebPermission which only allows access to http://www.contoso.com.
     WebPermission myWebPermission = new WebPermission(NetworkAccess.Connect, "http://www.contoso.com");
     // Replace the existing WebPermission in myPermissions with the updated WebPermission.
     myPermissions.SetPermission(myWebPermission);

     // Use the modified PermissionSet to construct the XmlSecureResolver.
     XmlSecureResolver sResolver = new XmlSecureResolver(resolver, myPermissions);

     // Get the object.
     Uri fullUri = sResolver.ResolveUri(null, fileURL);
     return sResolver.GetEntity(fullUri, null, null);
   } 

[C++] 

Object* GetFile (String* fileURL, XmlResolver* resolver) {

    // Generate the default PermissionSet using the file URL.
    Evidence* evidence = XmlSecureResolver::CreateEvidenceForUrl(fileURL);
    PermissionSet* myPermissions = SecurityManager::ResolvePolicy(evidence);

    // Modify the PermissionSet to only allow access to http://www.contoso.com.
    // Create a WebPermission which only allows access to http://www.contoso.com.
    WebPermission* myWebPermission = new WebPermission(NetworkAccess::Connect, S"http://www.contoso.com");
    // Replace the existing WebPermission in myPermissions with the updated WebPermission.
    myPermissions->SetPermission(myWebPermission);

    // Use the modified PermissionSet to construct the XmlSecureResolver.
    XmlSecureResolver* sResolver = new XmlSecureResolver(resolver, myPermissions);

    // Get the object.
    Uri* fullUri = sResolver->ResolveUri(0, fileURL);
    return sResolver->GetEntity(fullUri, 0, 0);
} 

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

XmlSecureResolver Class | XmlSecureResolver Members | System.Xml Namespace

Show:
© 2015 Microsoft