Прочетете на английски Редактиране

Споделяне чрез


RightsManagementInformation Class

Definition

Represents Digital Rights Management (DRM) information that is stored in an EncryptedPackageEnvelope.

C#
public class RightsManagementInformation
Inheritance
RightsManagementInformation

Examples

The following example shows how to initialize a RightsManagementInformation object for encryption.

C#
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;
}

The following example shows how to initialize a RightsManagementInformation object for decryption.

C#
ShowStatus("   Opening the encrypted Package.");
EncryptedPackageEnvelope ePackage =
    EncryptedPackageEnvelope.Open(xpsFile, FileAccess.ReadWrite);
RightsManagementInformation rmi =
    ePackage.RightsManagementInformation;

ShowStatus("   Looking for an embedded UseLicense for user:\n       " +
           currentUserId + " [" + _authentication + "]");
UseLicense useLicense =
    rmi.LoadUseLicense(
        new ContentUser(currentUserId, _authentication));

ReadOnlyCollection<ContentGrant> grants;
if (useLicense == null)
{
    ShowStatus("   No Embedded UseLicense found.\n       " +
               "Attempting to acqure UseLicnese\n       " +
               "from the PublishLicense.");
    PublishLicense pubLicense = rmi.LoadPublishLicense();

    ShowStatus("   Referral information:");

    if (pubLicense.ReferralInfoName == null)
        ShowStatus("       Name: (null)");
    else
        ShowStatus("       Name: " + pubLicense.ReferralInfoName);

    if (pubLicense.ReferralInfoUri == null)
        ShowStatus("    Uri: (null)");
    else
        ShowStatus("    Uri: " +
            pubLicense.ReferralInfoUri.ToString());

    useLicense = pubLicense.AcquireUseLicense(_secureEnv);
    if (useLicense == null)
    {
        ShowStatus("   User DOES NOT HAVE RIGHTS\n       " +
            "to access this document!");
        return false;
    }
}// end:if (useLicense == null)
ShowStatus("   UseLicense acquired.");

Remarks

RightsManagementInformation provides access to the PublishLicense and UseLicense data stored in a rights managed protected Package.

Properties

CryptoProvider

Gets or sets the CryptoProvider for accessing the package's encrypted rights management data stream.

Methods

DeleteUseLicense(ContentUser)

Deletes the UseLicense for a specified user from the encrypted rights management data stream.

Equals(Object)

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

(Inherited from Object)
GetEmbeddedUseLicenses()

Returns a dictionary collection of user and UseLicense key/value pairs from the encrypted rights management data stream.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
LoadPublishLicense()

Returns the embedded PublishLicense from the encrypted rights management data stream.

LoadUseLicense(ContentUser)

Returns a specified user's embedded UseLicense from the encrypted rights management data stream.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SavePublishLicense(PublishLicense)

Saves a given PublishLicense to the encrypted rights management data stream.

SaveUseLicense(ContentUser, UseLicense)

Saves a given UseLicense for a specified user to the encrypted rights management data stream.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Продукт Версии
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also