다음을 통해 공유


CipherReference 클래스

정의

XML 암호화의 <CipherReference> 요소를 나타냅니다. 이 클래스는 상속될 수 없습니다.

public ref class CipherReference sealed : System::Security::Cryptography::Xml::EncryptedReference
public sealed class CipherReference : System.Security.Cryptography.Xml.EncryptedReference
type CipherReference = class
    inherit EncryptedReference
Public NotInheritable Class CipherReference
Inherits EncryptedReference
상속
CipherReference

예제

다음 코드 예제에서는의 새 인스턴스를 만듭니다 CipherReference합니다.

#using <System.Xml.dll>
#using <System.Security.dll>
#using <System.dll>

using namespace System;
using namespace System::Security::Cryptography::Xml;
using namespace System::Xml;
using namespace System::IO;

/// This sample used the EncryptedData class to create an encrypted data element
/// and write it to an XML file. It demonstrates the use of CipherReference.

[STAThread]
int main()
{
   
   //Create a URI string.
   String^ uri = "http://www.woodgrovebank.com/document.xml";
   
   // Create a Base64 transform. The input content retrieved from the
   // URI should be Base64-decoded before other processing.
   Transform^ base64 = gcnew XmlDsigBase64Transform;
   
   //Create a transform chain and add the transform to it.
   TransformChain^ tc = gcnew TransformChain;
   tc->Add( base64 );
   
   //Create <CipherReference> information.
   CipherReference ^ reference = gcnew CipherReference( uri,tc );
   
   // Create a new CipherData object using the CipherReference information.
   // Note that you cannot assign both a CipherReference and a CipherValue
   // to a CipherData object.
   CipherData ^ cd = gcnew CipherData( reference );
   
   // Create a new EncryptedData object.
   EncryptedData^ ed = gcnew EncryptedData;
   
   //Add an encryption method to the object.
   ed->Id = "ED";
   ed->EncryptionMethod = gcnew EncryptionMethod( "http://www.w3.org/2001/04/xmlenc#aes128-cbc" );
   ed->CipherData = cd;
   
   //Add key information to the object.
   KeyInfo^ ki = gcnew KeyInfo;
   ki->AddClause( gcnew KeyInfoRetrievalMethod( "#EK","http://www.w3.org/2001/04/xmlenc#EncryptedKey" ) );
   ed->KeyInfo = ki;
   
   // Create new XML document and put encrypted data into it.
   XmlDocument^ doc = gcnew XmlDocument;
   XmlElement^ encryptionPropertyElement = dynamic_cast<XmlElement^>(doc->CreateElement( "EncryptionProperty", EncryptedXml::XmlEncNamespaceUrl ));
   EncryptionProperty ^ ep = gcnew EncryptionProperty( encryptionPropertyElement );
   ed->AddProperty( ep );
   
   // Output the resulting XML information into a file.
   try
   {
      String^ path = "c:\\test\\MyTest.xml";
      File::WriteAllText( path, ed->GetXml()->OuterXml );
   }
   catch ( IOException^ e ) 
   {
      Console::WriteLine( "File IO error. {0}", e );
   }

}
using System;
using System.Security.Cryptography.Xml;
using System.Xml;
using System.IO;

/// This sample used the EncryptedData class to create an encrypted data element
/// and write it to an XML file. It demonstrates the use of CipherReference.
namespace EncryptedDataSample
{
    class Example
    {
        [STAThread]
        static void Main(string[] args)
        {
            //Create a URI string.
            String uri = "http://www.woodgrovebank.com/document.xml";
            // Create a Base64 transform. The input content retrieved from the
            // URI should be Base64-decoded before other processing.
            Transform base64 = new XmlDsigBase64Transform();
            //Create a transform chain and add the transform to it.
            TransformChain tc = new TransformChain();
            tc.Add(base64);
            //Create <CipherReference> information.
            CipherReference reference = new CipherReference(uri, tc);

            // Create a new CipherData object using the CipherReference information.
            // Note that you cannot assign both a CipherReference and a CipherValue
            // to a CipherData object.
            CipherData cd = new CipherData(reference);

            // Create a new EncryptedData object.
            EncryptedData ed = new EncryptedData();

            //Add an encryption method to the object.
            ed.Id = "ED";
            ed.EncryptionMethod = new EncryptionMethod("http://www.w3.org/2001/04/xmlenc#aes128-cbc");
            ed.CipherData = cd;

            //Add key information to the object.
            KeyInfo ki = new KeyInfo();
            ki.AddClause(new KeyInfoRetrievalMethod("#EK", "http://www.w3.org/2001/04/xmlenc#EncryptedKey"));
            ed.KeyInfo = ki;

            // Create new XML document and put encrypted data into it.
            XmlDocument doc = new XmlDocument();
            XmlElement encryptionPropertyElement = (XmlElement)doc.CreateElement("EncryptionProperty", EncryptedXml.XmlEncNamespaceUrl);
            EncryptionProperty ep = new EncryptionProperty(encryptionPropertyElement);
            ed.AddProperty(ep);

            // Output the resulting XML information into a file.
            try
            {
                string path = @"c:\test\MyTest.xml";

                File.WriteAllText(path, ed.GetXml().OuterXml);
            }
            catch (IOException e)
            {
                Console.WriteLine("File IO error. {0}", e);
            }
        }
    }
}
Imports System.Security.Cryptography.Xml
Imports System.Xml
Imports System.IO


