Пример #1
0
        public static string GenerateAndSealRACKey(IPerTenantRMSTrustedPublishingDomainConfiguration config)
        {
            ArgumentValidator.ThrowIfNull("config", config);
            ContextProvider contextProvider = null;
            string          result;

            try
            {
                contextProvider = new ContextProvider(config);
                IRightsAccountCertificateGenerator rightsAccountCertificateGenerator = GeneratorFactory.CreateRightsAccountCertificateGenerator(contextProvider);
                result = rightsAccountCertificateGenerator.GenerateSealedKey();
            }
            catch (ConfigurationProviderException innerException)
            {
                throw new RightsManagementServerException(ServerStrings.FailedToCreateLicenseGenerator(string.Empty, "Rac"), innerException);
            }
            catch (CertificationException innerException2)
            {
                throw new RightsManagementServerException(ServerStrings.FailedToCreateLicenseGenerator(string.Empty, "Rac"), innerException2);
            }
            finally
            {
                if (contextProvider != null)
                {
                    contextProvider.Dispose();
                }
            }
            return(result);
        }
Пример #2
0
        public static string ResealRACKey(IPerTenantRMSTrustedPublishingDomainConfiguration config, string originalSharedKey)
        {
            ArgumentValidator.ThrowIfNull("config", config);
            ArgumentValidator.ThrowIfNullOrEmpty("config.CompressedSLCCertChain", config.CompressedSLCCertChain);
            ArgumentValidator.ThrowIfNullOrEmpty("originalSharedKey", originalSharedKey);
            ContextProvider contextProvider = null;
            string          result;

            try
            {
                contextProvider = new ContextProvider(config);
                IRightsAccountCertificateGenerator rightsAccountCertificateGenerator = GeneratorFactory.CreateRightsAccountCertificateGenerator(contextProvider);
                result = rightsAccountCertificateGenerator.ResealKey(originalSharedKey, RMUtil.DecompressSLCCertificate(config.CompressedSLCCertChain));
            }
            catch (ConfigurationProviderException innerException)
            {
                throw new RightsManagementServerException(ServerStrings.FailedToResealKey, innerException);
            }
            catch (CertificationException innerException2)
            {
                throw new RightsManagementServerException(ServerStrings.FailedToResealKey, innerException2);
            }
            catch (RightsManagementException innerException3)
            {
                throw new RightsManagementServerException(ServerStrings.FailedToResealKey, innerException3, true);
            }
            finally
            {
                if (contextProvider != null)
                {
                    contextProvider.Dispose();
                }
            }
            return(result);
        }