EncryptedPackageEnvelope.CreateFromPackage Yöntem

Tanım

İçeriğinin kaynağı olarak mevcut şifrelenmemiş paketi kullanan bir EncryptedPackageEnvelope oluşturur ve döndürür.

Aşırı Yüklemeler

CreateFromPackage(Stream, Stream, PublishLicense, CryptoProvider)

İçeriği olarak belirtilen şifrelenmemiş paketi kullanan bir EncryptedPackageEnvelope (belirtilen akışta) oluşturur ve döndürür.

CreateFromPackage(String, Stream, PublishLicense, CryptoProvider)

İçeriği olarak belirtilen şifrelenmemiş paketi kullanan ve belirtilen dosya adını veren bir EncryptedPackageEnvelope oluşturur ve döndürür.

Örnekler

Aşağıdaki örnekte, bir örneğini EncryptedPackageEnvelopebaşlatmak için yönteminin CreateFromPackage nasıl kullanılacağı gösterilmektedir.

WriteStatus("   Signing the UnsignedPublishLicense\n" +
            "       to build the PublishLicense.");
UseLicense authorsUseLicense;
PublishLicense publishLicense =
    unsignedLicense.Sign(_secureEnv, out authorsUseLicense);

WriteStatus("   Binding the author's UseLicense and");
WriteStatus("       obtaining the CryptoProvider.");
CryptoProvider cryptoProvider = authorsUseLicense.Bind(_secureEnv);

WriteStatus("   Creating the EncryptedPackage.");
Stream packageStream = File.OpenRead(packageFile);
EncryptedPackageEnvelope ePackage =
    EncryptedPackageEnvelope.CreateFromPackage(encryptedFile,
        packageStream, publishLicense, cryptoProvider);

WriteStatus("   Adding an author's UseLicense.");
RightsManagementInformation rmi =
    ePackage.RightsManagementInformation;
rmi.SaveUseLicense(author, authorsUseLicense);

ePackage.Close();
WriteStatus("   Done - Package encryption complete.");

WriteStatus("Verifying package encryption.");
if (EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile))
{
    WriteStatus("   Confirmed - '" + encryptedFilename +
                "' is encrypted.");
}
else
{
    MessageBox.Show("ERROR: '" + encryptedFilename +
        "' is NOT ENCRYPTED.", "Encryption Error",
        MessageBoxButton.OK, MessageBoxImage.Error);
    WriteStatus("ERROR: '" + encryptedFilename +
                "' is NOT ENCRYPTED.\n");
    return false;
}
WriteStatus("   Signing the UnsignedPublishLicense" & vbLf & "       to build the PublishLicense.")
Dim authorsUseLicense As UseLicense = Nothing
Dim publishLicense As PublishLicense = unsignedLicense.Sign(_secureEnv, authorsUseLicense)

WriteStatus("   Binding the author's UseLicense and")
WriteStatus("       obtaining the CryptoProvider.")
Dim cryptoProvider As CryptoProvider = authorsUseLicense.Bind(_secureEnv)

WriteStatus("   Creating the EncryptedPackage.")
Dim packageStream As Stream = File.OpenRead(packageFile)
Dim ePackage As EncryptedPackageEnvelope = EncryptedPackageEnvelope.CreateFromPackage(encryptedFile, packageStream, publishLicense, cryptoProvider)

WriteStatus("   Adding an author's UseLicense.")
Dim rmi As RightsManagementInformation = ePackage.RightsManagementInformation
rmi.SaveUseLicense(author, authorsUseLicense)

ePackage.Close()
WriteStatus("   Done - Package encryption complete.")

WriteStatus("Verifying package encryption.")
If EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile) Then
    WriteStatus("   Confirmed - '" & encryptedFilename & "' is encrypted.")
Else
    MessageBox.Show("ERROR: '" & encryptedFilename & "' is NOT ENCRYPTED.", "Encryption Error", MessageBoxButton.OK, MessageBoxImage.Error)
    WriteStatus("ERROR: '" & encryptedFilename & "' is NOT ENCRYPTED." & vbLf)
    Return False
End If

CreateFromPackage(Stream, Stream, PublishLicense, CryptoProvider)

İçeriği olarak belirtilen şifrelenmemiş paketi kullanan bir EncryptedPackageEnvelope (belirtilen akışta) oluşturur ve döndürür.

public:
 static System::IO::Packaging::EncryptedPackageEnvelope ^ CreateFromPackage(System::IO::Stream ^ envelopeStream, System::IO::Stream ^ packageStream, System::Security::RightsManagement::PublishLicense ^ publishLicense, System::Security::RightsManagement::CryptoProvider ^ cryptoProvider);
