ZoneIdentityPermissionとは? わかりやすく解説

ZoneIdentityPermission クラス

コードダウンロード元のゾーンに対して ID アクセス許可定義します。このクラス継承できません。

名前空間: System.Security.Permissions
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class
 ZoneIdentityPermission
    Inherits CodeAccessPermission
Dim instance As ZoneIdentityPermission
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public sealed class ZoneIdentityPermission
 : CodeAccessPermission
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class ZoneIdentityPermission sealed
 : public CodeAccessPermission
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class ZoneIdentityPermission extends
 CodeAccessPermission
SerializableAttribute 
ComVisibleAttribute(true) 
public final class ZoneIdentityPermission extends
 CodeAccessPermission
解説解説

このアクセス許可は、呼び出しコード特定のゾーンからダウンロードされたかどうかを判断できますゾーンは、Microsoft Internet Explorerオプションに従って構成されInternet Explorer の IInternetSecurityManager および関連する API によって URL から割り当てられます。アクセス許可では、正確なゾーン一致だけを定義します。つまり、URL1 つゾーンだけに属することができます

メモメモ

.NET Framework Version 1.0 および 1.1 では、アクセス許可状態値 Unrestricted を ID アクセス許可割り当てることはできません。.NET Framework Version 2.0 では、任意のアクセス許可状態値を ID アクセス許可割り当てることができます。つまり、バージョン 2.0 では、ID アクセス許可動作が、IUnrestrictedPermission インターフェイス実装しているアクセス許可動作等しくなりますバージョン 2.0アプリケーションバージョン 1.1CAS ポリシー実行する方法については、「<legacyV1CASPolicy> 要素」を参照してください

使用例使用例
Imports System
Imports System.Security
Imports System.Security.Permissions
Imports Microsoft.VisualBasic

Module Module1

    Public Class ZoneIdentityDemo

        ' IsSubsetOf determines whether the current permission is a
 subset of the specified permission.
        Private Function IsSubsetOfDemo() As
 Boolean
            Dim returnValue As Boolean
 = True
            Dim zone1, zone2 As SecurityZone
            Dim zoneIdPerm1, zoneIdPerm2 As
 ZoneIdentityPermission
            Dim zoneGen1 As New
 zoneGenerator()
            Dim zoneGen2 As New
 zoneGenerator()
            zoneGen1.ResetIndex()
            While zoneGen1.CreateZone(zone1)
                zoneIdPerm1 = New ZoneIdentityPermission(zone1)
                zoneGen2.ResetIndex()
                Console.WriteLine("********************************************************"
 & ControlChars.Cr)

                While zoneGen2.CreateZone(zone2)
                    zoneIdPerm2 = New ZoneIdentityPermission(zone2)
                    Try
                        If zoneIdPerm1.IsSubsetOf(zoneIdPerm2)
 Then
                            Console.WriteLine((zoneIdPerm1.SecurityZone.ToString()
 & _
                            " is a subset of " &
 zoneIdPerm2.SecurityZone.ToString()))
                        Else
                            Console.WriteLine((zoneIdPerm1.SecurityZone.ToString()
 & _
                            " is not a subset of "
 & zoneIdPerm2.SecurityZone.ToString()))
                        End If
                    Catch e As Exception
                        Console.WriteLine(("An exception was thrown
 for subset :" & _
                        zoneIdPerm1.ToString() & ControlChars.Cr & zoneIdPerm2.ToString()
 & _
                        ControlChars.Cr & e.ToString()))
                        returnValue = False
                    End Try
ContinueWhile2:
                End While
ContinueWhile1:
            End While
            Return returnValue
        End Function 'IsSubsetOfDemo

        ' Union creates a new permission that is the union of the current
 permission and the specified permission.
        Private Function UnionDemo() As
 Boolean
            Dim returnValue As Boolean
 = True
            Dim zone1, zone2 As SecurityZone
            Dim zoneIdPerm1, zoneIdPerm2 As
 ZoneIdentityPermission
            Dim zoneIdPerm3 As IPermission
            Dim zoneGen1 As New
 ZoneGenerator()
            Dim zoneGen2 As New
 ZoneGenerator()
            zoneGen1.ResetIndex()
            While zoneGen1.CreateZone(zone1)
                zoneIdPerm1 = New ZoneIdentityPermission(zone1)
                Console.WriteLine("**********************************************************"
 & ControlChars.Cr)
                zoneGen2.ResetIndex()

                Try
                    While zoneGen2.CreateZone(zone2)
                        zoneIdPerm2 = New ZoneIdentityPermission(zone2)
                        zoneIdPerm3 = CType(zoneIdPerm1.Union(zoneIdPerm2), ZoneIdentityPermission)
                        zoneIdPerm3 = zoneIdPerm1.Union(zoneIdPerm2)

                        If zoneIdPerm3 Is Nothing
 Then
                            Console.WriteLine(("The union of "
 & zone1.ToString() & " and " & _
                            zone2.ToString() & " is null."))
                        Else
                            Console.WriteLine(("The union of "
 & zoneIdPerm1.SecurityZone.ToString() & " and "
 _
                            & zoneIdPerm2.SecurityZone.ToString() & "
 = " _
                            & CType(zoneIdPerm3, Object).SecurityZone.ToString()))
                        End If
ContinueWhile2:
                    End While
                Catch e As Exception
                    Console.WriteLine(e.Message)
                End Try

ContinueWhile1:
            End While


            Return returnValue
        End Function 'UnionDemo

        ' Intersect creates and returns a new permission that is the
 intersection of the current 
        ' permission and the permission specified.
        Private Function IntersectDemo() As
 Boolean
            Dim returnValue As Boolean
 = True
            Dim zone1, zone2 As SecurityZone
            Dim zoneIdPerm1, zoneIdPerm2, zoneIdPerm3 As
 ZoneIdentityPermission
            Dim zoneGen1 As New
 ZoneGenerator()
            Dim zoneGen2 As New
 ZoneGenerator()
            zoneGen1.ResetIndex()
            While zoneGen1.CreateZone(zone1)
                zoneIdPerm1 = New ZoneIdentityPermission(zone1)
                Console.WriteLine("**********************************************************"
 & ControlChars.Cr)
                zoneGen2.ResetIndex()

                While zoneGen2.CreateZone(zone2)
                    zoneIdPerm2 = New ZoneIdentityPermission(zone2)
                    zoneIdPerm3 = CType(zoneIdPerm1.Intersect(zoneIdPerm2), ZoneIdentityPermission)
                    If Not (zoneIdPerm3 Is
 Nothing) Then
                        Console.WriteLine(("The intersection of
 " & zone1.ToString() & " and "
 & _
                        zone2.ToString() & " = "
 & CType(zoneIdPerm3, Object).SecurityZone.ToString()))
                    Else
                        Console.WriteLine(("The intersection of
 " & zone1.ToString() & " and "
 & _
                        zone2.ToString() & " is null."))
                    End If
ContinueWhile2:
                End While
