示例#1
0
        internal PublishLicense SignIssuanceLicense(IssuanceLicense issuanceLicense, out UseLicense authorUseLicense)
        {
            CheckDisposed();

            Invariant.Assert(issuanceLicense != null);
            Invariant.Assert(!_envHandle.IsInvalid);

            using (CallbackHandler signIssuanceLicenseCallbackHandler = new CallbackHandler())
            {
                string clientLicensorCertificate = GetClientLicensorCert();

                if (clientLicensorCertificate == null)
                    throw new RightsManagementException(SR.Get(SRID.UserHasNoClientLicensorCert));

                // Trim all the leading and trailing white space characters
                // of the clientLicensorCertificate.
                clientLicensorCertificate = clientLicensorCertificate.Trim();

                // Make sure the clientLicensorCertificate is valid. By trimming white spaces
                // above, if the certificate string is empty or contains only white spaces, it
                // is empty now.
                if (clientLicensorCertificate.Length == 0)
                    throw new RightsManagementException(SR.Get(SRID.UserHasNoClientLicensorCert));

                // Offline publishing supported no Online publishing support 
                int hr = SafeNativeMethods.DRMGetSignedIssuanceLicense(
                    _envHandle,
                    issuanceLicense.Handle,
                    (uint)(SignIssuanceLicenseFlags.Offline |
                                SignIssuanceLicenseFlags.AutoGenerateKey |
                                SignIssuanceLicenseFlags.OwnerLicenseNoPersist),
                    null,
                    0,
                    NativeConstants.ALGORITHMID_AES,     // currently AES is the only supported key type 
                    clientLicensorCertificate,
                    signIssuanceLicenseCallbackHandler.CallbackDelegate,
                    null, // we are only supporting offline publishing no url needed
                    0); // no context required

                Errors.ThrowOnErrorCode(hr);

                signIssuanceLicenseCallbackHandler.WaitForCompletion();     // it will throw a proper exception in a failure case                

                // build publish License from th result 
                PublishLicense publishLicense = new PublishLicense(
                    signIssuanceLicenseCallbackHandler.CallbackData);

                // After Issuance license is signed we should build the Author's Use License 
                authorUseLicense = new UseLicense(GetOwnerLicense(issuanceLicense.Handle));

                return publishLicense;
            }
        }
示例#2
0
        /// <summary>
        /// This constructor accepts XrML Publish License template as a parameter. It parses the XrRML document 
        /// and initializes class based on that.
        /// </summary>
        public UnsignedPublishLicense(string publishLicenseTemplate) :this ()
        {
            SecurityHelper.DemandRightsManagementPermission();

            if (publishLicenseTemplate == null)
            {   
                throw new ArgumentNullException("publishLicenseTemplate");
            }
            
            using(IssuanceLicense issuanceLicense = new IssuanceLicense(
                                        DateTime.MinValue,  // validFrom, - default 
                                        DateTime.MaxValue,  // validUntil, - default 
                                        null,  // referralInfoName,
                                        null,  //  referralInfoUrl,
                                        null,  // owner,
                                        publishLicenseTemplate, 
                                        SafeRightsManagementHandle.InvalidHandle,     // boundLicenseHandle,
                                        _contentId,  //  contentId,
                                        null,    //  grantCollection
                                        null,   //  Localized Name Description pairs collection 
                                        null,   //  Application Specific Data Dictionary
                                        0,      // validity interval days 
                                        null))     // revocation point info 
            {
                // update our instance data based on the parsed information 
                issuanceLicense.UpdateUnsignedPublishLicense(this);
            }
        }
示例#3
0
 /// <summary>
 /// This method produces serialized Publish License XRML template.
 /// </summary>
 override public string ToString()
 {
     SecurityHelper.DemandRightsManagementPermission();
 
     using(IssuanceLicense issuanceLicense = new IssuanceLicense(
                                 DateTime.MinValue, 
                                 DateTime.MaxValue, 
                                 _referralInfoName,
                                 _referralInfoUri,
                                 _owner,
                                 null,
                                 SafeRightsManagementHandle.InvalidHandle,     // boundLicenseHandle,
                                 _contentId,
                                 Grants,
                                 LocalizedNameDescriptionDictionary,
                                 ApplicationSpecificDataDictionary,
                                 _rightValidityIntervalDays,
                                 _revocationPoint))
     {
         return issuanceLicense.ToString();
     }
 }
示例#4
0
 /// <summary>
 /// This constructor accepts Signed XrML Publish License as a parameter. 
 /// It decrypts and parses parses the XrRML document and initializes class based on that.
 /// </summary>
 internal UnsignedPublishLicense(SafeRightsManagementHandle boundLicenseHandle, string publishLicenseTemplate)
                                                                                                                                  :this ()
 {
     Invariant.Assert(!boundLicenseHandle.IsInvalid);
     Invariant.Assert(publishLicenseTemplate != null);
     
     using(IssuanceLicense issuanceLicense = new IssuanceLicense(
                                 DateTime.MinValue,  // validFrom, - default 
                                 DateTime.MaxValue,  // validUntil, - default 
                                 null,  // referralInfoName,
                                 null,  //  referralInfoUrl,
                                 null,  // owner,
                                 publishLicenseTemplate, 
                                 boundLicenseHandle,     // boundLicenseHandle,
                                 _contentId,  //  contentId,
                                 null,    //  grantCollection
                                 null,   //  Localized Name Description pairs collection 
                                 null,   //  Application Specific Data Dictionary                                        
                                 0,       // validity interval days 
                                 null))     // revocation point info 
     {
         // update our instance data based on the parsed information 
         issuanceLicense.UpdateUnsignedPublishLicense(this);
     }
 }
示例#5
0
        /// <summary>
        /// This functions signs the Publish License offline, and as a result produces 2 objects. It makes an instance of the  PublishLicense 
        /// and it also builds an instance of the UseLicense, which represeents the authors UseLicense 
        /// </summary>
        public PublishLicense Sign(SecureEnvironment secureEnvironment, out UseLicense authorUseLicense)
        {
            SecurityHelper.DemandRightsManagementPermission();

            if (secureEnvironment == null)
            {
                throw new ArgumentNullException("secureEnvironment");
            }

            // in case owner wasn't specified we can just assume default owner 
            // based on the user identity that was used to build the secure environment
            ContentUser contentOwner;

            if (_owner != null)
            {
                contentOwner = _owner; 
            }
            else
            {
                contentOwner = secureEnvironment.User;
            }

            using(IssuanceLicense issuanceLicense = new IssuanceLicense(
                                        DateTime.MinValue,  // validFrom, - default 
                                        DateTime.MaxValue,  // validUntil, - default 
                                        _referralInfoName,
                                        _referralInfoUri,
                                        contentOwner,
                                        null,
                                        SafeRightsManagementHandle.InvalidHandle,     // boundLicenseHandle,
                                        _contentId,
                                        Grants,
                                        LocalizedNameDescriptionDictionary,
                                        ApplicationSpecificDataDictionary,
                                        _rightValidityIntervalDays,
                                        _revocationPoint))
            {
                // The SecureEnvironment constructor makes sure ClientSession cannot be null.
                // Accordingly suppressing preSharp warning about having to validate ClientSession.
#pragma warning suppress 6506
                return secureEnvironment.ClientSession.SignIssuanceLicense(issuanceLicense, out authorUseLicense);
            }
        }