UseLicense Clase

Definición

Representa una licencia que permite el acceso a contenido administrado con derechos protegidos.Represents a license that enables access to protected rights managed content.

public ref class UseLicense
public class UseLicense
[System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)]
public class UseLicense
type UseLicense = class
[<System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)>]
type UseLicense = class
Public Class UseLicense
Herencia
UseLicense
Atributos

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar esta clase para inicializar un PublishLicense .The following example shows how to use this class to initialize a 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

Comentarios

Como con otros System.Security.RightsManagement tipos, UseLicense solo se puede usar en aplicaciones de plena confianza.As with other System.Security.RightsManagement types, UseLicense is only usable in full trust applications.

Constructores

UseLicense(String)

Inicializa una nueva instancia de la clase UseLicense.Initializes a new instance of the UseLicense class.

Propiedades

ApplicationData

Obtiene el diccionario de datos de aplicación que contiene los pares de clave y valor pasados de la aplicación de publicación a la aplicación que los utiliza.Gets the application data dictionary that contains key/value pairs passed from the publishing application to the consuming application.

ContentId

Obtiene el identificador de contenido creado por el editor.Gets the content identifier created by the publisher.

Owner

Obtiene el propietario de la licencia.Gets the owner of the license.

Métodos

Bind(SecureEnvironment)

Enlaza la licencia a un SecureEnvironment determinado.Binds the license to a given SecureEnvironment.

Equals(Object)

Indica si esta licencia es equivalente a otra licencia determinada.Indicates if this license is equivalent to another given license.

GetHashCode()

Devuelve el código hash asociado con esta licencia.Returns the hash code associated with this license.

GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Heredado de Object)
MemberwiseClone()

Crea una copia superficial del Object actual.Creates a shallow copy of the current Object.

(Heredado de Object)
ToString()

Devuelve la cadena XrML serializada utilizada para crear esta licencia.Returns the serialized XrML string used to create this license.

Se aplica a