RightsManagementInformation Class

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

System.Object
  System.IO.Packaging.RightsManagementInformation

Namespace:  System.IO.Packaging
Assembly:  WindowsBase (in WindowsBase.dll)

'Declaration
Public Class RightsManagementInformation

The RightsManagementInformation type exposes the following members.

  NameDescription
Public propertyCryptoProviderGets or sets the CryptoProvider for accessing the package's encrypted rights management data stream.
Top

  NameDescription
Public methodDeleteUseLicenseDeletes the UseLicense for a specified user from the encrypted rights management data stream.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetEmbeddedUseLicensesReturns a dictionary collection of user and UseLicense key/value pairs from the encrypted rights management data stream.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodLoadPublishLicenseReturns the embedded PublishLicense from the encrypted rights management data stream.
Public methodLoadUseLicenseReturns a specified user's embedded UseLicense from the encrypted rights management data stream.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSavePublishLicenseSaves a given PublishLicense to the encrypted rights management data stream.
Public methodSaveUseLicenseSaves a given UseLicense for a specified user to the encrypted rights management data stream.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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

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

				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)

				ePackage.Close()
				WriteStatus("   Done - Package encryption complete.")

				WriteStatus("Verifying package encryption.")
				If EncryptedPackageEnvelope.IsEncryptedPackageEnvelope(encryptedFile) Then
					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." & vbLf)
					Return False
				End If

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

				ShowStatus("   Opening the encrypted Package.")
				Dim ePackage As EncryptedPackageEnvelope = EncryptedPackageEnvelope.Open(xpsFile, FileAccess.ReadWrite)
				Dim rmi As RightsManagementInformation = ePackage.RightsManagementInformation

				ShowStatus("   Looking for an embedded UseLicense for user:" & vbLf & "       " & currentUserId & " [" & _authentication & "]")
				Dim useLicense As UseLicense = rmi.LoadUseLicense(New ContentUser(currentUserId, _authentication))

				Dim grants As ReadOnlyCollection(Of ContentGrant)
				If useLicense Is Nothing Then
					ShowStatus("   No Embedded UseLicense found." & vbLf & "       " & "Attempting to acqure UseLicnese" & vbLf & "       " & "from the PublishLicense.")
					Dim pubLicense As PublishLicense = rmi.LoadPublishLicense()

					ShowStatus("   Referral information:")

					If pubLicense.ReferralInfoName Is Nothing Then
						ShowStatus("       Name: (null)")
					Else
						ShowStatus("       Name: " & pubLicense.ReferralInfoName)
					End If

					If pubLicense.ReferralInfoUri Is Nothing Then
						ShowStatus("    Uri: (null)")
					Else
						ShowStatus("    Uri: " & pubLicense.ReferralInfoUri.ToString())
					End If

					useLicense = pubLicense.AcquireUseLicense(_secureEnv)
					If useLicense Is Nothing Then
						ShowStatus("   User DOES NOT HAVE RIGHTS" & vbLf & "       " & "to access this document!")
						Return False
					End If
				End If ' end:if (useLicense == null)
				ShowStatus("   UseLicense acquired.")

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft