StorePermissionAttribute クラス
アセンブリ: System (system.dll 内)
構文
<SerializableAttribute> _ <AttributeUsageAttribute(AttributeTargets.Assembly Or AttributeTargets.Class Or AttributeTargets.Struct Or AttributeTargets.Constructor Or AttributeTargets.Method, AllowMultiple:=True, Inherited:=False)> _ Public NotInheritable Class StorePermissionAttribute Inherits CodeAccessSecurityAttribute
[SerializableAttribute] [AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Constructor|AttributeTargets.Method, AllowMultiple=true, Inherited=false)] public sealed class StorePermissionAttribute : CodeAccessSecurityAttribute
[SerializableAttribute] [AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Constructor|AttributeTargets::Method, AllowMultiple=true, Inherited=false)] public ref class StorePermissionAttribute sealed : public CodeAccessSecurityAttribute
/** @attribute SerializableAttribute() */ /** @attribute AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Class|AttributeTargets.Struct|AttributeTargets.Constructor|AttributeTargets.Method, AllowMultiple=true, Inherited=false) */ public final class StorePermissionAttribute extends CodeAccessSecurityAttribute
宣言の許容スコープは、使用する SecurityAction 値によって異なります。
セキュリティ属性によって宣言されたセキュリティ情報は、属性ターゲットのメタデータに格納され、実行時にシステムによってアクセスされます。StorePermissionAttribute 属性は宣言セキュリティにだけ使用されます。強制セキュリティの場合は、StorePermission クラスを使用します。
StorePermissionAttribute を使用して、ストアに追加するためのアクセス許可を拒否するコード例を次に示します。このコード例は、StorePermission クラスのトピックで取り上げているコード例の一部分です。
'Deny the permission the ability to add to a store. <StorePermission(SecurityAction.Deny, Flags:=StorePermissionFlags.AddToStore)> _ Private Shared Sub AddToStore(ByVal cert As X509Certificate2) Try Dim store As New X509Store("teststore", StoreLocation.CurrentUser) store.Open(OpenFlags.ReadWrite) ' The following attempt to add a certificate results in an exception being thrown. store.Add(cert) Return Catch e As SecurityException Console.WriteLine("Security exception thrown when attempting: " + _ CType(e.FirstPermissionThatFailed, System.Security.Permissions.StorePermission).Flags) Return End Try End Sub 'AddToStore
//Deny the permission the ability to add to a store. [StorePermission(SecurityAction.Deny, Flags = StorePermissionFlags.AddToStore)] private static void AddToStore(X509Certificate2 cert) { try { X509Store store = new X509Store("teststore" , StoreLocation.CurrentUser); store.Open(OpenFlags.ReadWrite); // The following attempt to add a certificate results in an exception being thrown. store.Add(cert); return; } catch (SecurityException e) { Console.WriteLine("Security exception thrown when attempting: " + ((StorePermission)e.FirstPermissionThatFailed).Flags); return; } }
//Deny the permission the ability to add to a store. /** @attribute StorePermission(SecurityAction.Deny, Flags = StorePermissionFlags.AddToStore) */ private static void AddToStore(X509Certificate2 cert) { try { X509Store store = new X509Store("teststore" , StoreLocation.CurrentUser); store.Open(OpenFlags.ReadWrite); // The following attempt to add a certificate results in // an exception being thrown. store.Add(cert); return; } catch (System.Security.SecurityException e) { Console.WriteLine("Security exception thrown when attempting: " + ((StorePermission)e.get_FirstPermissionThatFailed()).get_Flags()); return; } } //AddToStore
System.Attribute
System.Security.Permissions.SecurityAttribute
System.Security.Permissions.CodeAccessSecurityAttribute
System.Security.Permissions.StorePermissionAttribute
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Weblioに収録されているすべての辞書からStorePermissionAttribute クラスを検索する場合は、下記のリンクをクリックしてください。
全ての辞書からStorePermissionAttribute クラスを検索
- StorePermissionAttribute クラスのページへのリンク