UseLicense Класс

Определение

Представляет лицензию, позволяющую получить доступ к содержимому, защищенному системой управления правами.

public ref class UseLicense
[System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)]
public class UseLicense
public class UseLicense
[<System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)>]
type UseLicense = class
type UseLicense = class
Public Class UseLicense
Наследование
UseLicense
Атрибуты

Примеры

В следующем примере показано, как использовать этот класс для инициализации PublishLicense.

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

Комментарии

Как и в случае с другими System.Security.RightsManagement типами, UseLicense можно использовать только в приложениях с полным доверием.

Конструкторы

UseLicense(String)

Инициализирует новый экземпляр класса UseLicense.

Свойства

ApplicationData

Возвращает словарь данных приложения, содержащий пары ключ-значение, переданные из публикующего приложения в приложение, которое их использует.

ContentId

Возвращает созданный издателем идентификатор содержимого.

Owner

Возвращает владельца лицензии.

Методы

Bind(SecureEnvironment)

Привязывает лицензию к указанному SecureEnvironment.

Equals(Object)

Указывает, эквивалентна ли эта лицензия другой заданной лицензии.

GetHashCode()

Возвращает хэш-код, связанный с этой лицензией.

GetType()

Возвращает объект Type для текущего экземпляра.

(Унаследовано от Object)
MemberwiseClone()

Создает неполную копию текущего объекта Object.

(Унаследовано от Object)
ToString()

Возвращает сериализованную строку XrML, используемую для создания этой лицензии.

Применяется к