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

CodeAccessPermission クラス

すべてのコード アクセス許可の基になる構造体を定義します。

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

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public MustInherit Class
 CodeAccessPermission
    Implements IPermission, ISecurityEncodable, IStackWalk
Dim instance As CodeAccessPermission
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public abstract class CodeAccessPermission
 : IPermission, ISecurityEncodable, IStackWalk
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class CodeAccessPermission abstract
 : IPermission, ISecurityEncodable, IStackWalk
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public abstract class CodeAccessPermission
 implements IPermission, ISecurityEncodable, 
    IStackWalk
SerializableAttribute 
ComVisibleAttribute(true) 
public abstract class CodeAccessPermission
 implements IPermission, ISecurityEncodable, 
    IStackWalk
解説解説

コード アクセス許可は、スタック ウォークを使用し、コードを呼び出したすべての呼び出し元にアクセス許可が与えられるようにします。アクセス許可オブジェクトが null 参照 (Visual Basic では Nothing) の場合、そのオブジェクトは、状態が PermissionState.None のアクセス許可オブジェクトと同じように処理されます。

コール スタック内で上位にあるメソッドが下位にあるメソッドを呼び出すことができるように、通常コール スタックは、下方向に影響力を持つものとして表現されます。

CodeAccessPermission クラスの継承クラスは、セキュリティ インフラストラクチャを拡張するアクセス許可として正しく機能するために、完全信頼が与えられている必要があります。継承クラスに完全信頼が与えられるように指定するために、CodeAccessPermission は ControlEvidence = true および ControlPolicy = true の InheritanceDemand を発行します。

継承確認要求の詳細については、「継承確認要求」を参照してください。

継承時の注意 CodeAccessPermission から継承する場合は、IUnrestrictedPermission インターフェイスも実装する必要があります。 CodeAccessPermission の Copy、Intersect、IsSubsetOf、ToXml、FromXml、および Union の各メンバをオーバーライドする必要があります。 唯一のパラメータとして PermissionState をとるコンストラクタも定義する必要があります。 CodeAccessPermission から継承するクラスに SerializableAttribute 属性を適用する必要があります。

使用例使用例

CodeAccessPermission クラスから派生したアクセス許可のコード例を次に示します。

' This custom permission is intended only for the purposes of illustration.
' The following code shows how to create a custom permission that inherits
' from CodeAccessPermission. The code implements all required overrides.
' A wildcard character ('*') is implemented for the Name property.
Imports System
Imports System.Security
Imports System.Security.Permissions
Imports System.IO
Imports System.Security.Policy
Imports System.Collections
Imports Microsoft.VisualBasic

<assembly: System.Reflection.AssemblyKeyFile("Key.snk")>

