PublishLicense PublishLicense PublishLicense PublishLicense Class


Represents a signed rights managed publish license.

public ref class PublishLicense
public class PublishLicense
type PublishLicense = class
Public Class PublishLicense


The following example shows how to initialize a PublishLicense by using the Sign method.

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


PublishLicense defines security data about rights, users, and other security-related information. The license defines how a specific user on a specific computer can use specified rights managed content.

The publishing process begins with the document author, who defines rights information in an UnsignedPublishLicense. Next, the author creates a signed PublishLicense by calling the Sign method of the UnsignedPublishLicense. The serialized form of the signed PublishLicense can then be provided to end users who can use it to acquire a UseLicense by calling the AcquireUseLicense method of the PublishLicense. The returned UseLicense then allows the client application to exercise the rights that were granted to the user.

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


PublishLicense(String) PublishLicense(String) PublishLicense(String) PublishLicense(String)

Initializes a new instance of the PublishLicense class from a specified serialized and signed PublishLicense.


ContentId ContentId ContentId ContentId

Gets the publisher-created content identifier.

ReferralInfoName ReferralInfoName ReferralInfoName ReferralInfoName

Gets the contact name for the author or publisher of the content.

ReferralInfoUri ReferralInfoUri ReferralInfoUri ReferralInfoUri

Gets the contact URI for the author or publisher of the content.

UseLicenseAcquisitionUrl UseLicenseAcquisitionUrl UseLicenseAcquisitionUrl UseLicenseAcquisitionUrl

Gets the URI to use for acquiring a UseLicense.


AcquireUseLicense(SecureEnvironment) AcquireUseLicense(SecureEnvironment) AcquireUseLicense(SecureEnvironment) AcquireUseLicense(SecureEnvironment)

Attempts to acquire a UseLicense for a user or user group in a specified SecureEnvironment.

AcquireUseLicenseNoUI(SecureEnvironment) AcquireUseLicenseNoUI(SecureEnvironment) AcquireUseLicenseNoUI(SecureEnvironment) AcquireUseLicenseNoUI(SecureEnvironment)

Attempts to acquire a UseLicense for a user or user group in a specified SecureEnvironment.

DecryptUnsignedPublishLicense(CryptoProvider) DecryptUnsignedPublishLicense(CryptoProvider) DecryptUnsignedPublishLicense(CryptoProvider) DecryptUnsignedPublishLicense(CryptoProvider)

Returns a decrypted UnsignedPublishLicense version of this signed PublishLicense.

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

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
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 that was used to create this license.

Applies to

See also