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:
- Store information about the document, such as its path and publishing status, in a collection object (m_RmhDocProp).
- Create an RMSWsrv object.
- Start encrypting the MHT file by using the RMSWsrv object's asynchronous handle to the Crypto.Encrypt method.
- 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.
- Get the issuance license signed (by calling the private method GetSignedPublishingLicense).
- Add the signed issuance license to the compound file (by calling the Cdoclib.dll function AddPublishingLicense).
- Update the document's status.
- 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:
- Check the container file out of the store (Checkout).
- Copy the existing issuance license from the file (GetPublishingLicense).
- Create a new content key (this key is only required for the republishing call; it does not replace the old key).
- Create a new unsigned issuance license (GetUnsignedPublishingLicense).
- Update the old issuance license with the new data (by using rmsServer.EditPublishingLicense, which calls the SOAP proxy function EditIssuanceLicense).
- 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.
- 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:
- Get the path to the file in the library (GetRmhDocument).
- Extract the issuance license from the container file (GetPublishingLicense).
- Get the use license by using RMSWsrv.AcquireEndUserLicense (which wraps the SOAP call AcquirePreLicense).
- Serialize the use license chain into a format that a consuming application can use (CreateMsdrmCompatibleChain).
- Create a new name for the use license, beginning with "EUL-".
- Add the use license to the container file (AddEndUserLicense).
- Return the file's location in the document library.
GetUnsignedPublishingLicense
The GetUnsignedPublishingLicense method creates a new, unsigned issuance license, by completing the following steps:
Create a new issuance license by using the DRMCreateIssuanceLicense function.
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:
- Create an AD RMS right by using DRMCreateRight.
- 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.
- Add the user/right pair by using the DRMAddRightWithUser function.
Add metadata to the issuance license, including random GUIDs for the content ID and SKU.
Add the name-value pair "Allow_Server_Editing"/"True", to allow your application to update the issuance license when a user requests content.
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