ProtectedConfiguration 클래스

정의

현재 애플리케이션의 구성 파일에 대한 보호되는 구성 공급자에 액세스할 수 있도록 합니다.

public ref class ProtectedConfiguration abstract sealed
public static class ProtectedConfiguration
type ProtectedConfiguration = class
Public Class ProtectedConfiguration
상속
ProtectedConfiguration

예제

다음 예제에서는 사용 ProtectedConfiguration 하는 방법을 보여 줍니다는 보호된 구성 공급자의 컬렉션을 검색 하 고 해당 공급자 이름, RSA 공급자 이름 및 섹션 이름을 검색 하는 클래스입니다.

using System;
using System.Configuration;
using System.Collections;
using System.Security.Permissions;

namespace Samples.AspNet
{
  
    // Show how to use the ProtectedConfiguration.
    public sealed class UsingProtectedConfiguration
    {

        [PermissionSet(SecurityAction.Demand, Name="FullTrust")]    
     private static void GetProviders()
        {
            // Get the providers' collection.
            ProtectedConfigurationProviderCollection
                providers = ProtectedConfiguration.Providers;

            IEnumerator pEnum =
                providers.GetEnumerator();

            foreach (ProtectedConfigurationProvider provider in
                providers)
            {
                Console.WriteLine
                    ("Provider name: {0}",
                      provider.Name);
                Console.WriteLine
                         ("Provider description: {0}",
                          provider.Description);
            }
        }

       [PermissionSet(SecurityAction.Demand, Name="FullTrust")]    
    private static void GetProviderName()
        {
            // Get the current provider name.
            string dataProtectionProviderName =
               ProtectedConfiguration.DataProtectionProviderName;
            Console.WriteLine(
                "Data protection provider name: {0}",
                 dataProtectionProviderName);

            // Get the Rsa provider name.
            string rsaProviderName =
                ProtectedConfiguration.RsaProviderName;
            Console.WriteLine(
                "Rsa provider name: {0}",
                 rsaProviderName);

            // Get the protected section name.
            string protectedSectionName =
                ProtectedConfiguration.ProtectedDataSectionName;
            Console.WriteLine(
                "Protected section name: {0}",
                 protectedSectionName);
        }

        static void Main(string[] args)
        {

            // Get current and Rsa provider names.
            GetProviderName();

            // Get the providers' collection.
            GetProviders();
        }
    }    
}
Imports System.Configuration
Imports System.Collections
Imports System.Security.Permissions

' Show how to use the ProtectedConfiguration.
NotInheritable Public Class UsingProtectedConfiguration
   
  

   <PermissionSet( _
    SecurityAction.Demand, Name:="FullTrust")> _
    Private Shared Sub GetProviders()
      ' Get the providers' collection.
        Dim providers _
        As ProtectedConfigurationProviderCollection = _
        ProtectedConfiguration.Providers
      
        Dim pEnum As IEnumerator = _
        providers.GetEnumerator()
      
        Dim provider _
        As ProtectedConfigurationProvider

        For Each provider In providers
            Console.WriteLine( _
            "Provider name: {0}", provider.Name)
            Console.WriteLine( _
            "Provider description: {0}", provider.Description)
        Next provider
   End Sub

   <PermissionSet( _
    SecurityAction.Demand, Name:="FullTrust")> _
    Private Shared Sub GetProviderName()
      ' Get the current provider name.
        Dim dataProtectionProviderName As String = _
        ProtectedConfiguration.DataProtectionProviderName
        Console.WriteLine( _
        "Data protection provider name: {0}", _
        dataProtectionProviderName)

      ' Get the Rsa provider name.
        Dim rsaProviderName As String = _
        ProtectedConfiguration.RsaProviderName
        Console.WriteLine( _
        "Rsa provider name: {0}", rsaProviderName)

        ' Get the Rsa provider name.
        Dim protectedSectionName As String = _
        ProtectedConfiguration.ProtectedDataSectionName
        Console.WriteLine( _
        "Protected section name: {0}", protectedSectionName)

    End Sub
   
   
    Public Shared Sub Main(ByVal args() As String)

       
        ' Get current and Rsa provider names.
        GetProviderName()

        ' Get the providers' collection.
        GetProviders()
        
    End Sub

End Class

설명

ProtectedConfiguration 클래스를 사용하면 중요한 구성 데이터를 보호하는 데 사용할 수 있는 공급자에 대한 정보를 얻을 수 있습니다. 일반적으로 표준 공급자를 사용하지만 클래스에서 ProtectedConfigurationProvider 파생하여 사용자 지정 공급자를 만들 수도 있습니다.

보호된 구성에 대한 자세한 내용은 보호된 구성을 사용하여 구성 정보 암호화를 참조하세요.

필드

DataProtectionProviderName

데이터 보호 공급자의 이름입니다.

ProtectedDataSectionName

보호되는 데이터 섹션의 이름입니다.

RsaProviderName

RSA 공급자의 이름입니다.

속성

DefaultProvider

보호된 기본 구성 공급자의 이름을 가져옵니다.

Providers

설치한 보호되는 구성 공급자의 컬렉션을 가져옵니다.

적용 대상

추가 정보