<assembly: System.Security.AllowPartiallyTrustedCallersAttribute()>
Namespace MyPermission

    <Serializable()> _
                   Public NotInheritable Class
 NameIdPermission
        Inherits CodeAccessPermission
        Implements IUnrestrictedPermission
        Private m_Name As String
        Private m_Unrestricted As Boolean


        Public Sub New(ByVal
 name As String)
            m_name = name
        End Sub 'New


        Public Sub New(ByVal
 state As PermissionState)
            If state = PermissionState.None Then
                m_name = ""
            ElseIf state = PermissionState.Unrestricted Then
                Throw New ArgumentException("Unrestricted
 state is not allowed for identity permissions.")
            Else
                Throw New ArgumentException("Invalid
 permission state.")
            End If
        End Sub 'New 

        Public Property Name() As
 String
            Get
                Return m_name
            End Get
            Set(ByVal Value As
 String)
                m_name = Value
            End Set
        End Property

        Public Overrides Function
 Copy() As IPermission
            Dim name As String
            name = m_name
            Return New NameIdPermission(name)
        End Function 'Copy

        Public Function IsUnrestricted() As
 Boolean Implements IUnrestrictedPermission.IsUnrestricted
            ' Always false, unrestricted state is not allowed.
            Return m_Unrestricted
        End Function 'IsUnrestricted

        Private Function VerifyType(ByVal
 target As IPermission) As Boolean
            Return TypeOf target Is
 NameIdPermission
        End Function 'VerifyType

        Public Overrides Function
 IsSubsetOf(ByVal target As IPermission) As
 Boolean

#If (Debug) Then

            Console.WriteLine("************* Entering IsSubsetOf
 *********************")
#End If
            If target Is Nothing
 Then
                Console.WriteLine("IsSubsetOf: target == null")
                Return False
            End If
#If (Debug) Then
            Console.WriteLine(("This is = " + CType(Me,
 NameIdPermission).Name))
            Console.WriteLine(("Target is " + CType(target,
 NameIdPermission).m_name))
#End If
            Try
                Dim operand As NameIdPermission
 = CType(target, NameIdPermission)

                ' The following check for unrestricted permission is
 only included as an example for
                ' permissions that allow the unrestricted state. It
 is of no value for this permission.
                If True = operand.m_Unrestricted
 Then
                    Return True
                ElseIf True = Me.m_Unrestricted
 Then
                    Return False
                End If

                If Not (Me.m_name
 Is Nothing) Then
                    If operand.m_name Is Nothing
 Then
                        Return False
                    End If
                    If Me.m_name = ""
 Then
                        Return True
                    End If
                End If
                If Me.m_name.Equals(operand.m_name)
 Then
                    Return True
                Else
                    ' Check for wild card character '*'.
                    Dim i As Integer
 = operand.m_name.LastIndexOf("*")

                    If i > 0 Then
                        Dim prefix As String
 = operand.m_name.Substring(0, i)

                        If Me.m_name.StartsWith(prefix)
 Then
                            Return True
                        End If
                    End If
                End If

                Return False
            Catch
                Throw New ArgumentException(String.Format("Argument_WrongType",
 Me.GetType().FullName))
            End Try
        End Function 'IsSubsetOf

        Public Overrides Function
 Intersect(ByVal target As IPermission) As
 IPermission
            Console.WriteLine("************* Entering Intersect
 *********************")
            If target Is Nothing
 Then
                Return Nothing
            End If
#If (Debug) Then

            Console.WriteLine(("This is = " + CType(Me,
 NameIdPermission).Name))
            Console.WriteLine(("Target is " + CType(target,
 NameIdPermission).m_name))
#End If
            If Not VerifyType(target) Then
                Throw New ArgumentException(String.Format("Argument
 is wrong type.", Me.GetType().FullName))
            End If

            Dim operand As NameIdPermission
 = CType(target, NameIdPermission)

            If operand.IsSubsetOf(Me) Then
                Return operand.Copy()
            ElseIf Me.IsSubsetOf(operand) Then
                Return Me.Copy()
            Else
                Return Nothing
            End If
        End Function 'Intersect

        Public Overrides Function
 Union(ByVal target As IPermission) As
 IPermission
#If (Debug) Then

            Console.WriteLine("************* Entering Union *********************")
#End If
            If target Is Nothing
 Then
                Return Me
            End If
#If (Debug) Then
            Console.WriteLine(("This is = " + CType(Me,
 NameIdPermission).Name))
            Console.WriteLine(("Target is " + CType(target,
 NameIdPermission).m_name))
#End If
            If Not VerifyType(target) Then
                Throw New ArgumentException(String.Format("Argument_WrongType",
 Me.GetType().FullName))
            End If

            Dim operand As NameIdPermission
 = CType(target, NameIdPermission)

            If operand.IsSubsetOf(Me) Then
                Return Me.Copy()
            ElseIf Me.IsSubsetOf(operand) Then
                Return operand.Copy()
            Else
                Return Nothing
            End If
        End Function 'Union
        

        

        Public Overrides Sub
 FromXml(ByVal e As SecurityElement)
            ' The following code for unrestricted permission is only
 included as an example for
            ' permissions that allow the unrestricted state. It is of
 no value for this permission.
            Dim elUnrestricted As String
 = e.Attribute("Unrestricted")
            If Nothing <> elUnrestricted
 Then
                m_Unrestricted = Boolean.Parse(elUnrestricted)
                Return
            End If

            Dim elName As String
 = e.Attribute("Name")
            m_name = IIf(elName Is Nothing,
 Nothing, elName)
        End Sub 'FromXml

        Public Overrides Function
 ToXml() As SecurityElement
            ' Use the SecurityElement class to encode the permission
 to XML.
            Dim esd As New
 SecurityElement("IPermission")

            Dim name As String
 = GetType(NameIdPermission).AssemblyQualifiedName
            esd.AddAttribute("class", name)
            esd.AddAttribute("version", "1.0")

            ' The following code for unrestricted permission is only
 included as an example for
            ' permissions that allow the unrestricted state. It is of
 no value for this permission.
            If m_Unrestricted Then
                esd.AddAttribute("Unrestricted", True.ToString())
            End If
            If Not (m_Name Is
 Nothing) Then
                esd.AddAttribute("Name", m_Name)
            End If
            Return esd
        End Function 'ToXml
End Namespace
//#define debug
// This custom permission is intended only for the purposes of illustration.
// The following code shows how to create a custom permission that inherits
// from CodeAccessPermission. The code implements all required overrides.
// A wildcard character ('*') is implemented for the Name property.
using System;
using System.Security;
using System.Security.Permissions;
using System.IO;
using System.Security.Policy;
using System.Collections;
using System.Text;

[assembly:System.Reflection.AssemblyKeyFile("Key.snk")]
[assembly:System.Security.AllowPartiallyTrustedCallersAttribute()]

namespace MyPermission
{
    [Serializable()] sealed public class  
 NameIdPermission : CodeAccessPermission, IUnrestrictedPermission
    {
        private String m_Name;
        private bool m_Unrestricted;

        public  NameIdPermission(String name)
        {
            m_Name = name;
        }

        public  NameIdPermission(PermissionState state)
        {
            if (state == PermissionState.None)
            {
                m_Name = "";
            }
            else
                if (state == PermissionState.Unrestricted)
            {
                throw new ArgumentException("Unrestricted
 state is not allowed for identity permissions.");
            }
            else throw new ArgumentException("Invalid
 permission state.");
        }

        public String Name
        {
            set{m_Name = value;}
            get{ return m_Name;}
        }
        public override IPermission Copy()
        {
            string name = m_Name;
            return new  NameIdPermission( name
 );
        }
        public bool IsUnrestricted()
        {
            // Always false, unrestricted state is not allowed.
            return m_Unrestricted;
        }

        private bool VerifyType(IPermission
 target)
        {
            return (target is  NameIdPermission);
        }
        public override bool IsSubsetOf(IPermission
 target)
        {
#if(debug)
            Console.WriteLine ("************* Entering IsSubsetOf *********************");
#endif
            if (target == null)
            {
                Console.WriteLine ("IsSubsetOf: target == null");
                return false;
            }
#if(debug)

            Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
            Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
#endif
            try
            {
                 NameIdPermission operand = ( NameIdPermission)target;

                // The following check for unrestricted permission is
 only included as an example for
                // permissions that allow the unrestricted state. It
 is of no value for this permission.
                if (true == operand.m_Unrestricted)
                {
                    return true;
                }
                else if (true
 == this.m_Unrestricted)
                {
                    return false;
                }

                if (this.m_Name != null)
                {
                    if (operand.m_Name == null)
 return false;

                    if (this.m_Name == "")
 return true;
                }

                if (this.m_Name.Equals (operand.m_Name))
 return true;
                else
                {
                    // Check for wild card character '*'.
                    int i = operand.m_Name.LastIndexOf ("*");

                    if (i > 0)
                    {
                        string prefix = operand.m_Name.Substring
 (0, i);

                        if (this.m_Name.StartsWith
 (prefix))
                        {
                            return true;
                        }
                    }
                }

                return false;
            }
            catch (InvalidCastException)
            {
                throw new ArgumentException (String.Format ("Argument_WrongType",
 this.GetType ().FullName));
            }
        }
        public override IPermission Intersect(IPermission target)
        {
            Console.WriteLine ("************* Entering Intersect *********************");
            if (target == null)
            {
                return null;
            }
#if(debug)
            Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
            Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
#endif
            if (!VerifyType(target))
            {
                throw new ArgumentException (String.Format ("Argument
 is wrong type.", this.GetType ().FullName));
            }

             NameIdPermission operand = ( NameIdPermission)target;

            if (operand.IsSubsetOf (this))
 return operand.Copy ();
            else if (this.IsSubsetOf
 (operand)) return this.Copy ();
            else
                return null;
        }

        public override IPermission Union(IPermission target)
        {
#if(debug)
            Console.WriteLine ("************* Entering Union *********************");
#endif
            if (target == null)
            {
                return this;
            }
#if(debug)
            Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
            Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
#endif
            if (!VerifyType(target))
            {
                throw new ArgumentException (String.Format ("Argument_WrongType",
 this.GetType ().FullName));
            }

             NameIdPermission operand = ( NameIdPermission)target;

            if (operand.IsSubsetOf (this))
 return this.Copy ();
            else if (this.IsSubsetOf
 (operand)) return operand.Copy ();
            else
                return null;
        }
        
        
        
        
       public override void FromXml(SecurityElement
 e)
        {
            // The following code for unrestricted permission is only
 included as an example for
            // permissions that allow the unrestricted state. It is
 of no value for this permission.
            String elUnrestricted = e.Attribute("Unrestricted");
            if (null != elUnrestricted)
            {
                m_Unrestricted = bool.Parse(elUnrestricted);
                return;
            }

            String elName = e.Attribute( "Name" );
            m_Name = elName == null ? null
 : elName;
        }
        public override SecurityElement ToXml()
        {
            // Use the SecurityElement class to encode the permission
 to XML.
            SecurityElement esd = new SecurityElement("IPermission");
            String name = typeof( NameIdPermission).AssemblyQualifiedName;
            esd.AddAttribute("class", name);
            esd.AddAttribute("version", "1.0");

            // The following code for unrestricted permission is only
 included as an example for
            // permissions that allow the unrestricted state. It is
 of no value for this permission.
            if (m_Unrestricted)
            {
                esd.AddAttribute("Unrestricted", true.ToString());
            }
            if (m_Name != null) esd.AddAttribute(
 "Name", m_Name );
            return esd;
        }
     }
}
//#define debug
// This custom permission is intended only for the purposes of illustration.
// The following code shows how to create a custom permission that inherits
// from CodeAccessPermission. The code implements all required overrides.
// A wildcard character ('*') is implemented for the Name property.

using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
using namespace System::IO;
using namespace System::Security::Policy;
using namespace System::Collections;
using namespace System::Text;

[assembly:System::Reflection::AssemblyKeyFile("Key.snk")];
[assembly:System::Security::AllowPartiallyTrustedCallersAttribute];

[Serializable]
public ref class NameIdPermission: public
 CodeAccessPermission, public IUnrestrictedPermission
{
private:
   String^ m_Name;
   bool m_Unrestricted;

public:
   NameIdPermission( String^ name )
   {
      m_Name = name;
   }

   NameIdPermission( PermissionState state )
   {
      if ( state == PermissionState::None )
      {
         m_Name = "";
      }
      else if ( state == PermissionState::Unrestricted
 )
      {
         throw gcnew ArgumentException( "Unrestricted state is not allowed for
 identity permissions." );
      }
      else
      {
         throw gcnew ArgumentException( "Invalid permission state." );
      }
   }

   property String^ Name 
   {
      String^ get()
      {
         return m_Name;
      }
      void set( String^ value )
      {
         m_Name = value;
      }
   }

public:
   virtual IPermission^ Copy() override
   {
      String^ name = m_Name;
      return gcnew NameIdPermission( name );
   }

public:
   virtual bool IsUnrestricted()
   {
      // Always false, unrestricted state is not allowed.
      return m_Unrestricted;
   }

private:
   bool VerifyType( IPermission^ target )
   {
      return dynamic_cast<NameIdPermission^>(target) !=
 nullptr;
   }

public:
   virtual bool IsSubsetOf( IPermission^ target ) override
   {
#if ( debug ) 
      Console::WriteLine( "************* Entering IsSubsetOf *********************"
 );
#endif

      if ( target == nullptr )
      {
         Console::WriteLine( "IsSubsetOf: target == null"
 );
         return false;
      }

#if ( debug ) 
      Console::WriteLine( "This is = {0}", ((NameIdPermission)this).Name
 );
      Console::WriteLine( "Target is {0}", ((NameIdPermission)target).m_Name
 );
#endif

      try
      {
         NameIdPermission^ operand = dynamic_cast<NameIdPermission^>(target);
         
         // The following check for unrestricted permission is only
 included as an example for
         // permissions that allow the unrestricted state. It is of
 no value for this permission.
         if ( true == operand->m_Unrestricted
 )
         {
            return true;
         }
         else if ( true
 == this->m_Unrestricted )
         {
            return false;
         }

         if ( this->m_Name != nullptr )
         {
            if ( operand->m_Name == nullptr )
            {
               return false;
            }
            if ( this->m_Name->Equals(
 "" ) )
            {
               return true;
            }
         }

         if ( this->m_Name->Equals( operand->m_Name
 ) )
         {
            return true;
         }
         else
         {
            // Check for wild card character '*'.
            int i = operand->m_Name->LastIndexOf( "*"
 );

            if ( i > 0 )
            {
               String^ prefix = operand->m_Name->Substring( 0, i );
               if ( this->m_Name->StartsWith(
 prefix ) )
               {
                  return true;
               }
            }
         }
         return false;
      }
      catch ( InvalidCastException^ ) 
      {
         throw gcnew ArgumentException( String::Format( "Argument_WrongType",
 this->GetType()->FullName ) );
      }
   }

public:
   virtual IPermission^ Intersect( IPermission^ target ) override
   {
      Console::WriteLine( "************* Entering Intersect *********************"
 );
      if ( target == nullptr )
      {
         return nullptr;
      }

#if ( debug ) 
      Console::WriteLine( "This is = {0}", ((NameIdPermission)this).Name
 );
      Console::WriteLine( "Target is {0}", ((NameIdPermission)target).m_Name
 );
#endif 

      if (  !VerifyType( target ) )
      {
         throw gcnew ArgumentException( String::Format( "Argument is wrong type.",
 this->GetType()->FullName ) );
      }

      NameIdPermission^ operand = dynamic_cast<NameIdPermission^>(target);

      if ( operand->IsSubsetOf( this ) )
      {
         return operand->Copy();
      }
      else if ( this->IsSubsetOf(
 operand ) )
      {
         return this->Copy();
      }
      else
      {
         return nullptr;
      }
   }

public:
   virtual IPermission^ Union( IPermission^ target ) override
   {
#if ( debug ) 
      Console::WriteLine( "************* Entering Union *********************"
 );
#endif 

      if ( target == nullptr )
      {
         return this;
      }

#if ( debug ) 
      Console::WriteLine( "This is = {0}", ((NameIdPermission)this).Name
 );
      Console::WriteLine( "Target is {0}", ((NameIdPermission)target).m_Name
 );
#endif 

      if (  !VerifyType( target ) )
      {
         throw gcnew ArgumentException( String::Format( "Argument_WrongType",
 this->GetType()->FullName ) );
      }

      NameIdPermission^ operand = dynamic_cast<NameIdPermission^>(target);

      if ( operand->IsSubsetOf( this ) )
      {
         return this->Copy();
      }
      else if ( this->IsSubsetOf(
 operand ) )
      {
         return operand->Copy();
      }
      else
      {
         return nullptr;
      }
   }





public:
   virtual void FromXml( SecurityElement^ e ) override
   {
      // The following code for unrestricted permission is only included
 as an example for
      // permissions that allow the unrestricted state. It is of no
 value for this permission.
      String^ elUnrestricted = e->Attribute("Unrestricted");
      if ( nullptr != elUnrestricted )
      {
         m_Unrestricted = Boolean::Parse( elUnrestricted );
         return;
      }

      String^ elName = e->Attribute("Name");
      m_Name = elName == nullptr ? nullptr : elName;
   }

public:
   virtual SecurityElement^ ToXml() override
   {
      // Use the SecurityElement class to encode the permission to XML.
      SecurityElement^ esd = gcnew SecurityElement( "IPermission" );
      String^ name = NameIdPermission::typeid->AssemblyQualifiedName;
      esd->AddAttribute( "class", name );
      esd->AddAttribute( "version", "1.0" );
      
      // The following code for unrestricted permission is only included
 as an example for
      // permissions that allow the unrestricted state. It is of no
 value for this permission.
      if ( m_Unrestricted )
      {
         esd->AddAttribute( "Unrestricted", true.ToString()
 );
      }

      if ( m_Name != nullptr )
      {
         esd->AddAttribute( "Name", m_Name );
      }

      return esd;
   }
};
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
  System.Security.CodeAccessPermission
     派生クラス
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

CodeAccessPermission コンストラクタ

CodeAccessPermission クラスの新しいインスタンスを初期化します。

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

Dim instance As New CodeAccessPermission
protected CodeAccessPermission ()
protected:
CodeAccessPermission ()
protected CodeAccessPermission ()
protected function CodeAccessPermission ()
解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CodeAccessPermission クラス
CodeAccessPermission メンバ
System.Security 名前空間

CodeAccessPermission メソッド


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

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

関連項目

CodeAccessPermission クラス
System.Security 名前空間

その他の技術情報

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

CodeAccessPermission メンバ

すべてのコード アクセス許可の基になる構造体を定義します。

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


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

関連項目

CodeAccessPermission クラス
System.Security 名前空間

その他の技術情報

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



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「CodeAccessPermission」の関連用語

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

   

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



CodeAccessPermissionのページの著作権

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

©2026 GRAS Group, Inc.RSS