public static System.IO.Packaging.EncryptedPackageEnvelope CreateFromPackage (System.IO.Stream envelopeStream, System.IO.Stream packageStream, System.Security.RightsManagement.PublishLicense publishLicense, System.Security.RightsManagement.CryptoProvider cryptoProvider);
static member CreateFromPackage : System.IO.Stream * System.IO.Stream * System.Security.RightsManagement.PublishLicense * System.Security.RightsManagement.CryptoProvider -> System.IO.Packaging.EncryptedPackageEnvelope
Public Shared Function CreateFromPackage (envelopeStream As Stream, packageStream As Stream, publishLicense As PublishLicense, cryptoProvider As CryptoProvider) As EncryptedPackageEnvelope

Parametreler

envelopeStream
Stream

Dosyanın oluşturulacağı akış.

packageStream
Stream

Mevcut şifrelenmemiş paketi temsil eden akış.

publishLicense
PublishLicense

Bileşik dosyaya eklenmiş yayımlama lisansı.

cryptoProvider
CryptoProvider

Geçerli kullanıcının şifrelenmiş içerik üzerinde hangi işlemleri gerçekleştirmesine izin verileceğini belirleyen bir nesne.

Döndürülenler

Yeni oluşturulan EncryptedPackageEnvelope.

Özel durumlar

envelopeStream veya packageStream şeklindedir null.

envelopeStream okuma/yazma erişimi sağlamaz.

Örnekler

Aşağıdaki örnekte, bir örneğini EncryptedPackageEnvelopebaşlatmak için yönteminin CreateFromPackage nasıl kullanılacağı gösterilmektedir.

WriteStatus("   Signing the UnsignedPublishLicense\n" +
            "       to build the PublishLicense.");
UseLicense authorsUseLicense;
PublishLicense publishLicense =
    unsignedLicense.Sign(_secureEnv, out authorsUseLicense);

WriteStatus("   Binding the author's UseLicense and");
WriteStatus("       obtaining the CryptoProvider.");
CryptoProvider cryptoProvider = authorsUseLicense.Bind(_secureEnv);

WriteStatus("   Creating the EncryptedPackage.");
Stream packageStream = File.OpenRead(packageFile);
EncryptedPackageEnvelope ePackage =
    EncryptedPackageEnvelope.CreateFromPackage(encryptedFile,
        packageStream, publishLicense, cryptoProvider);

WriteStatus("   Adding an author's UseLicense.");
RightsManagementInformation rmi =
    ePackage.RightsManagementInformation;
rmi.SaveUseLicense(author, authorsUseLicense);

ePackage.Close();
WriteStatus("   Done - Package encryption complete.");

WriteStatus("Verifying package encryption.");
if (EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile))
{
    WriteStatus("   Confirmed - '" + encryptedFilename +
                "' is encrypted.");
}
else
{
    MessageBox.Show("ERROR: '" + encryptedFilename +
        "' is NOT ENCRYPTED.", "Encryption Error",
        MessageBoxButton.OK, MessageBoxImage.Error);
    WriteStatus("ERROR: '" + encryptedFilename +
                "' is NOT ENCRYPTED.\n");
    return false;
}
WriteStatus("   Signing the UnsignedPublishLicense" & vbLf & "       to build the PublishLicense.")
Dim authorsUseLicense As UseLicense = Nothing
Dim publishLicense As PublishLicense = unsignedLicense.Sign(_secureEnv, authorsUseLicense)

WriteStatus("   Binding the author's UseLicense and")
WriteStatus("       obtaining the CryptoProvider.")
Dim cryptoProvider As CryptoProvider = authorsUseLicense.Bind(_secureEnv)

WriteStatus("   Creating the EncryptedPackage.")
Dim packageStream As Stream = File.OpenRead(packageFile)
Dim ePackage As EncryptedPackageEnvelope = EncryptedPackageEnvelope.CreateFromPackage(encryptedFile, packageStream, publishLicense, cryptoProvider)

WriteStatus("   Adding an author's UseLicense.")
Dim rmi As RightsManagementInformation = ePackage.RightsManagementInformation
rmi.SaveUseLicense(author, authorsUseLicense)

ePackage.Close()
WriteStatus("   Done - Package encryption complete.")

WriteStatus("Verifying package encryption.")
If EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile) Then
    WriteStatus("   Confirmed - '" & encryptedFilename & "' is encrypted.")
Else
    MessageBox.Show("ERROR: '" & encryptedFilename & "' is NOT ENCRYPTED.", "Encryption Error", MessageBoxButton.OK, MessageBoxImage.Error)
    WriteStatus("ERROR: '" & encryptedFilename & "' is NOT ENCRYPTED." & vbLf)
    Return False
End If

Açıklamalar

Geçerli kullanıcının yeni dosyaya okuma/yazma erişimi vardır.

Ayrıca bkz.

Şunlara uygulanır

CreateFromPackage(String, Stream, PublishLicense, CryptoProvider)

İçeriği olarak belirtilen şifrelenmemiş paketi kullanan ve belirtilen dosya adını veren bir EncryptedPackageEnvelope oluşturur ve döndürür.

public:
 static System::IO::Packaging::EncryptedPackageEnvelope ^ CreateFromPackage(System::String ^ envelopeFileName, System::IO::Stream ^ packageStream, System::Security::RightsManagement::PublishLicense ^ publishLicense, System::Security::RightsManagement::CryptoProvider ^ cryptoProvider);
