Share via


Rmhdoc Class

The Rmhdoc class is the controlling class for the whole project. It accesses all the other classes, as well as the unmanaged DLL Cdoclib.dll.

Method Description
CreateMsdrmCompatibleChain This helper method converts string arrays into values that DRMGetSignedIssuanceLicense or AD RMS license-consuming applications can use.
EncryptCallback This asynchronous callback method alerts the class that encryption of a document has completed. Allowing encryption to be an asynchronous method can improve performance because multiple publishing methods can be attempted simultaneously.
GetSignedPublishingLicense (private) This internal method uses SOAP methods to get a issuance license signed.
GetUnsignedPublishingLicense (private) This internal method creates an unsigned issuance license. For more information, see GetUnsignedPublishingLicense, later in this topic.
PreLicense This is the last method that an application performs on a document when it is requested. This method obtains a use license for a document and puts it into the compound file.

For more information about this method, see PreLicense, later in this topic.

Publish This is the first method that the application performs on a document. This method handles the encryption and issuance license acquisition for a new document submitted to the library. It accepts the path to a file to publish. Encryption and issuance license acquisition take place simultaneously.

For more information about this method, see Publish, later in this topic.

Republish This method updates an issuance license in a compound file before the file is downloaded by a client.

For more information about this method, see Republish, later in this topic.

RmOnStatus This asynchronous callback method is called when an asynchronous method completes. It is represented by the delegate MsdrmCallback.

The Rmhdoc class defines four key methods: Publish, Republish, PreLicense, and GetUnsignedPublishingLicense. These methods are described below.

  • Publish
  • Republish
  • PreLicense
  • GetUnsignedPublishingLicense

Publish

The Publish method encrypts a document, creates a new issuance license and a new container file, and then puts the document and new issuance license into the new container file. This method completes the following steps:

  1. Store information about the document, such as its path and publishing status, in a collection object (m_RmhDocProp).
  2. Create an RMSWsrv object.
  3. Start encrypting the MHT file by using the RMSWsrv object's asynchronous handle to the Crypto.Encrypt method.
  4. Create the unsigned issuance license (by calling the private method GetUnsignedPublishingLicense). The Web application adds arbitrary values such as validity times and metadata to the issuance license. You can specify the values to be added. User rights are assigned by calling RmhStore.StoreUserRights (for more information, see RmhStore.
  5. Get the issuance license signed (by calling the private method GetSignedPublishingLicense).
  6. Add the signed issuance license to the compound file (by calling the Cdoclib.dll function AddPublishingLicense).
  7. Update the document's status.
  8. List the new document as checked in by calling Checkin.

Republish

The Republish method replaces an existing signed issuance license by completing the following steps:

  1. Check the container file out of the store (Checkout).
  2. Copy the existing issuance license from the file (GetPublishingLicense).
  3. Create a new content key (this key is only required for the republishing call; it does not replace the old key).
  4. Create a new unsigned issuance license (GetUnsignedPublishingLicense).
  5. Update the old issuance license with the new data (by using rmsServer.EditPublishingLicense, which calls the SOAP proxy function EditIssuanceLicense).
  6. When the new issuance license is returned, replace the old issuance license in the compound file with the new signed issuance license (the first certificate in the retrieved chain) by using the UpdatePublishingLicense function from the Cdoclib.dll file.
  7. Check the file back into the store (Checkin).

PreLicense

The PreLicense method obtains a use license, adds it to the container file, and returns a path to the file by completing the following steps:

  1. Get the path to the file in the library (GetRmhDocument).
  2. Extract the issuance license from the container file (GetPublishingLicense).
  3. Get the use license by using RMSWsrv.AcquireEndUserLicense (which wraps the SOAP call AcquirePreLicense).
  4. Serialize the use license chain into a format that a consuming application can use (CreateMsdrmCompatibleChain).
  5. Create a new name for the use license, beginning with "EUL-".
  6. Add the use license to the container file (AddEndUserLicense).
  7. Return the file's location in the document library.

GetUnsignedPublishingLicense

The GetUnsignedPublishingLicense method creates a new, unsigned issuance license, by completing the following steps:

  1. Create a new issuance license by using the DRMCreateIssuanceLicense function.

  2. Enumerate the two Right objects (View and Other) in the StoreRights class. For each Right object, enumerate the XrML rights associated with it. These would be VIEW for View, and EDIT, PRINT, and so on for Other. The exact list is described in the section StoreRights, Dacl, Ace, Sid, Right, and User Classes. For each XrML right, the GetUnsignedPublishingLicense method completes the following tasks:

    1. Create an AD RMS right by using DRMCreateRight.
    2. Enumerate the permitted users associated with that XrML right. A list of permitted users is stored in the Right object. If this user does not exist in an existing Hashtable of AD RMS user objects, create an AD RMS user object by using the DRMCreateUser function.
    3. Add the user/right pair by using the DRMAddRightWithUser function.
  3. Add metadata to the issuance license, including random GUIDs for the content ID and SKU.

  4. Add the name-value pair "Allow_Server_Editing"/"True", to allow your application to update the issuance license when a user requests content.

  5. Get the stored content key and licensor certificate chain from memory, and pass them into the DRMGetSignedIssuanceLicense function with the DRM_SERVER_ISSUANCELICENSE flag. The signed issuance license is returned to the RmOnStatus callback method.

See Also

Protected Document Library Sample Classes and Functions

Send comments about this topic to Microsoft

Build date: 3/13/2008