Example #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);
        }
Example #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);
        }
        public ConfigurationInformationProvider(IPerTenantRMSTrustedPublishingDomainConfiguration perTenantconfig)
        {
            this.serverLicensorCertificate             = new ConfigurationInformationProvider.ServerLicensorCertInformation(ConfigurationInformationProvider.GetTrustedDomainChainArrayFromCompressedString(perTenantconfig.CompressedSLCCertChain));
            this.serverLicensorCertificate.IsValidated = true;
            List <string[]> list = new List <string[]>(perTenantconfig.CompressedTrustedDomainChains.Count);

            foreach (string compressedCertChainString in perTenantconfig.CompressedTrustedDomainChains)
            {
                list.Add(ConfigurationInformationProvider.GetTrustedDomainChainArrayFromCompressedString(compressedCertChainString));
            }
            this.trustedUserDomains             = new ConfigurationInformationProvider.TrustedDomainInformation(list);
            this.trustedUserDomains.IsValidated = true;
            this.trustedPublishingDomains       = this.trustedUserDomains;
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            foreach (string compressedTemplateString in perTenantconfig.CompressedRMSTemplates)
            {
                string templateFromCompressedString = ConfigurationInformationProvider.GetTemplateFromCompressedString(compressedTemplateString);
                Guid   templateGuidFromLicense;
                try
                {
                    templateGuidFromLicense = DrmClientUtils.GetTemplateGuidFromLicense(templateFromCompressedString);
                }
                catch (RightsManagementException ex)
                {
                    throw new ConfigurationProviderException(true, "ConfigurationInformationProvider failed to parse template data for tenant ", ex);
                }
                dictionary.Add(templateGuidFromLicense.ToString("B"), templateFromCompressedString);
            }
            this.rightsTemplateInformation                 = new ConfigurationInformationProvider.RightsTemplateInformation(dictionary);
            this.licensingIntranetDistributionPointUrl     = perTenantconfig.IntranetLicensingUrl;
            this.licensingExtranetDistributionPointUrl     = perTenantconfig.ExtranetLicensingUrl;
            this.certificationIntranetDistributionPointUrl = perTenantconfig.IntranetCertificationUrl;
            this.certificationExtranetDistributionPointUrl = perTenantconfig.ExtranetCertificationUrl;
        }
 public ContextProvider(IPerTenantRMSTrustedPublishingDomainConfiguration perTenantconfig)
 {
     if (perTenantconfig == null)
     {
         throw new ArgumentNullException("perTenantconfig");
     }
     this.configProvider              = new ConfigurationInformationProvider(perTenantconfig);
     this.privateKeyProvider          = new TrustedPublishingDomainPrivateKeyProvider(null, perTenantconfig.PrivateKeys);
     this.globalConfigurationProvider = new GlobalConfigurationCacheProvider();
     this.directoryServiceProvider    = new DirectoryServiceProvider();
 }