public static System.IO.Packaging.EncryptedPackageEnvelope CreateFromPackage (string envelopeFileName, System.IO.Stream packageStream, System.Security.RightsManagement.PublishLicense publishLicense, System.Security.RightsManagement.CryptoProvider cryptoProvider);
static member CreateFromPackage : string * System.IO.Stream * System.Security.RightsManagement.PublishLicense * System.Security.RightsManagement.CryptoProvider -> System.IO.Packaging.EncryptedPackageEnvelope
Public Shared Function CreateFromPackage (envelopeFileName As String, packageStream As Stream, publishLicense As PublishLicense, cryptoProvider As CryptoProvider) As EncryptedPackageEnvelope

Parametreler

envelopeFileName
String

OLE bileşik dosyasının adı.

packageStream
Stream

Mevcut şifrelenmemiş paketi temsil eden akış.

publishLicense
PublishLicense

Bileşik dosyaya eklenmiş yayımlama lisansı.

cryptoProvider
CryptoProvider

Geçerli kullanıcının şifrelenmiş içerik üzerinde hangi işlemleri gerçekleştirmesine izin verileceğini belirleyen bir nesne.

Döndürülenler

Yeni oluşturulan EncryptedPackageEnvelope.

Özel durumlar

envelopeFileName veya packageStream şeklindedir null.

Örnekler

Aşağıdaki örnekte, bir örneğini EncryptedPackageEnvelopebaşlatmak için yönteminin CreateFromPackage nasıl kullanılacağı gösterilmektedir.

WriteStatus("   Signing the UnsignedPublishLicense\n" +
            "       to build the PublishLicense.");
UseLicense authorsUseLicense;
PublishLicense publishLicense =
    unsignedLicense.Sign(_secureEnv, out authorsUseLicense);

WriteStatus("   Binding the author's UseLicense and");
WriteStatus("       obtaining the CryptoProvider.");
CryptoProvider cryptoProvider = authorsUseLicense.Bind(_secureEnv);

WriteStatus("   Creating the EncryptedPackage.");
Stream packageStream = File.OpenRead(packageFile);
EncryptedPackageEnvelope ePackage =
    EncryptedPackageEnvelope.CreateFromPackage(encryptedFile,
        packageStream, publishLicense, cryptoProvider);

WriteStatus("   Adding an author's UseLicense.");
RightsManagementInformation rmi =
    ePackage.RightsManagementInformation;
rmi.SaveUseLicense(author, authorsUseLicense);

ePackage.Close();
WriteStatus("   Done - Package encryption complete.");

WriteStatus("Verifying package encryption.");
if (EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile))
{
    WriteStatus("   Confirmed - '" + encryptedFilename +
                "' is encrypted.");
}
else
{
    MessageBox.Show("ERROR: '" + encryptedFilename +
        "' is NOT ENCRYPTED.", "Encryption Error",
        MessageBoxButton.OK, MessageBoxImage.Error);
    WriteStatus("ERROR: '" + encryptedFilename +
                "' is NOT ENCRYPTED.\n");
    return false;
}
WriteStatus("   Signing the UnsignedPublishLicense" & vbLf & "       to build the PublishLicense.")
Dim authorsUseLicense As UseLicense = Nothing
Dim publishLicense As PublishLicense = unsignedLicense.Sign(_secureEnv, authorsUseLicense)

WriteStatus("   Binding the author's UseLicense and")
WriteStatus("       obtaining the CryptoProvider.")
Dim cryptoProvider As CryptoProvider = authorsUseLicense.Bind(_secureEnv)

WriteStatus("   Creating the EncryptedPackage.")
Dim packageStream As Stream = File.OpenRead(packageFile)
Dim ePackage As EncryptedPackageEnvelope = EncryptedPackageEnvelope.CreateFromPackage(encryptedFile, packageStream, publishLicense, cryptoProvider)

WriteStatus("   Adding an author's UseLicense.")
Dim rmi As RightsManagementInformation = ePackage.RightsManagementInformation
rmi.SaveUseLicense(author, authorsUseLicense)

ePackage.Close()
WriteStatus("   Done - Package encryption complete.")

WriteStatus("Verifying package encryption.")
If EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile) Then
    WriteStatus("   Confirmed - '" & encryptedFilename & "' is encrypted.")
Else
    MessageBox.Show("ERROR: '" & encryptedFilename & "' is NOT ENCRYPTED.", "Encryption Error", MessageBoxButton.OK, MessageBoxImage.Error)
    WriteStatus("ERROR: '" & encryptedFilename & "' is NOT ENCRYPTED." & vbLf)
    Return False
End If

Açıklamalar

Belirtilen ada sahip bir dosya zaten varsa, üzerine yazılır.

Geçerli kullanıcının dosyaya okuma/yazma erişimi vardır.

Ayrıca bkz.

Şunlara uygulanır