'/ This sample used the EncryptedData class to create a EncryptedData element
'/ and write it to an XML file. It demonstrates the use of CipherReference.
Module Module1

    Sub Main()
        ' Create a URI string.
        Dim uri As String = "http://www.woodgrovebank.com/document.xml"
        ' Create a Base64 transform. The input content retrieved from the
        ' URI should be Base64-decoded before other processing.
        Dim base64 As Transform = New XmlDsigBase64Transform
        Dim tc As New TransformChain
        tc.Add(base64)
        ' Create <CipherReference> information.
        Dim reference As CipherReference = New CipherReference(uri, tc)

        ' Create a new CipherData object.
        ' Note that you cannot assign both a CipherReference and a CipherValue
        ' to a CipherData object.
        Dim cd As CipherData = New CipherData(Reference)

        ' Create a new EncryptedData object.
        Dim ed As New EncryptedData

        'Add an encryption method to the object.
        ed.Id = "ED"
        ed.EncryptionMethod = New EncryptionMethod("http://www.w3.org/2001/04/xmlenc#aes128-cbc")
        ed.CipherData = cd

        'Add key information to the object.
        Dim ki As New KeyInfo
        ki.AddClause(New KeyInfoRetrievalMethod("#EK", "http://www.w3.org/2001/04/xmlenc#EncryptedKey"))
        ed.KeyInfo = ki

        ' Create new XML document and put encrypted data into it.
        Dim doc As New XmlDocument
        Dim encryptionPropertyElement As XmlElement = CType(doc.CreateElement("EncryptionProperty", EncryptedXml.XmlEncNamespaceUrl), XmlElement)
        Dim ep As New EncryptionProperty(encryptionPropertyElement)
        ed.AddProperty(ep)

        ' Output the resulting XML information into a file.
        Dim path As String = "c:\test\MyTest.xml"
        File.WriteAllText(path, ed.GetXml().OuterXml)
    End Sub

End Module

설명

이 클래스는 XML 암호화의 <CipherReference> 요소를 나타냅니다. 처리될 때 암호화된 데이터를 생성하는 원본을 식별합니다.

에서 참조 <CipherReference> 하는 실제 암호화된 데이터는 다음 프로세스에서 가져옵니다. 속성에는 <CipherReference> URI 역참조되는 URI(Uniform Resource Identifier)가 포함되어 있습니다. 요소에 <CipherReference> 변환 체인도 포함된 경우 URI 역참조로 인한 데이터는 암호화된 데이터를 생성하도록 지정된 대로 변환됩니다. 예를 들어 암호화된 데이터가 XML 문서 내에서 base64로 인코딩된 경우 변환은 XPath 식과 base64 디코딩을 지정하여 암호화된 데이터를 추출할 수 있습니다.

URI 및 변환 구문은 XML 디지털 서명의 구문과 유사합니다. 그러나 XML 디지털 서명에서 생성 및 유효성 검사 처리는 모두 동일한 원본 데이터로 시작하고 동일한 순서로 변환을 수행합니다. XML 암호화의 암호 해독 애플리케이션에 암호화 된 데이터만 및 지정 된 변환 합니다. 변환은 암호화된 데이터를 가져오는 데 필요한 순서대로 열거됩니다.

참고 기본적으로 속성이 null이므로 웹 사이트의 DocumentEvidence 파일과 같이 알 수 없는 원본이 있는 문서의 암호 참조를 역참조할 수 없습니다. 예를 들어 웹 SecurityException 에서 파일을 참조하는 <CipherReference> 요소가 포함된 파일의 암호를 해독하려고 하면 완전히 신뢰할 수 있는 어셈블리에서 요청이 이루어진 경우에도 이 throw됩니다.

암호 해독 된 문서를 신뢰할 수 인 경우에 다음 코드를 사용 하 여 완전히 신뢰할 수 있는 애플리케이션에 대해이 동작을 변경할 수 있습니다.

Evidence ev = new Evidence();  
ev.AddHost (new Zone(SecurityZone.MyComputer));  
EncryptedXml exml = new EncryptedXml(doc, ev);  

생성자

CipherReference()

CipherReference 클래스의 새 인스턴스를 초기화합니다.

CipherReference(String)

지정된 URI(Uniform Resource Identifier)를 사용하여 CipherReference 클래스의 새 인스턴스를 초기화합니다.

CipherReference(String, TransformChain)

지정된 URI(Uniform Resource Identifier)와 변환 체인 정보를 사용하여 CipherReference 클래스의 새 인스턴스를 초기화합니다.

속성

CacheValid

캐시가 유효한지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 EncryptedReference)
ReferenceType

참조 형식을 가져오거나 설정합니다.

(다음에서 상속됨 EncryptedReference)
TransformChain

EncryptedReference 개체의 변환 체인을 가져오거나 설정합니다.

(다음에서 상속됨 EncryptedReference)
Uri

EncryptedReference 개체의 URI(Uniform Resource Identifier)를 가져오거나 설정합니다.

(다음에서 상속됨 EncryptedReference)

메서드

AddTransform(Transform)

Transform 개체를 EncryptedReference 개체의 현재 변환 체인에 추가합니다.

(다음에서 상속됨 EncryptedReference)
Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
GetXml()

CipherReference 개체의 XML 표현을 반환합니다.

LoadXml(XmlElement)

XML 정보를 XML 암호화의 <CipherReference> 요소로 로드합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상