ContinueWhile1:
            End While

            Return returnValue
        End Function 'IntersectDemo

        'Copy creates and returns an identical copy of the current permission.
        Private Function CopyDemo() As
 Boolean

            Dim returnValue As Boolean
 = True

            Dim zone1 As SecurityZone
            Dim zoneIdPerm1, zoneIdPerm2 As
 ZoneIdentityPermission

            Dim zoneGen1 As New
 ZoneGenerator()
            Dim zoneGen2 As New
 ZoneGenerator()

            zoneGen1.ResetIndex()
            While zoneGen1.CreateZone(zone1)
                zoneIdPerm1 = New ZoneIdentityPermission(zone1)

                zoneGen2.ResetIndex()
                Console.WriteLine("********************************************************"
 & ControlChars.Cr)
                Try
                    zoneIdPerm2 = CType(zoneIdPerm1.Copy(), ZoneIdentityPermission)
                    Console.WriteLine(("Result of copy = "
 & zoneIdPerm2.ToString()))

                Catch e As Exception
                    Console.WriteLine(("Copy failed :"
 & zoneIdPerm1.ToString() & e.ToString()))
                    GoTo ContinueWhile1
                End Try
ContinueWhile1:
            End While
            Return returnValue
        End Function 'CopyDemo

        ' ToXml creates an XML encoding of the permission and its current
 state; 
        ' FromXml reconstructs a permission with the specified state
 from the XML encoding. 
        Private Function ToFromXmlDemo() As
 Boolean

            Dim returnValue As Boolean
 = True

            Dim zone1 As SecurityZone
            Dim zoneIdPerm1, zoneIdPerm2 As
 ZoneIdentityPermission
            Dim zoneGen1 As New
 ZoneGenerator()
            Dim zoneGen2 As New
 ZoneGenerator()
            zoneGen1.ResetIndex()
            While zoneGen1.CreateZone(zone1)
                zoneIdPerm1 = New ZoneIdentityPermission(zone1)
                Console.WriteLine("********************************************************"
 & ControlChars.Cr)
                zoneGen2.ResetIndex()
                Try
                    zoneIdPerm2 = New ZoneIdentityPermission(PermissionState.None)
                    zoneIdPerm2.FromXml(zoneIdPerm1.ToXml())
                    Console.WriteLine(("Result of ToFromXml =
 " & zoneIdPerm2.ToString()))

                Catch e As Exception
                    Console.WriteLine(("ToFromXml failed :"
 & zoneIdPerm1.ToString() & e.ToString()))
                    GoTo ContinueWhile1
                End Try
ContinueWhile1:
            End While

            Return returnValue
        End Function 'ToFromXmlDemo

        ' Invoke all demos.
        Public Function RunDemo() As
 Boolean
            Dim returnCode As Boolean
 = True
            Dim tempReturnCode As Boolean

            ' Call the IsSubsetOf demo.
            If IsSubsetOfDemo() Then
                Console.Out.WriteLine("IsSubsetOf demo completed
 successfully.")
                tempReturnCode = True
            Else
                Console.Out.WriteLine("IsSubsetOf demo failed.")
                tempReturnCode = False
            End If
            returnCode = tempReturnCode And returnCode

            ' Call the Union demo.
            If UnionDemo() Then
                Console.Out.WriteLine("Union demo completed successfully.")
                tempReturnCode = True
            Else
                Console.Out.WriteLine("Union demo failed.")
                tempReturnCode = False
            End If
            returnCode = tempReturnCode And returnCode

            ' Call the Intersect demo.    
            If IntersectDemo() Then
                Console.Out.WriteLine("Intersect demo completed
 successfully.")
                tempReturnCode = True
            Else
                Console.Out.WriteLine("Intersect demo failed.")
                tempReturnCode = False
            End If
            returnCode = tempReturnCode And returnCode


            ' Call the Copy demo.    
            If CopyDemo() Then
                Console.Out.WriteLine("Copy demo completed successfully.")
                tempReturnCode = True
            Else
                Console.Out.WriteLine("Copy demo failed.")
                tempReturnCode = False
            End If
            returnCode = tempReturnCode And returnCode

            ' Call the ToFromXml demo.    
            If ToFromXmlDemo() Then
                Console.Out.WriteLine("ToFromXml demo completed
 successfully.")
                tempReturnCode = True
            Else
                Console.Out.WriteLine("ToFromXml demo failed.")
                tempReturnCode = False
            End If
            returnCode = tempReturnCode And returnCode

            Return returnCode
        End Function

        ' Test harness.
        Public Overloads Shared
 Sub Main(ByVal args() As
 [String])
            Try
                Dim democase As New
 ZoneIdentityDemo()
                Dim returnCode As Boolean
 = democase.RunDemo()
                If returnCode Then
                    Console.Out.WriteLine("ZoneIdentityPermission
 demo completed successfully.")
                    Console.Out.WriteLine("Press the Enter key
 to exit.")
                    Dim consoleInput As String
 = Console.ReadLine()
                    System.Environment.ExitCode = 100
                Else
                    Console.Out.WriteLine("ZoneIdentityPermission
 demo failed.")
                    Console.Out.WriteLine("Press the Enter key
 to exit.")
                    Dim consoleInput As String
 = Console.ReadLine()
                    System.Environment.ExitCode = 101
                End If
            Catch e As Exception
                Console.Out.WriteLine("ZoneIdentityPermission
 demo failed.")
                Console.WriteLine(e.ToString())
                Console.Out.WriteLine("Press the Enter key to
 exit.")
                Dim consoleInput As String
 = Console.ReadLine()
                System.Environment.ExitCode = 101
            End Try
        End Sub 'Main
    End Class 'ZoneIdentityDemo
 _


    ' This class generates ZoneIdentityPermission objects.
    Friend Class ZoneGenerator


        Private myZone As SecurityZone() =
 {SecurityZone.NoZone, _
        SecurityZone.Internet, _
        SecurityZone.Intranet, _
        SecurityZone.MyComputer, _
        SecurityZone.Untrusted, _
        SecurityZone.Trusted}

        Private zoneIndex As Integer
 = 0


        Public Sub New()
            ResetIndex()
        End Sub 'New


        Public Sub ResetIndex()
            zoneIndex = 0
        End Sub 'ResetIndex

        ' CreateZone creates ZoneIdentityPermission objects.
        Public Function CreateZone(ByRef
 zone As SecurityZone) As Boolean

            If zoneIndex >= myZone.Length Then

                zone = SecurityZone.NoZone
                zoneIndex = zoneIndex + 1
                Return False
            End If
            zone = myZone(zoneIndex)
            zoneIndex = zoneIndex + 1
            Return True

        End Function 'CreateZone
    ' End of ZoneGenerator.
End Module
using System;
using System.Security;
using System.Security.Permissions;

public class ZoneIdentityDemo
{
    // IsSubsetOf determines whether the current permission is a subset
 of the specified permission.
    private bool IsSubsetOfDemo()
    {
        bool returnValue = true;
        SecurityZone zone1, zone2;
        ZoneIdentityPermission zoneIdPerm1, zoneIdPerm2;
        ZoneGenerator zoneGen1 = new ZoneGenerator();
        ZoneGenerator zoneGen2 = new ZoneGenerator();
        zoneGen1.ResetIndex();
        while (zoneGen1.CreateZone(out zone1))
        {
            zoneIdPerm1 = new ZoneIdentityPermission( zone1);
            zoneGen2.ResetIndex();
            Console.WriteLine("********************************************************\n");

            while (zoneGen2.CreateZone(out zone2))
            {
                zoneIdPerm2 = new ZoneIdentityPermission( zone2);
                try
                {
                    if (zoneIdPerm1.IsSubsetOf(zoneIdPerm2))
                    {
                        Console.WriteLine(zoneIdPerm1.SecurityZone + " is a
 subset of " +
                            zoneIdPerm2.SecurityZone);
                    }
                    else
                    {
                        Console.WriteLine(zoneIdPerm1.SecurityZone + " is not
 a subset of " +
                            zoneIdPerm2.SecurityZone);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("An exception was thrown for
 subset :" + zoneIdPerm1 + "\n" +
                        zoneIdPerm2 + "\n" + e);
                    returnValue = false;
                }
            }
        }
        return returnValue;
    }
    // Union creates a new permission that is the union of the current
 permission and the specified permission.
    private bool UnionDemo()
    {
        bool returnValue = true;
        SecurityZone zone1, zone2;
        ZoneIdentityPermission zoneIdPerm1, zoneIdPerm2;
        IPermission zoneIdPerm3;
        ZoneGenerator zoneGen1 = new ZoneGenerator();
        ZoneGenerator zoneGen2 = new ZoneGenerator();
        zoneGen1.ResetIndex();
        while (zoneGen1.CreateZone(out zone1))
        {
            zoneIdPerm1 = new ZoneIdentityPermission( zone1);
            Console.WriteLine("**********************************************************\n");
            zoneGen2.ResetIndex();

            while (zoneGen2.CreateZone(out zone2))
            {
                zoneIdPerm2 = new ZoneIdentityPermission( zone2);
                try
                {
                    zoneIdPerm3 = (ZoneIdentityPermission)zoneIdPerm1.Union(zoneIdPerm2);
                    zoneIdPerm3 = zoneIdPerm1.Union(zoneIdPerm2);

                    if (zoneIdPerm3 == null)
                    {
                        Console.WriteLine("The union of " + zone1 + "
 and " + zone2 + " is null.");
                    }
                    else
                    {
                        Console.WriteLine("The union of " + zoneIdPerm1.SecurityZone
 + " and " +
                            zoneIdPerm2.SecurityZone + " = " +
                            ((ZoneIdentityPermission)zoneIdPerm3).SecurityZone.ToString());
                    }
                }
                catch (Exception e)
                {
                    // Expected exception.
                    Console.WriteLine("An exception was thrown for
 union :" + e.Message);
                }

            }
        }

        return returnValue;

    }
    // Intersect creates and returns a new permission that is the intersection
 of the current
    // permission and the permission specified.
    private bool IntersectDemo()
    {
        bool returnValue = true;
        SecurityZone zone1, zone2;
        ZoneIdentityPermission zoneIdPerm1, zoneIdPerm2, zoneIdPerm3;
        ZoneGenerator zoneGen1 = new ZoneGenerator();
        ZoneGenerator zoneGen2 = new ZoneGenerator();
        zoneGen1.ResetIndex();
        while (zoneGen1.CreateZone(out zone1))
        {
            zoneIdPerm1 = new ZoneIdentityPermission( zone1);
            Console.WriteLine("**********************************************************\n");
            zoneGen2.ResetIndex();

            while (zoneGen2.CreateZone(out zone2))
            {
                zoneIdPerm2 = new ZoneIdentityPermission( zone2);

                zoneIdPerm3 = (ZoneIdentityPermission)zoneIdPerm1.Intersect(zoneIdPerm2);
                if (zoneIdPerm3 != null)
                {
                    Console.WriteLine("The intersection of " + zone1 +
 " and " + zone2 + " = " +
                        ((ZoneIdentityPermission)zoneIdPerm3).SecurityZone.ToString());
                }
                else
                {
                    Console.WriteLine("The intersection of " + zone1 +
 " and " + zone2 + " is null.");
                }
            }
        }

        return returnValue;
    }
    //Copy creates and returns an identical copy of the current permission.
    private bool CopyDemo()
    {

        bool returnValue = true;

        SecurityZone zone1;
        ZoneIdentityPermission zoneIdPerm1, zoneIdPerm2;

        ZoneGenerator zoneGen1 = new ZoneGenerator();
        ZoneGenerator zoneGen2 = new ZoneGenerator();

        zoneGen1.ResetIndex();
        while (zoneGen1.CreateZone(out zone1))
        {
            zoneIdPerm1 = new ZoneIdentityPermission( zone1);
            zoneGen2.ResetIndex();
            Console.WriteLine("********************************************************\n");
            try
            {
                zoneIdPerm2 = (ZoneIdentityPermission)zoneIdPerm1.Copy();
                Console.WriteLine("Result of copy = " + zoneIdPerm2.ToString());

            }
            catch (Exception e)
            {
                Console.WriteLine("Copy failed :" + zoneIdPerm1.ToString()
 + e);
                continue;
            }
        }
        return returnValue;
    }
    // ToXml creates an XML encoding of the permission and its current
 state;
    // FromXml reconstructs a permission with the specified state from
 the XML encoding.
    private bool ToFromXmlDemo()
    {

        bool returnValue = true;

        SecurityZone zone1;
        ZoneIdentityPermission zoneIdPerm1, zoneIdPerm2;
        ZoneGenerator zoneGen1 = new ZoneGenerator();
        ZoneGenerator zoneGen2 = new ZoneGenerator();
        zoneGen1.ResetIndex();
        while (zoneGen1.CreateZone(out zone1))
        {
            zoneIdPerm1 = new ZoneIdentityPermission( zone1);
            Console.WriteLine("********************************************************\n");
            zoneGen2.ResetIndex();
            try
            {
                zoneIdPerm2 = new ZoneIdentityPermission(PermissionState.None);
                zoneIdPerm2.FromXml(zoneIdPerm1.ToXml());
                Console.WriteLine("Result of ToFromXml = " +
                    zoneIdPerm2.ToString());

            }
            catch (Exception e)
            {
                Console.WriteLine("ToFromXml failed :" + zoneIdPerm1.ToString()
 + e);
                continue;
            }
        }

        return returnValue;

    }
    // Invoke all demos.
    public bool RunDemo()
    {
        bool returnCode = true;
        bool tempReturnCode;

        // Call the IsSubsetOf demo.
        if (tempReturnCode = IsSubsetOfDemo()) Console.Out.WriteLine("IsSubsetOf
 demo completed successfully.");
        else
            Console.Out.WriteLine("IsSubsetOf demo failed.");
        returnCode = tempReturnCode && returnCode;

        // Call the Union demo.
        if (tempReturnCode = UnionDemo()) Console.Out.WriteLine("Union
 demo completed successfully.");
        else
            Console.Out.WriteLine("Union demo failed.");
        returnCode = tempReturnCode && returnCode;

        // Call the Intersect demo.
        if (tempReturnCode = IntersectDemo()) Console.Out.WriteLine("Intersect
 demo completed successfully.");
        else
            Console.Out.WriteLine("Intersect demo failed.");
        returnCode = tempReturnCode && returnCode;


        // Call the Copy demo.
        if (tempReturnCode = CopyDemo()) Console.Out.WriteLine("Copy
 demo completed successfully.");
        else
            Console.Out.WriteLine("Copy demo failed.");
        returnCode = tempReturnCode && returnCode;

        // Call the ToFromXml demo.
        if (tempReturnCode = ToFromXmlDemo()) Console.Out.WriteLine("ToFromXml
 demo completed successfully.");
        else
            Console.Out.WriteLine("ToFromXml demo failed.");
        returnCode = tempReturnCode && returnCode;

        return (returnCode);
    }
    // Test harness.
    public static void Main(String[]
 args)
    {
        try
        {
            ZoneIdentityDemo democase = new ZoneIdentityDemo();
            bool returnCode = democase.RunDemo();
            if (returnCode)
            {
                Console.Out.WriteLine("ZoneIdentityPermission demo completed
 successfully.");
                Console.Out.WriteLine("Press the Enter key to exit.");
                string consoleInput = Console.ReadLine();
                System.Environment.ExitCode = 100;
            }
            else
            {
                Console.Out.WriteLine("ZoneIdentityPermission demo failed.");
                Console.Out.WriteLine("Press the Enter key to exit.");
                string consoleInput = Console.ReadLine();
                System.Environment.ExitCode = 101;
            }
        }
        catch (Exception e)
        {
            Console.Out.WriteLine("ZoneIdentityPermission demo failed.");
            Console.WriteLine(e.ToString());
            Console.Out.WriteLine("Press the Enter key to exit.");
            string consoleInput = Console.ReadLine();
            System.Environment.ExitCode = 101;
        }
    }
}


// This class generates ZoneIdentityPermission objects.

internal class ZoneGenerator
{


    private SecurityZone[] myZone =
{ SecurityZone.NoZone, SecurityZone.Internet, SecurityZone.Intranet, SecurityZone.MyComputer,
 SecurityZone.Untrusted, SecurityZone.Trusted };

    private int zoneIndex = 0;

    public ZoneGenerator()
    {
        ResetIndex();
    }

    public void ResetIndex()
    {
        zoneIndex = 0;
    }
    // CreateZone creates ZoneIdentityPermission objects.
    public bool CreateZone(out SecurityZone
 zone)
    {

        if (zoneIndex >= myZone.Length)
        {

            zone = SecurityZone.NoZone;
            zoneIndex++;
            return false;
        }
        zone = myZone[zoneIndex++];
        return true;
    }
} // End of ZoneGenerator.
using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
using namespace System::Runtime::InteropServices;

// This class generates ZoneIdentityPermission objects.

[assembly:CLSCompliant(true)];
ref class ZoneGenerator
{
private:
   array<SecurityZone>^myZone;
   int zoneIndex;

public:
   ZoneGenerator()
   {
      array<SecurityZone>^ temp = {SecurityZone::NoZone,SecurityZone::Internet
,SecurityZone::Intranet,SecurityZone::MyComputer,SecurityZone::Untrusted,SecurityZone::Trusted};
      myZone = temp;
      ResetIndex();
   }

   void ResetIndex()
   {
      zoneIndex = 0;
   }


   // CreateZone creates ZoneIdentityPermission objects.
   bool CreateZone( [Out]SecurityZone * zone )
   {
      if ( zoneIndex >= myZone->Length )
      {      
          
          *zone = SecurityZone::NoZone;
         zoneIndex++;
         return false;
      }

       *zone = myZone[ zoneIndex++ ];
       return true;
   }

};


// End of ZoneGenerator.
public ref class ZoneIdentityDemo
{
private:

   // IsSubsetOf determines whether the current permission is a subset
 of the specified permission.
   bool IsSubsetOfDemo()
   {
      bool returnValue = true;
      SecurityZone zone1;
      SecurityZone zone2;
      ZoneIdentityPermission^ zoneIdPerm1;
      ZoneIdentityPermission^ zoneIdPerm2;
      ZoneGenerator^ zoneGen1 = gcnew ZoneGenerator;
      ZoneGenerator^ zoneGen2 = gcnew ZoneGenerator;
      zoneGen1->ResetIndex();
      while ( zoneGen1->CreateZone(  &zone1 ) )
      {
         zoneIdPerm1 = gcnew ZoneIdentityPermission( zone1 );
         zoneGen2->ResetIndex();
         Console::WriteLine( "********************************************************\n"
 );
         while ( zoneGen2->CreateZone(  &zone2 ) )
         {
            zoneIdPerm2 = gcnew ZoneIdentityPermission( zone2 );
            try
            {
               if ( zoneIdPerm1->IsSubsetOf( zoneIdPerm2 )
 )
               {
                  Console::WriteLine( "{0} is a subset of {1}", zoneIdPerm1->SecurityZone,
 zoneIdPerm2->SecurityZone );
               }
               else
               {
                  Console::WriteLine( "{0} is not a subset of {1}", zoneIdPerm1->SecurityZone,
 zoneIdPerm2->SecurityZone );
               }
            }
            catch ( Exception^ e ) 
            {
               Console::WriteLine( "An exception was thrown for
 subset : {0}\n{1}\n{2}", zoneIdPerm1, zoneIdPerm2, e );
               returnValue = false;
            }

         }
      }

      return returnValue;
   }


   // Union creates a new permission that is the union of the current
 permission and the specified permission.
   bool UnionDemo()
   {
      bool returnValue = true;
      SecurityZone zone1;
      SecurityZone zone2;
      ZoneIdentityPermission^ zoneIdPerm1;
      ZoneIdentityPermission^ zoneIdPerm2;
      IPermission^ zoneIdPerm3;
      ZoneGenerator^ zoneGen1 = gcnew ZoneGenerator;
      ZoneGenerator^ zoneGen2 = gcnew ZoneGenerator;
      zoneGen1->ResetIndex();
      while ( zoneGen1->CreateZone(  &zone1 ) )
      {
         zoneIdPerm1 = gcnew ZoneIdentityPermission( zone1 );
         Console::WriteLine( "**********************************************************\n"
 );
         zoneGen2->ResetIndex();
         while ( zoneGen2->CreateZone(  &zone2 ) )
         {
            zoneIdPerm2 = gcnew ZoneIdentityPermission( zone2 );
            zoneIdPerm3 = zoneIdPerm1->Union( zoneIdPerm2 );
            if ( zoneIdPerm3 == nullptr )
            {
               Console::WriteLine( "The union of {0} and {1} is null.",
 zone1, zone2 );
            }
            else
            {
               Console::WriteLine( "The union of {0} and {1} = {2}", zoneIdPerm1->SecurityZone,
 zoneIdPerm2->SecurityZone, (dynamic_cast<ZoneIdentityPermission^>(zoneIdPerm3))->SecurityZone
 );
            }
         }
      }

      return returnValue;
   }


   // Intersect creates and returns a new permission that is the intersection
 of the current
   // permission and the permission specified.
   bool IntersectDemo()
   {
      bool returnValue = true;
      SecurityZone zone1;
      SecurityZone zone2;
      ZoneIdentityPermission^ zoneIdPerm1;
      ZoneIdentityPermission^ zoneIdPerm2;
      ZoneIdentityPermission^ zoneIdPerm3;
      ZoneGenerator^ zoneGen1 = gcnew ZoneGenerator;
      ZoneGenerator^ zoneGen2 = gcnew ZoneGenerator;
      zoneGen1->ResetIndex();
      while ( zoneGen1->CreateZone(  &zone1 ) )
      {
         zoneIdPerm1 = gcnew ZoneIdentityPermission( zone1 );
         Console::WriteLine( "**********************************************************\n"
 );
         zoneGen2->ResetIndex();
         while ( zoneGen2->CreateZone(  &zone2 ) )
         {
            zoneIdPerm2 = gcnew ZoneIdentityPermission( zone2 );
            zoneIdPerm3 = dynamic_cast<ZoneIdentityPermission^>(zoneIdPerm1->Intersect(
 zoneIdPerm2 ));
            if ( zoneIdPerm3 != nullptr )
            {
               Console::WriteLine( "The intersection of {0} and {1} = {2}",
 zone1, zone2, (dynamic_cast<ZoneIdentityPermission^>(zoneIdPerm3))->SecurityZone
 );
            }
            else
            {
               Console::WriteLine( "The intersection of {0} and {1} is null.",
 zone1, zone2 );
            }
         }
      }

      return returnValue;
   }


   //Copy creates and returns an identical copy of the current permission.
   bool CopyDemo()
   {
      bool returnValue = true;
      SecurityZone zone1;
      ZoneIdentityPermission^ zoneIdPerm1;
      ZoneIdentityPermission^ zoneIdPerm2;
      ZoneGenerator^ zoneGen1 = gcnew ZoneGenerator;
      ZoneGenerator^ zoneGen2 = gcnew ZoneGenerator;
      zoneGen1->ResetIndex();
      while ( zoneGen1->CreateZone(  &zone1 ) )
      {
         zoneIdPerm1 = gcnew ZoneIdentityPermission( zone1 );
         zoneGen2->ResetIndex();
         Console::WriteLine( "********************************************************\n"
 );
         try
         {
            zoneIdPerm2 = dynamic_cast<ZoneIdentityPermission^>(zoneIdPerm1->Copy());
            Console::WriteLine( "Result of copy = {0}", zoneIdPerm2 );
         }
         catch ( Exception^ e ) 
         {
            Console::WriteLine( "Copy failed : {0}{1}", zoneIdPerm1, e
 );
            continue;
         }

      }

      return returnValue;
   }


   // ToXml creates an XML encoding of the permission and its current
 state;
   // FromXml reconstructs a permission with the specified state from
 the XML encoding.
   bool ToFromXmlDemo()
   {
      bool returnValue = true;
      SecurityZone zone1;
      ZoneIdentityPermission^ zoneIdPerm1;
      ZoneIdentityPermission^ zoneIdPerm2;
      ZoneGenerator^ zoneGen1 = gcnew ZoneGenerator;
      ZoneGenerator^ zoneGen2 = gcnew ZoneGenerator;
      zoneGen1->ResetIndex();
      while ( zoneGen1->CreateZone(  &zone1 ) )
      {
         zoneIdPerm1 = gcnew ZoneIdentityPermission( zone1 );

         Console::WriteLine( "********************************************************\n"
 );
         zoneGen2->ResetIndex();
         try
         {
            zoneIdPerm2 = gcnew ZoneIdentityPermission( PermissionState::None );
            zoneIdPerm2->FromXml( zoneIdPerm1->ToXml() );
            Console::WriteLine( "Result of ToFromXml = {0}", zoneIdPerm2
 );
         }
         catch ( Exception^ e ) 
         {
            Console::WriteLine( "ToFromXml failed : {0}{1}", zoneIdPerm1,
 e );
            continue;
         }

      }

      return returnValue;
   }


public:

   // Invoke all demos.
   bool RunDemo()
   {
      bool returnCode = true;
      bool tempReturnCode;
      
      // Call the IsSubsetOf demo.
      if ( tempReturnCode = IsSubsetOfDemo() )
            Console::WriteLine( "IsSubsetOf demo completed successfully."
 );
      else
            Console::WriteLine( "IsSubsetOf demo failed." );

      returnCode = tempReturnCode && returnCode;
      
      // Call the Union demo.
      if ( tempReturnCode = UnionDemo() )
            Console::WriteLine( "Union demo completed successfully." );
      else
            Console::WriteLine( "Union demo failed." );

      returnCode = tempReturnCode && returnCode;
      
      // Call the Intersect demo.
      if ( tempReturnCode = IntersectDemo() )
            Console::WriteLine( "Intersect demo completed successfully."
 );
      else
            Console::WriteLine( "Intersect demo failed." );

      returnCode = tempReturnCode && returnCode;
      
      // Call the Copy demo.
      if ( tempReturnCode = CopyDemo() )
            Console::WriteLine( "Copy demo completed successfully." );
      else
            Console::WriteLine( "Copy demo failed." );

      returnCode = tempReturnCode && returnCode;
      
      // Call the ToFromXml demo.
      if ( tempReturnCode = ToFromXmlDemo() )
            Console::WriteLine( "ToFromXml demo completed successfully."
 );
      else
            Console::WriteLine( "ToFromXml demo failed." );

      returnCode = tempReturnCode && returnCode;
      return (returnCode);
   }

};


// Test harness.
int main()
{
   try
   {
      ZoneIdentityDemo^ democase = gcnew ZoneIdentityDemo;
      bool returnCode = democase->RunDemo();
      if ( returnCode )
      {
         Console::WriteLine( "ZoneIdentityPermission demo completed successfully."
 );
         Console::WriteLine( "Press the Enter key to exit." );
         Console::ReadLine();
         System::Environment::ExitCode = 100;
      }
      else
      {
         Console::WriteLine( "ZoneIdentityPermission demo failed." );
         Console::WriteLine( "Press the Enter key to exit." );
         Console::ReadLine();
         System::Environment::ExitCode = 101;
      }
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "ZoneIdentityPermission demo failed." );
      Console::WriteLine( e );
      Console::WriteLine( "Press the Enter key to exit." );
      Console::ReadLine();
      System::Environment::ExitCode = 101;
   }

}

// This sample demonstrates the IsSubsetOf, Union, Intersect,
// Copy, ToXml and FromXml methods
// of the ZoneIdentityPermission class.
import System.*;
import System.Security.*;
import System.Security.Permissions .* ;

/** @assembly CLSCompliant(true)
 */

public class ZoneIdentityDemo
{
    // IsSubsetOf determines whether the current permission
    // is a subset of the specified permission.
    private boolean IsSubsetOfDemo()
    {
        boolean returnValue = true;
        SecurityZone zone1[] = new SecurityZone[1];
        SecurityZone zone2[] = new SecurityZone[1];
        ZoneIdentityPermission zoneIdPerm1[] = new ZoneIdentityPermission[1];
        ZoneIdentityPermission zoneIdPerm2[] = new ZoneIdentityPermission[1];
        ZoneGenerator zoneGen1 = new ZoneGenerator();
        ZoneGenerator zoneGen2 = new ZoneGenerator();

        zoneGen1.ResetIndex();
        while (zoneGen1.CreateZone(zoneIdPerm1, zone1)) {
            if (zoneIdPerm1[0] == null) {
                continue;
            }
            zoneGen2.ResetIndex();
            Console.WriteLine("****************************" 
                + "****************************\n");
            while (zoneGen2.CreateZone(zoneIdPerm2, zone2)) {
                if (zoneIdPerm2[0] == null)
 {
                    continue;
                }

                try {
                    if (zoneIdPerm1[0].IsSubsetOf(zoneIdPerm2[0]))
 {
                        Console.WriteLine((zoneIdPerm1[0].get_SecurityZone() 
                            + " is a subset of " 
                            + zoneIdPerm2[0].get_SecurityZone()));
                    }
                    else {
                        Console.WriteLine((zoneIdPerm1[0].get_SecurityZone() 
                            + " is not a subset of " + 
                        zoneIdPerm2[0].get_SecurityZone()));
                    }
                }
                catch (System.Exception e) {
                    Console.WriteLine(("An exception was thrown for
 subset :" 
                        + zoneIdPerm1[0] + "\n" + zoneIdPerm2[0] + "\n"
 + e));
                    returnValue = false;
                }
            }
        }
        return returnValue;
    } //IsSubsetOfDemo

    // Union creates a new permission that is the union of the
    // current permission and the specified permission.
    private boolean UnionDemo()
    {
        boolean returnValue = true;
        SecurityZone zone1[] = new SecurityZone[1];
        SecurityZone zone2[] = new SecurityZone[1];
        ZoneIdentityPermission zoneIdPerm1[] = new ZoneIdentityPermission[1];
        ZoneIdentityPermission zoneIdPerm2[] = new ZoneIdentityPermission[1];
        IPermission zoneIdPerm3;
        ZoneGenerator zoneGen1 = new ZoneGenerator();
        ZoneGenerator zoneGen2 = new ZoneGenerator();

        zoneGen1.ResetIndex();
        while (zoneGen1.CreateZone(zoneIdPerm1, zone1)) {
            if (zoneIdPerm1[0] == null) {
                continue;
            }
            Console.WriteLine("***************************************"
 
                + "*******************\n");
            zoneGen2.ResetIndex();
            while (zoneGen2.CreateZone(zoneIdPerm2, zone2)) {
                if (zoneIdPerm2[0] == null)
 {
                    continue;
                }
                zoneIdPerm3 = ((ZoneIdentityPermission)(zoneIdPerm1[0].
                    Union(zoneIdPerm2[0])));
                zoneIdPerm3 = zoneIdPerm1[0].Union(zoneIdPerm2[0]);
                if (zoneIdPerm3 == null) {
                    Console.WriteLine(("The union of " + zone1[0] + "
 and " 
                        + zone2[0] + " is null."));
                }
                else {
                    Console.WriteLine(("The union of " + zoneIdPerm1[0].
                    get_SecurityZone() + " and " 
                        + zoneIdPerm2[0].get_SecurityZone() + " = " 
                        + ((ZoneIdentityPermission)(zoneIdPerm3)).
                        get_SecurityZone().ToString()));
                }
            }
        }
        return returnValue;
    } //UnionDemo

    // Intersect creates and returns a new permission that
    // is the intersection of the current
    // permission and the permission specified.
    private boolean IntersectDemo()
    {
        boolean returnValue = true;
        SecurityZone zone1[] = new SecurityZone[1];
        SecurityZone zone2[] = new SecurityZone[1];
        ZoneIdentityPermission zoneIdPerm1[] = new ZoneIdentityPermission[1];
        ZoneIdentityPermission zoneIdPerm2[] = new ZoneIdentityPermission[1];
        ZoneIdentityPermission zoneIdPerm3 = null;
        ZoneGenerator zoneGen1 = new ZoneGenerator();
        ZoneGenerator zoneGen2 = new ZoneGenerator();

        zoneGen1.ResetIndex();
        while (zoneGen1.CreateZone(zoneIdPerm1, zone1)) {
            if (zoneIdPerm1[0] == null) {
                continue;
            }
            Console.WriteLine("**********************************" 
                + "************************\n");
            zoneGen2.ResetIndex();
            while (zoneGen2.CreateZone(zoneIdPerm2, zone2)) {
                if (zoneIdPerm2[0] == null)
 {
                    continue;
                }
                zoneIdPerm3 = ((ZoneIdentityPermission)(zoneIdPerm1[0].
                    Intersect(zoneIdPerm2[0])));
                if (zoneIdPerm3 != null) {
                    Console.WriteLine(("The intersection of " + zone1[0]
 
                        + " and " + zone2[0] + " = " + 
                        ((ZoneIdentityPermission)(zoneIdPerm3)).
                        get_SecurityZone().ToString()));
                }
                else {
                    Console.WriteLine(("The intersection of " + zone1[0]
 
                        + " and " + zone2[0] + " is null."));
                }
            }
        }
        return returnValue;
    } //IntersectDemo

    //Copy creates and returns an identical copy of the current permission.
    private boolean CopyDemo()
    {
        boolean returnValue = true;
        SecurityZone zone1[] = new SecurityZone[1];
        ZoneIdentityPermission zoneIdPerm1[] = new ZoneIdentityPermission[1];
        ZoneIdentityPermission zoneIdPerm2 = null;
        ZoneGenerator zoneGen1 = new ZoneGenerator();
        ZoneGenerator zoneGen2 = new ZoneGenerator();

        zoneGen1.ResetIndex();
        while (zoneGen1.CreateZone(zoneIdPerm1, zone1)) {
            if (zoneIdPerm1[0] == null) {
                continue;
            }
            zoneGen2.ResetIndex();
            Console.WriteLine("**********************************" 
                + "**********************\n");
            try {
                zoneIdPerm2 = ((ZoneIdentityPermission)(zoneIdPerm1[0].Copy()));
                Console.WriteLine(("Result of copy = " 
                    + zoneIdPerm2.ToString()));
            }
            catch (System.Exception e) {
                Console.WriteLine(("Copy failed :" 
                    + zoneIdPerm1[0].ToString() + e));
                continue;
            }
        }
        return returnValue;
    } //CopyDemo

    // ToXml creates an XML encoding of the permission and its current
 state;
    // FromXml reconstructs a permission with the specified 
    // state from the XML encoding.
    private boolean ToFromXmlDemo()
    {
        boolean returnValue = true;
        SecurityZone zone1[] = new SecurityZone[1];
        ZoneIdentityPermission zoneIdPerm1[] = new
        ZoneIdentityPermission[1];
        ZoneIdentityPermission zoneIdPerm2 = null;
        ZoneGenerator zoneGen1 = new ZoneGenerator();
        ZoneGenerator zoneGen2 = new ZoneGenerator();

        zoneGen1.ResetIndex();
        while (zoneGen1.CreateZone(zoneIdPerm1, zone1)) {
            if (zoneIdPerm1[0] == null) {
                continue;
            }
            Console.WriteLine("*********************************" 
                + "***********************\n");
            zoneGen2.ResetIndex();
            try {
                zoneIdPerm2 = new ZoneIdentityPermission(PermissionState.None);
                zoneIdPerm2.FromXml(zoneIdPerm1[0].ToXml());
                Console.WriteLine(("Result of ToFromXml = " 
                    + zoneIdPerm2.ToString()));
            }
            catch (System.Exception e) {
                Console.WriteLine(("ToFromXml failed :" 
                    + zoneIdPerm1[0].ToString() + e));
                continue;
            }
        }
        return returnValue;
    } //ToFromXmlDemo

    // Invoke all demos.
    public boolean RunDemo()
    {
        boolean returnCode = true;
        boolean tempReturnCode;

        // Call the IsSubsetOf demo.
        if (tempReturnCode = IsSubsetOfDemo()) {
            Console.get_Out().WriteLine("IsSubsetOf demo " 
                + "completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("IsSubsetOf demo failed.");
        }
        returnCode = tempReturnCode && returnCode;

        // Call the Union demo.
        if (tempReturnCode = UnionDemo()) {
            Console.get_Out().WriteLine("Union demo completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("Union demo failed.");
        }

        returnCode = tempReturnCode && returnCode;

        // Call the Intersect demo.
        if (tempReturnCode = IntersectDemo()) {
            Console.get_Out().WriteLine("Intersect demo " 
                + " completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("Intersect demo failed.");
        }
        returnCode = tempReturnCode && returnCode;

        // Call the Copy demo.
        if (tempReturnCode = CopyDemo()) {
            Console.get_Out().WriteLine("Copy demo completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("Copy demo failed.");
        }
        returnCode = tempReturnCode && returnCode;

        // Call the ToFromXml demo.
        if (tempReturnCode = ToFromXmlDemo()) {
            Console.get_Out().WriteLine("ToFromXml demo " 
                + "completed successfully.");
        }
        else {
            Console.get_Out().WriteLine("ToFromXml demo failed.");
        }
        returnCode = tempReturnCode && returnCode;
        return returnCode;
    } //RunDemo

    // Test harness.
    public static void main(String[]
 args)
    {
        try {
            ZoneIdentityDemo democase = new ZoneIdentityDemo();
            boolean returnCode = democase.RunDemo();
            if (returnCode) {
                Console.get_Out().WriteLine("ZoneIdentityPermission" 
                    + " demo completed successfully.");
                Console.get_Out().WriteLine("Press the Enter key to exit.");
                String consoleInput = Console.ReadLine();
                Environment.set_ExitCode(100);
            }
            else {
                Console.get_Out().WriteLine("ZoneIdentityPermission" 
                    + " demo failed.");
                Console.get_Out().WriteLine("Press the Enter key to exit.");
                String consoleInput = Console.ReadLine();
                Environment.set_ExitCode(101);
            }
        }
        catch (System.Exception e) {
            Console.get_Out().WriteLine("ZoneIdentityPermission demo failed.");
            Console.WriteLine(e.ToString());
            Console.get_Out().WriteLine("Press the Enter key to exit.");
            String consoleInput = Console.ReadLine();
            Environment.set_ExitCode(101);
        }
    } //main
} //ZoneIdentityDemo

// This class generates ZoneIdentityPermission objects.
class ZoneGenerator
{
    private SecurityZone myZone[] =  { 
        SecurityZone.NoZone, SecurityZone.Internet, SecurityZone.Intranet, 
        SecurityZone.MyComputer, SecurityZone.Untrusted, SecurityZone.Trusted };

    private int zoneIndex = 0;

    public ZoneGenerator()
    {
        ResetIndex();
    } //ZoneGenerator

    public void ResetIndex()
    {
        zoneIndex = 0;
    } //ResetIndex

    // CreateZone creates ZoneIdentityPermission objects.
    public boolean CreateZone(ZoneIdentityPermission zonePerm[],
 
        SecurityZone zone[])
    {
        if (zoneIndex >= myZone.length) {
            zonePerm[0] = new ZoneIdentityPermission(PermissionState.None);

            zone[0] = SecurityZone.NoZone;
            zoneIndex++;
            return false;
        }
        zone[0] = myZone[zoneIndex++];

        try {
            zonePerm[0] = new ZoneIdentityPermission(zone[0]);
            return true;
        }
        catch (System.Exception e) {
            Console.WriteLine(("Cannot create ZoneIdentityPermission: "
 
                + zone[0] + " " + e));
            zonePerm[0] = new ZoneIdentityPermission(PermissionState.None);
            zone[0] = SecurityZone.NoZone;
            return true;
        }
    } //CreateZone
} //ZoneGenerator 
継承階層継承階層
System.Object
   System.Security.CodeAccessPermission
    System.Security.Permissions.ZoneIdentityPermission
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ZoneIdentityPermission メンバ
System.Security.Permissions 名前空間
ZoneIdentityPermissionAttribute
Zone
ZoneMembershipCondition
その他の技術情報
アクセス許可
アクセス許可要求

ZoneIdentityPermission コンストラクタ (SecurityZone)

指定されゾーン ID を表す ZoneIdentityPermission クラス新しインスタンス初期化します。

名前空間: System.Security.Permissions
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    zone As SecurityZone _
)
Dim zone As SecurityZone

Dim instance As New ZoneIdentityPermission(zone)
public ZoneIdentityPermission (
    SecurityZone zone
)
public:
ZoneIdentityPermission (
    SecurityZone zone
)
public ZoneIdentityPermission (
    SecurityZone zone
)
public function ZoneIdentityPermission (
    zone : SecurityZone
)

パラメータ

zone

ゾーン識別子

使用例使用例
' CreateZone creates ZoneIdentityPermission objects.
Public Function CreateZone(ByRef
 zone As SecurityZone) As Boolean

    If zoneIndex >= myZone.Length Then

        zone = SecurityZone.NoZone
        zoneIndex = zoneIndex + 1
        Return False
    End If
    zone = myZone(zoneIndex)
    zoneIndex = zoneIndex + 1
    Return True

End Function 'CreateZone
// CreateZone creates ZoneIdentityPermission objects.
public bool CreateZone(out SecurityZone zone)
{

    if (zoneIndex >= myZone.Length)
    {

        zone = SecurityZone.NoZone;
        zoneIndex++;
        return false;
    }
    zone = myZone[zoneIndex++];
    return true;
}
// CreateZone creates ZoneIdentityPermission objects.
bool CreateZone( [Out]SecurityZone * zone )
{
   if ( zoneIndex >= myZone->Length )
   {      
       
       *zone = SecurityZone::NoZone;
      zoneIndex++;
      return false;
   }

    *zone = myZone[ zoneIndex++ ];
    return true;
}

// CreateZone creates ZoneIdentityPermission objects.
public boolean CreateZone(ZoneIdentityPermission zonePerm[], 
    SecurityZone zone[])
{
    if (zoneIndex >= myZone.length) {
        zonePerm[0] = new ZoneIdentityPermission(PermissionState.None);

        zone[0] = SecurityZone.NoZone;
        zoneIndex++;
        return false;
    }
    zone[0] = myZone[zoneIndex++];

    try {
        zonePerm[0] = new ZoneIdentityPermission(zone[0]);
        return true;
    }
    catch (System.Exception e) {
        Console.WriteLine(("Cannot create ZoneIdentityPermission: " 
            + zone[0] + " " + e));
        zonePerm[0] = new ZoneIdentityPermission(PermissionState.None);
        zone[0] = SecurityZone.NoZone;
        return true;
    }
} //CreateZone
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ZoneIdentityPermission クラス
ZoneIdentityPermission メンバ
System.Security.Permissions 名前空間

ZoneIdentityPermission コンストラクタ (PermissionState)

PermissionState指定して、ZoneIdentityPermission クラス新しインスタンス初期化します。

名前空間: System.Security.Permissions
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Sub New ( _
    state As PermissionState _
)
Dim state As PermissionState

Dim instance As New ZoneIdentityPermission(state)
public ZoneIdentityPermission (
    PermissionState state
)
public:
ZoneIdentityPermission (
    PermissionState state
)
public ZoneIdentityPermission (
    PermissionState state
)
public function ZoneIdentityPermission (
    state : PermissionState
)

パラメータ

state

PermissionState 値の 1 つ

例外例外
例外種類条件

ArgumentException

state パラメータが、PermissionState の有効値ではありません。

解説解説
使用例使用例
zonePerm[0] = new ZoneIdentityPermission(PermissionState.None);
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ZoneIdentityPermission クラス
ZoneIdentityPermission メンバ
System.Security.Permissions 名前空間

ZoneIdentityPermission コンストラクタ

ZoneIdentityPermission クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
ZoneIdentityPermission (PermissionState) PermissionState を指定してZoneIdentityPermission クラス新しインスタンス初期化します。
ZoneIdentityPermission (SecurityZone) 指定されゾーン ID を表す ZoneIdentityPermission クラス新しインスタンス初期化します。
参照参照

関連項目

ZoneIdentityPermission クラス
ZoneIdentityPermission メンバ
System.Security.Permissions 名前空間

ZoneIdentityPermission プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ SecurityZone 現在の ZoneIdentityPermission で表されるゾーン取得または設定します
参照参照

関連項目

ZoneIdentityPermission クラス
System.Security.Permissions 名前空間
ZoneIdentityPermissionAttribute
Zone
ZoneMembershipCondition

その他の技術情報

アクセス許可
アクセス許可要求

ZoneIdentityPermission メソッド


パブリック メソッドパブリック メソッド

  名前 説明
パブリック メソッド Assert  アクセス許可要求によって保護されているリソースへのアクセス許可が、スタックの上位にある呼び出し元に与えられていない場合でも、呼び出しコードが、このメソッド呼び出すコード通じてリソースアクセスできるように宣言しますAssert使用すると、セキュリティ上の問題発生することがあります。 ( CodeAccessPermission から継承されます。)
パブリック メソッド Copy オーバーライドされます現在のアクセス許可コピー作成して返します
パブリック メソッド Demand  コール スタック内の上位にあるすべての呼び出し元に現在のインスタンスによって指定されているアクセス許可与えられていない場合は、実行時に SecurityException を強制します。 ( CodeAccessPermission から継承されます。)
パブリック メソッド Deny  コール スタックの上位の呼び出し元が、このメソッド呼び出すコード使用して現在のインスタンスによって指定されるリソースアクセスできないようにします。 ( CodeAccessPermission から継承されます。)
パブリック メソッド Equals  オーバーロードされます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド FromXml オーバーライドされますXML エンコーディングから、指定した状態のアクセス許可再構築ます。
パブリック メソッド GetHashCode  ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適した CodeAccessPermission オブジェクトハッシュ コード取得します。 ( CodeAccessPermission から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド Intersect オーバーライドされます現在のアクセス許可指定したアクセス許可積集合を表すアクセス許可作成して返します
パブリック メソッド IsSubsetOf オーバーライドされます現在のアクセス許可が、指定したアクセス許可サブセットかどうか判断します
パブリック メソッド PermitOnly  コール スタックの上位の呼び出し元が、このメソッド呼び出すコード使用して現在のインスタンスによって指定されるリソース以外のすべてのリソースアクセスできないようにします。 ( CodeAccessPermission から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド RevertAll  現在のフレーム対す以前オーバーライドをすべて削除し無効にます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド RevertAssert  現在のフレーム対す以前Assert をすべて削除し無効にます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド RevertDeny  現在のフレーム対す以前Deny をすべて削除し無効にます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド RevertPermitOnly  現在のフレーム対す以前の PermitOnly をすべて削除し無効にます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド ToString  現在のアクセス許可オブジェクト文字列形式作成して返します。 ( CodeAccessPermission から継承されます。)
パブリック メソッド ToXml オーバーライドされますアクセス許可とその現在の状態を表す XML エンコーディング作成します
パブリック メソッド Union オーバーライドされます現在のアクセス許可指定したアクセス許可和集合を表すアクセス許可作成します
参照参照

関連項目

ZoneIdentityPermission クラス
System.Security.Permissions 名前空間
ZoneIdentityPermissionAttribute
Zone
ZoneMembershipCondition

その他の技術情報

アクセス許可
アクセス許可要求

ZoneIdentityPermission メンバ

コードダウンロード元のゾーンに対して ID アクセス許可定義します。このクラス継承できません。

ZoneIdentityPermission データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド ZoneIdentityPermission オーバーロードされます。 ZoneIdentityPermission クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ SecurityZone 現在の ZoneIdentityPermission表されるゾーン取得または設定します
パブリック メソッドパブリック メソッド
  名前 説明
パブリック メソッド Assert  アクセス許可要求によって保護されているリソースへのアクセス許可が、スタックの上位にある呼び出し元に与えられていない場合でも、呼び出しコードが、このメソッド呼び出すコード通じてリソースアクセスできるように宣言しますAssert使用すると、セキュリティ上の問題発生することがあります。 (CodeAccessPermission から継承されます。)
パブリック メソッド Copy オーバーライドされます現在のアクセス許可コピー作成して返します
パブリック メソッド Demand  コール スタック内の上位にあるすべての呼び出し元に現在のインスタンスによって指定されているアクセス許可与えられていない場合は、実行時に SecurityException を強制します。 (CodeAccessPermission から継承されます。)
パブリック メソッド Deny  コール スタックの上位の呼び出し元が、このメソッド呼び出すコード使用して現在のインスタンスによって指定されるリソースアクセスできないようにします。 (CodeAccessPermission から継承されます。)
パブリック メソッド Equals  オーバーロードされます。 ( CodeAccessPermission から継承されます。)
パブリック メソッド FromXml オーバーライドされますXML エンコーディングから、指定した状態のアクセス許可再構築ます。
パブリック メソッド GetHashCode  ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適した CodeAccessPermission オブジェクトハッシュ コード取得します。 (CodeAccessPermission から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド Intersect オーバーライドされます現在のアクセス許可指定したアクセス許可積集合を表すアクセス許可作成して返します
パブリック メソッド IsSubsetOf オーバーライドされます現在のアクセス許可が、指定したアクセス許可サブセットかどうか判断します
パブリック メソッド PermitOnly  コール スタックの上位の呼び出し元が、このメソッド呼び出すコード使用して現在のインスタンスによって指定されるリソース以外のすべてのリソースアクセスできないようにします。 (CodeAccessPermission から継承されます。)
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド RevertAll  現在のフレーム対す以前オーバーライドをすべて削除し無効にます。 (CodeAccessPermission から継承されます。)
パブリック メソッド RevertAssert  現在のフレーム対す以前Assert をすべて削除し無効にます。 (CodeAccessPermission から継承されます。)
パブリック メソッド RevertDeny  現在のフレーム対す以前Deny をすべて削除し無効にます。 (CodeAccessPermission から継承されます。)
パブリック メソッド RevertPermitOnly  現在のフレーム対す以前の PermitOnly をすべて削除し無効にます。 (CodeAccessPermission から継承されます。)
パブリック メソッド ToString  現在のアクセス許可オブジェクト文字列形式作成して返します。 (CodeAccessPermission から継承されます。)
パブリック メソッド ToXml オーバーライドされますアクセス許可とその現在の状態を表す XML エンコーディング作成します
パブリック メソッド Union オーバーライドされます現在のアクセス許可指定したアクセス許可和集合を表すアクセス許可作成します
参照参照

関連項目

ZoneIdentityPermission クラス
System.Security.Permissions 名前空間
ZoneIdentityPermissionAttribute
Zone
ZoneMembershipCondition

その他の技術情報

アクセス許可
アクセス許可要求



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ZoneIdentityPermission」の関連用語

ZoneIdentityPermissionのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ZoneIdentityPermissionのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS