コード例 #1
0
ファイル: XmlSecureResolverTests.cs プロジェクト: weeble/mono
        public void EmptyEvidenceWontMatter()
        {
            XmlSecureResolver r = new XmlSecureResolver(new XmlUrlResolver(), (Evidence)null);
            Uri uri             = r.ResolveUri(null, "http://www.go-mono.com");

            Assert.IsNotNull(uri);
        }
コード例 #2
0
        [Category("NotWorking")]          // requires imperative stack modifiers to work
        public void EmptyEvidenceDeniedAccess()
        {
            XmlSecureResolver r = new XmlSecureResolver(new XmlUrlResolver(), (Evidence)null);
            Uri uri             = r.ResolveUri(null, "http://www.example.com");

            r.GetEntity(uri, null, typeof(Stream));
        }
コード例 #3
0
ファイル: XmlSecureResolverTests.cs プロジェクト: weeble/mono
        public void TestAsync()
        {
            var      loc      = Assembly.GetExecutingAssembly().Location;
            Evidence e        = XmlSecureResolver.CreateEvidenceForUrl(loc);
            var      ur       = new XmlUrlResolver();
            var      sr       = new XmlSecureResolver(ur, e);
            Uri      resolved = sr.ResolveUri(null, loc);

            Assert.AreEqual("file", resolved.Scheme);
            var task = sr.GetEntityAsync(resolved, null, typeof(Stream));

            Assert.That(task.Wait(3000));
            Assert.IsInstanceOfType(typeof(Stream), task.Result);
        }
コード例 #4
0
    // NOTE:  To test, replace www.contoso.com w/ the local string

//<snippet1>

    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));
    }
コード例 #5
0
ファイル: XmlSecureResolverTests.cs プロジェクト: weeble/mono
        public void EmptyCtorCannotResolve()
        {
            XmlSecureResolver r = new XmlSecureResolver(null, (Evidence)null);

            r.ResolveUri(null, "http://www.go-mono.com");
        }