EncryptedPackageEnvelope.CreateFromPackage EncryptedPackageEnvelope.CreateFromPackage EncryptedPackageEnvelope.CreateFromPackage Method

定義

既存の暗号化されていないパッケージをコンテンツのソースとして使用する EncryptedPackageEnvelope を作成して返します。Creates and returns an EncryptedPackageEnvelope that uses an existing unencrypted package as the source of its content.

オーバーロード

CreateFromPackage(Stream, Stream, PublishLicense, CryptoProvider) CreateFromPackage(Stream, Stream, PublishLicense, CryptoProvider) CreateFromPackage(Stream, Stream, PublishLicense, CryptoProvider)

指定した暗号化されていないパッケージをコンテンツとして使用する EncryptedPackageEnvelope を (指定したストリームに) 作成して返します。Creates and returns an EncryptedPackageEnvelope (on the specified stream) that uses the specified unencrypted package as its content.

CreateFromPackage(String, Stream, PublishLicense, CryptoProvider) CreateFromPackage(String, Stream, PublishLicense, CryptoProvider) CreateFromPackage(String, Stream, PublishLicense, CryptoProvider)

指定した暗号化されていないパッケージをコンテンツとして使用する EncryptedPackageEnvelope を作成して返し、指定したファイル名を割り当てます。Creates and returns an EncryptedPackageEnvelope that uses the specified unencrypted package as its content, and gives it the specified file name.

次の例は、使用する方法を示します、CreateFromPackageをインスタンス化するメソッド、EncryptedPackageEnvelopeします。The following example shows how to use the CreateFromPackage method to instantiate an EncryptedPackageEnvelope.

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) CreateFromPackage(Stream, Stream, PublishLicense, CryptoProvider) CreateFromPackage(Stream, Stream, PublishLicense, CryptoProvider)

指定した暗号化されていないパッケージをコンテンツとして使用する EncryptedPackageEnvelope を (指定したストリームに) 作成して返します。Creates and returns an EncryptedPackageEnvelope (on the specified stream) that uses the specified unencrypted package as its content.

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

パラメーター

envelopeStream
Stream Stream Stream

ファイルを作成するストリーム。The stream on which to create the file.

packageStream
Stream Stream Stream

暗号化されていない、既存のパッケージを表すストリーム。The stream representing the existing unencrypted package.

publishLicense
PublishLicense PublishLicense PublishLicense

複合ファイルに埋め込まれている公開ライセンス。The publish license that is embedded in the compound file.

cryptoProvider
CryptoProvider CryptoProvider CryptoProvider

現在のユーザーが暗号化されたコンテンツで実行できる操作を決定するオブジェクト。An object that determines what operations the current user is allowed to perform on the encrypted content.

戻り値

例外

envelopeStream または packageStreamnull です。envelopeStream or packageStream is null.

envelopeStream が読み取り/書き込みアクセスを提供しません。envelopeStream does not provide read/write access.

次の例は、使用する方法を示します、CreateFromPackageをインスタンス化するメソッド、EncryptedPackageEnvelopeします。The following example shows how to use the CreateFromPackage method to instantiate an EncryptedPackageEnvelope.

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

注釈

現在のユーザーは、読み取り/書き込みアクセスを新しいファイルを持ちます。The current user has read/write access to the new file.

こちらもご覧ください

CreateFromPackage(String, Stream, PublishLicense, CryptoProvider) CreateFromPackage(String, Stream, PublishLicense, CryptoProvider) CreateFromPackage(String, Stream, PublishLicense, CryptoProvider)

指定した暗号化されていないパッケージをコンテンツとして使用する EncryptedPackageEnvelope を作成して返し、指定したファイル名を割り当てます。Creates and returns an EncryptedPackageEnvelope that uses the specified unencrypted package as its content, and gives it the specified file name.

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

パラメーター

envelopeFileName
String String String

OLE 複合ファイルの名前。The name of the OLE compound file.

packageStream
Stream Stream Stream

暗号化されていない、既存のパッケージを表すストリーム。The stream representing the existing unencrypted package.

publishLicense
PublishLicense PublishLicense PublishLicense

複合ファイルに埋め込まれている公開ライセンス。The publish license that is embedded in the compound file.

cryptoProvider
CryptoProvider CryptoProvider CryptoProvider

現在のユーザーが暗号化されたコンテンツで実行できる操作を決定するオブジェクト。An object that determines what operations the current user is allowed to perform on the encrypted content.

戻り値

例外

envelopeFileName または packageStreamnull です。envelopeFileName or packageStream is null.

次の例は、使用する方法を示します、CreateFromPackageをインスタンス化するメソッド、EncryptedPackageEnvelopeします。The following example shows how to use the CreateFromPackage method to instantiate an EncryptedPackageEnvelope.

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

注釈

指定した名前のファイルが既に存在する場合は上書きされます。If a file with the specified name already exists, it is overwritten.

現在のユーザーは、読み取り/書き込みアクセスをファイルを持ちます。The current user has read/write access to the file.

こちらもご覧ください

適用対象