UseLicense UseLicense UseLicense UseLicense Class


Represents a license that enables access to protected rights managed content.

public ref class UseLicense
public class UseLicense
type UseLicense = class
Public Class UseLicense


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 =
        packageStream, publishLicense, cryptoProvider);

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

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

WriteStatus("Verifying package encryption.");
if (EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile))
    WriteStatus("   Confirmed - '" + encryptedFilename +
                "' is encrypted.");
    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)

WriteStatus("   Done - Package encryption complete.")

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


As with other System.Security.RightsManagement types, UseLicense is only usable in full trust applications.


UseLicense(String) UseLicense(String) UseLicense(String) UseLicense(String)

Initializes a new instance of the UseLicense class.


ApplicationData ApplicationData ApplicationData ApplicationData

Gets the application data dictionary that contains key/value pairs passed from the publishing application to the consuming application.

ContentId ContentId ContentId ContentId

Gets the content identifier created by the publisher.

Owner Owner Owner Owner

Gets the owner of the license.


Bind(SecureEnvironment) Bind(SecureEnvironment) Bind(SecureEnvironment) Bind(SecureEnvironment)

Binds the license to a given SecureEnvironment.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Indicates if this license is equivalent to another given license.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Returns the hash code associated with this license.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns the serialized XrML string used to create this license.

Applies to