XmlSecureResolver Constructor (XmlResolver^, PermissionSet^)
.NET Framework (current version)
Initializes a new instance of the XmlSecureResolver class with the XmlResolver and PermissionSet specified.
Assembly: System.Xml (in System.Xml.dll)
Parameters
- resolver
-
Type:
System.Xml::XmlResolver^
The XML resolver that is wrapped by the XmlSecureResolver.
- permissionSet
-
Type:
System.Security::PermissionSet^
The permission set to apply to the underlying XmlResolver. The XmlSecureResolver calls the PermissionSet::PermitOnly method on the permission set before calling the GetEntity method on the underlying XML resolver.
The following example constructs an XmlSecureResolver object by using a customized permission set.
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 = gcnew 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 = gcnew XmlSecureResolver( resolver,myPermissions );
// Get the object.
Uri^ fullUri = sResolver->ResolveUri( nullptr, fileURL );
return sResolver->GetEntity( fullUri, nullptr, nullptr );
}
.NET Framework
Available since 1.1
Available since 1.1
Show: