private void ValidateRmsVersion(Uri uri, ServiceType serviceType) { if (serviceType == ServiceType.LicensingService) { uri = RmsoProxyUtil.GetLicenseServerRedirectUrl(uri); } if (serviceType == ServiceType.CertificationService) { uri = RmsoProxyUtil.GetCertificationServerRedirectUrl(uri); } if ((this.DataObject.IsChanged(IRMConfigurationSchema.InternalLicensingEnabled) && this.DataObject.InternalLicensingEnabled) || (this.DataObject.IsChanged(IRMConfigurationSchema.LicensingLocation) && serviceType == ServiceType.LicensingService)) { using (ServerWSManager serverWSManager = new ServerWSManager(uri, serviceType, null, null, RmsClientManagerUtils.GetLocalServerProxy(this.datacenter), RmsClientManager.AppSettings.RmsSoapQueriesTimeout)) { if (serviceType == ServiceType.CertificationService && !serverWSManager.ValidateCertificationServiceVersion()) { base.WriteError(new RmsVersionMismatchException(uri), ErrorCategory.InvalidOperation, base.Identity); } if (serviceType == ServiceType.LicensingService && !serverWSManager.ValidateLicensingServiceVersion()) { base.WriteError(new RmsVersionMismatchException(uri), ErrorCategory.InvalidOperation, base.Identity); } } } }
private bool TryGetULAndPreL() { this.result.SetTask(Strings.InfoGetLicensingUri); try { this.licensingUris = RmsClientManager.IRMConfig.GetTenantLicensingLocations(this.organizationId); if (this.licensingUris != null) { for (int i = 0; i < this.licensingUris.Count; i++) { this.licensingUris[i] = RmsoProxyUtil.GetLicenseServerRedirectUrl(this.licensingUris[i]); } } } catch (RightsManagementException ex) { this.result.SetFailureResult(Strings.ErrorFailedToGetLicensingUri, ex, this.encryptionEnabled); return(false); } catch (ExchangeConfigurationException ex2) { this.result.SetFailureResult(Strings.ErrorFailedToGetLicensingUri, ex2, this.encryptionEnabled); return(false); } if (this.licensingUris == null || this.licensingUris.Count == 0) { this.result.SetFailureResult(Strings.ErrorFailedToGetLicensingUri, null, this.encryptionEnabled); return(false); } foreach (Uri uri in this.licensingUris) { this.result.SetSuccessResult(Strings.InfoLicensingUri(uri)); } bool flag = true; foreach (Uri uri2 in this.licensingUris) { this.result.SetTask(Strings.InfoCheckRmsVersion(uri2)); try { if (this.ValidateRmsVersion(uri2, ServiceType.LicensingService)) { this.result.SetSuccessResult(Strings.InfoRmsVersionChecked); } else { this.result.SetFailureResult(Strings.ErrorFailedRmsVersionCheck, null, this.encryptionEnabled); flag = false; } } catch (RightsManagementException ex3) { this.result.SetFailureResult(Strings.ErrorFailedRmsVersionCheck, ex3, this.encryptionEnabled); flag = false; } catch (ExchangeConfigurationException ex4) { this.result.SetFailureResult(Strings.ErrorFailedRmsVersionCheckInitialization, ex4, this.encryptionEnabled); flag = false; } } if (!flag) { return(false); } XmlNode[] issuanceLicense; flag = this.TryCreatePL(out issuanceLicense); if (!flag) { return(false); } if (!this.datacenter) { foreach (string text in this.recipientsAddress) { this.result.SetTask(Strings.InfoGetPreL(text, this.publishingUri)); try { LicenseResponse[] array2 = RmsClientManager.AcquirePreLicense(this.context, this.publishingUri, issuanceLicense, new string[] { text }); int num = array2.Length; for (int k = 0; k < num; k++) { if (array2[k].Exception != null) { this.result.SetFailureResult(Strings.InfoPreLIndividual(array2[k].Exception.FailureCode), null, this.prelicensingEnabled); flag = false; } else { this.result.SetSuccessResult(Strings.InfoPreL); } } } catch (ExchangeConfigurationException ex5) { this.result.SetFailureResult(Strings.ErrorFailedToGetPreL, ex5, this.prelicensingEnabled); flag = false; } catch (RightsManagementException ex6) { this.result.SetFailureResult(Strings.ErrorFailedToGetPreL, ex6, this.prelicensingEnabled); flag = false; } } } this.result.SetTask(Strings.InfoGetUL(this.publishingUri)); try { RmsClientManager.AcquireUseLicense(this.context, this.publishingUri, issuanceLicense, null); this.result.SetSuccessResult(Strings.InfoUL); } catch (ExchangeConfigurationException ex7) { this.result.SetFailureResult(this.datacenter ? Strings.ErrorFailedToGetULTenant : Strings.ErrorFailedToGetULEnterprise, ex7, this.licensingEnabled); flag = false; } catch (RightsManagementException ex8) { if (ex8.FailureCode == RightsManagementFailureCode.ServerRightNotGranted) { this.result.SetFailureResult(Strings.ErrorFailedToGetULDueToInvalidSuperUserConfiguration, null, this.licensingEnabled); } else { this.result.SetFailureResult(this.datacenter ? Strings.ErrorFailedToGetULTenant : Strings.ErrorFailedToGetULEnterprise, ex8, this.licensingEnabled); } flag = false; } return(flag); }
private bool TryGetRacAndClc() { this.result.SetTask(Strings.InfoGetCertificationUri); try { this.certificationUri = RmsClientManager.GetRMSServiceLocation(this.organizationId, ServiceType.Certification); this.certificationUri = RmsoProxyUtil.GetCertificationServerRedirectUrl(this.certificationUri); } catch (RightsManagementException ex) { this.result.SetFailureResult(Strings.ErrorFailedToGetCertificationUri, ex, this.encryptionEnabled); return(false); } catch (ExchangeConfigurationException ex2) { this.result.SetFailureResult(Strings.ErrorFailedToGetCertificationUri, ex2, this.encryptionEnabled); return(false); } if (this.certificationUri == null) { this.result.SetFailureResult(Strings.ErrorFailedToGetCertificationUri, null, this.encryptionEnabled); return(false); } this.result.SetSuccessResult(Strings.InfoCertificationUri(this.certificationUri)); this.result.SetTask(Strings.InfoCheckRmsVersion(this.certificationUri)); try { if (this.ValidateRmsVersion(this.certificationUri, ServiceType.CertificationService)) { this.result.SetSuccessResult(Strings.InfoRmsVersionChecked); } else { this.result.SetFailureResult(Strings.ErrorFailedRmsVersionCheck, null, this.encryptionEnabled); } } catch (RightsManagementException ex3) { this.result.SetFailureResult(Strings.ErrorFailedRmsVersionCheck, ex3, this.encryptionEnabled); return(false); } catch (ExchangeConfigurationException ex4) { this.result.SetFailureResult(Strings.ErrorFailedRmsVersionCheckInitialization, ex4, this.encryptionEnabled); return(false); } this.result.SetTask(Strings.InfoGetPublishingUri); try { this.publishingUri = RmsClientManager.GetRMSServiceLocation(this.organizationId, ServiceType.Publishing); this.publishingUri = RmsoProxyUtil.GetLicenseServerRedirectUrl(this.publishingUri); } catch (RightsManagementException ex5) { this.result.SetFailureResult(Strings.ErrorFailedToGetPublishingUri, ex5, this.encryptionEnabled); return(false); } catch (ExchangeConfigurationException ex6) { this.result.SetFailureResult(Strings.ErrorFailedToGetPublishingUri, ex6, this.encryptionEnabled); return(false); } if (this.publishingUri == null) { this.result.SetFailureResult(Strings.ErrorFailedToGetPublishingUri, null, this.encryptionEnabled); return(false); } this.result.SetSuccessResult(Strings.InfoPublishingUri(this.publishingUri)); this.result.SetTask(Strings.InfoGetRacAndClc); try { this.tenantLicenses = RmsClientManager.AcquireTenantLicenses(this.context, this.publishingUri); this.result.SetSuccessResult(Strings.InfoRacAndClc); } catch (ExchangeConfigurationException ex7) { this.result.SetFailureResult(this.datacenter ? Strings.ErrorFailedToGetRacAndClcTenant : Strings.ErrorFailedToGetRacAndClcEnterprise, ex7, this.encryptionEnabled); return(false); } catch (RightsManagementException ex8) { this.result.SetFailureResult(this.datacenter ? Strings.ErrorFailedToGetRacAndClcTenant : Strings.ErrorFailedToGetRacAndClcEnterprise, ex8, this.encryptionEnabled); return(false); } return(true); }