Пример #1
0
        private SafeRightsManagementPubHandle GetRightHandle(ContentGrant grant)
        {
            SafeRightsManagementPubHandle rightHandle = null;

            // we only need to use date time inteval if at least one of the values isn't default to Min max
            // If both of the Min Max we can leave tyhem as nulls otherwise (if at least one not default)
            // we need to set both
            SystemTime systemTimeValidFrom  = null;
            SystemTime systemTimeValidUntil = null;

            if ((grant.ValidFrom != DateTime.MinValue) || (grant.ValidUntil != DateTime.MaxValue))
            {
                // we need to use non null values if at least one of the time boundaries isn't default
                // DRM SDK will not enforce date time unless both timeFrom and timeUnti are set
                systemTimeValidFrom  = new SystemTime(grant.ValidFrom);
                systemTimeValidUntil = new SystemTime(grant.ValidUntil);
            }

            int hr = SafeNativeMethods.DRMCreateRight(
                ClientSession.GetStringFromRight(grant.Right),
                systemTimeValidFrom,  // SystemTime timeFrom,
                systemTimeValidUntil, // SystemTime timeUntil,
                0,                    // countExtendedInfo,
                null,                 // string [] extendedInfoNames,
                null,                 // string [] extendedInfoValues,
                out rightHandle);

            Errors.ThrowOnErrorCode(hr);
            Debug.Assert((rightHandle != null) && (!rightHandle.IsInvalid));

            _pubHandlesList.Add(rightHandle);

            return(rightHandle);
        }
Пример #2
0
        private void AddGrant(ContentGrant grant)
        {
            Invariant.Assert(grant != null);
            Invariant.Assert(grant.User != null);

            SafeRightsManagementPubHandle right = GetRightHandle(grant);

            SafeRightsManagementPubHandle user = GetHandleFromUser(grant.User);

            int hr = SafeNativeMethods.DRMAddRightWithUser(
                _issuanceLicenseHandle,
                right,
                user);

            Errors.ThrowOnErrorCode(hr);
        }