Ejemplo n.º 1
0
        public static void CodeConnectAccessCallMethods()
        {
            CodeConnectAccess cca        = new CodeConnectAccess("test", 0);
            string            teststring = CodeConnectAccess.AnyScheme;
            int testint = CodeConnectAccess.DefaultPort;

            testint    = CodeConnectAccess.OriginPort;
            teststring = CodeConnectAccess.OriginScheme;
            cca        = CodeConnectAccess.CreateAnySchemeAccess(0);
            cca        = CodeConnectAccess.CreateOriginSchemeAccess(0);
            cca        = new CodeConnectAccess("test", 0);
            bool testbool = cca.Equals(new object());

            testint = cca.GetHashCode();
        }
Ejemplo n.º 2
0
// </snippet5>
// <snippet3>
    public static void SetNetCodeGroupAccess()
    {
        const string userPolicyLevel = "User";
        // Locate the User policy level.
        PolicyLevel level = null;

        System.Collections.IEnumerator ph =
            System.Security.SecurityManager.PolicyHierarchy();
        while (ph.MoveNext())
        {
            level = (PolicyLevel)ph.Current;
            if (level.Label == userPolicyLevel)
            {
                break;
            }
        }
        if (level.Label != userPolicyLevel)
        {
            throw new ApplicationException("Could not find User policy level.");
        }
        // <snippet7>

        IMembershipCondition membership =
            new UrlMembershipCondition(@"http://www.contoso.com/*");
        NetCodeGroup codeGroup = new NetCodeGroup(membership);

        // Delete default settings.
        codeGroup.ResetConnectAccess();
        // Create an object that represents access to the FTP scheme and default port.
        CodeConnectAccess a1 = new CodeConnectAccess(Uri.UriSchemeFtp, CodeConnectAccess.DefaultPort);
        // Create an object that represents access to the HTTPS scheme and default port.
        CodeConnectAccess a2 = new CodeConnectAccess(Uri.UriSchemeHttps, CodeConnectAccess.DefaultPort);
        // Create an object that represents access to the origin scheme and port.
        CodeConnectAccess a3 = CodeConnectAccess.CreateOriginSchemeAccess(CodeConnectAccess.OriginPort);

        // Add connection access objects to the NetCodeGroup object.
        codeGroup.AddConnectAccess(Uri.UriSchemeHttp, a1);
        codeGroup.AddConnectAccess(Uri.UriSchemeHttp, a2);
        codeGroup.AddConnectAccess(Uri.UriSchemeHttp, a3);
        // </snippet7>
        // Provide name and description information for caspol.exe tool.
        codeGroup.Name        = "ContosoHttpCodeGroup";
        codeGroup.Description = "Code originating from contoso.com can connect back using the FTP or HTTPS.";
        // Add the code group to the User policy's root node.
        level.RootCodeGroup.AddChild(codeGroup);
        // Save the changes to the policy level.
        System.Security.SecurityManager.SavePolicy();
    }
Ejemplo n.º 3
0
// </snippet6>

    public static void CreateNetCodeGroup()
    {
        IMembershipCondition membership =
            new UrlMembershipCondition(@"http://www.contoso.com/*");
        NetCodeGroup codeGroup = new NetCodeGroup(membership);

        // Display default settings.
        DisplayConnectionAccessRules(codeGroup);
        // Delete default settings.
        codeGroup.ResetConnectAccess();
        // Create an object that represents access to the ftp scheme and default port.
        CodeConnectAccess a1 = new CodeConnectAccess(Uri.UriSchemeFtp, CodeConnectAccess.DefaultPort);
        // Create an object that represents access to the HTTPS scheme and default port.
        CodeConnectAccess a2 = new CodeConnectAccess(Uri.UriSchemeHttps, CodeConnectAccess.DefaultPort);
        // Create an object that represents access to the origin scheme and port.
        CodeConnectAccess a3 = CodeConnectAccess.CreateOriginSchemeAccess(CodeConnectAccess.OriginPort);

        codeGroup.AddConnectAccess(Uri.UriSchemeHttp, a1);
        codeGroup.AddConnectAccess(Uri.UriSchemeHttp, a2);
        codeGroup.AddConnectAccess(Uri.UriSchemeHttp, a3);
        Console.WriteLine("New NetCodeGroup settings:");
        DisplayConnectionAccessRules(codeGroup);
    }
Ejemplo n.º 4
0
// </snippet3>
// <snippet4>
    public static void DisplayProperties(CodeConnectAccess access)
    {
        Console.WriteLine("Scheme:{0} Port: {1}", access.Scheme, access.Port);
    }
Ejemplo n.º 5
0
// </snippet2>
// <snippet5>
    public static CodeConnectAccess CreateAnySchemeOriginPortAccess()
    {
        return(CodeConnectAccess.CreateAnySchemeAccess(CodeConnectAccess.OriginPort));
    }
Ejemplo n.º 6
0
 public void AddConnectAccess(string originScheme, CodeConnectAccess connectAccess) { }
 public void AddConnectAccess(string originScheme, CodeConnectAccess connectAccess)
 {
 }