Esempio n. 1
0
        protected override void InternalValidate()
        {
            TaskLogger.LogEnter();
            base.InternalValidate();
            if (base.HasErrors)
            {
                TaskLogger.LogExit();
                return;
            }
            bool flag = false;

            if (base.Fields.IsModified("IntranetCertificationUrl") && !RMUtil.IsWellFormedRmServiceUrl(this.IntranetCertificationUrl))
            {
                base.WriteError(new RmsUrlIsInvalidException(this.IntranetCertificationUrl), (ErrorCategory)1000, this.IntranetCertificationUrl);
            }
            if (base.Fields.IsModified("ExtranetCertificationUrl") && !RMUtil.IsWellFormedRmServiceUrl(this.ExtranetCertificationUrl))
            {
                base.WriteError(new RmsUrlIsInvalidException(this.ExtranetCertificationUrl), (ErrorCategory)1000, this.ExtranetCertificationUrl);
            }
            Uri intranetLicensingUrl;

            if (base.Fields.IsModified("IntranetLicensingUrl"))
            {
                if (!RMUtil.IsWellFormedRmServiceUrl(this.IntranetLicensingUrl))
                {
                    base.WriteError(new RmsUrlIsInvalidException(this.IntranetLicensingUrl), (ErrorCategory)1000, this.IntranetLicensingUrl);
                }
                intranetLicensingUrl = this.IntranetLicensingUrl;
                flag = true;
            }
            else
            {
                intranetLicensingUrl = this.DataObject.IntranetLicensingUrl;
            }
            Uri extranetLicensingUrl;

            if (base.Fields.IsModified("ExtranetLicensingUrl"))
            {
                if (!RMUtil.IsWellFormedRmServiceUrl(this.ExtranetLicensingUrl))
                {
                    base.WriteError(new RmsUrlIsInvalidException(this.ExtranetLicensingUrl), (ErrorCategory)1000, this.ExtranetLicensingUrl);
                }
                extranetLicensingUrl = this.ExtranetLicensingUrl;
                flag = true;
            }
            else
            {
                extranetLicensingUrl = this.DataObject.ExtranetLicensingUrl;
            }
            if (flag)
            {
                foreach (string encodedTemplate in this.DataObject.RMSTemplates)
                {
                    RmsTemplateType rmsTemplateType;
                    string          templateXrml = RMUtil.DecompressTemplate(encodedTemplate, out rmsTemplateType);
                    this.ValidateTemplate(templateXrml, intranetLicensingUrl, extranetLicensingUrl);
                }
            }
            TaskLogger.LogExit();
        }
Esempio n. 2
0
 public static void ThrowIfIsNotWellFormedRmServiceUrl(Uri url, out object failureTarget)
 {
     failureTarget = null;
     if (null != url && !RMUtil.IsWellFormedRmServiceUrl(url))
     {
         failureTarget = url;
         throw new RmsUrlIsInvalidException(url);
     }
 }
Esempio n. 3
0
        private static bool ValidateResponsesAndUpdateServerInfo(AcquireServerInfoAsyncResult result, out LocalizedString errStr)
        {
            errStr = LocalizedString.Empty;
            if (result.ServiceLocationResponses == null)
            {
                errStr = ServerStrings.InvalidServiceLocationResponse;
                RmsServerInfoManager.Tracer.TraceError(0L, "ServiceLocation responses is null");
                return(false);
            }
            if (result.ServiceLocationResponses.Length != 4)
            {
                errStr = ServerStrings.IncorrectEntriesInServiceLocationResponse(result.ServiceLocationResponses.Length, 4);
                RmsServerInfoManager.Tracer.TraceError <int>(0L, "Number of entries in the response is {0}. Expected 4", result.ServiceLocationResponses.Length);
                return(false);
            }
            ServiceLocationResponse[] serviceLocationResponses = result.ServiceLocationResponses;
            int i = 0;

            while (i < serviceLocationResponses.Length)
            {
                ServiceLocationResponse serviceLocationResponse = serviceLocationResponses[i];
                Uri  uri;
                bool result2;
                if (!RMUtil.TryCreateUri(serviceLocationResponse.URL, out uri))
                {
                    errStr = ServerStrings.InvalidRmsUrl(serviceLocationResponse.Type, serviceLocationResponse.URL);
                    RmsServerInfoManager.Tracer.TraceError <string>(0L, "Invalid response from the service location. {0} is an invalid URI", serviceLocationResponse.URL);
                    result2 = false;
                }
                else
                {
                    if (RMUtil.IsWellFormedRmServiceUrl(uri))
                    {
                        switch (serviceLocationResponse.Type)
                        {
                        case ServiceType.ServerLicensingWSService:
                            if (uri.Scheme != Uri.UriSchemeHttps)
                            {
                                errStr = ServerStrings.InvalidUrlScheme(serviceLocationResponse.Type, uri);
                                RmsServerInfoManager.Tracer.TraceError <Uri>(0L, "The Uri scheme for the server licensing WS service {0} is not https", uri);
                                return(false);
                            }
                            result.ServerInfo.ServerLicensingWSPipeline = uri;
                            break;

                        case ServiceType.CertificationWSService:
                            if (uri.Scheme != Uri.UriSchemeHttps)
                            {
                                errStr = ServerStrings.InvalidUrlScheme(serviceLocationResponse.Type, uri);
                                RmsServerInfoManager.Tracer.TraceError <Uri>(0L, "The Uri scheme for the certification WS service {0} is not https", uri);
                                return(false);
                            }
                            result.ServerInfo.CertificationWSPipeline = uri;
                            break;

                        case ServiceType.ServerLicensingMexService:
                            result.ServerLicensingMExUri = RmsServerInfoManager.ConvertToWsdlUrl(serviceLocationResponse.URL);
                            break;

                        case ServiceType.CertificationMexService:
                            result.CertificationMExUri = RmsServerInfoManager.ConvertToWsdlUrl(serviceLocationResponse.URL);
                            break;
                        }
                        i++;
                        continue;
                    }
                    errStr = ServerStrings.InvalidRmsUrl(serviceLocationResponse.Type, serviceLocationResponse.URL);
                    RmsServerInfoManager.Tracer.TraceError <string>(0L, "Invalid response from the service location. {0} is an invalid RMS URI", serviceLocationResponse.URL);
                    result2 = false;
                }
                return(result2);
            }
            if (result.ServerInfo.CertificationWSPipeline == null || result.ServerInfo.ServerLicensingWSPipeline == null || result.CertificationMExUri == null || result.ServerLicensingMExUri == null)
            {
                errStr = ServerStrings.InvalidServiceLocationResponse;
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
 public static bool AreRmsOnlinePreRequisitesMet(IRMConfiguration irmConfiguration)
 {
     RmsUtil.ThrowIfParameterNull(irmConfiguration, "irmConfiguration");
     return(RMUtil.IsWellFormedRmServiceUrl(irmConfiguration.RMSOnlineKeySharingLocation));
 }