/// <summary>
        /// Executes this request.
        /// </summary>
        /// <returns>Service response.</returns>
        internal GetEncryptionConfigurationResponse Execute()
        {
            GetEncryptionConfigurationResponse serviceResponse = (GetEncryptionConfigurationResponse)this.InternalExecute();

            serviceResponse.ThrowIfNecessary();
            return(serviceResponse);
        }
        /// <summary>
        /// Parses the response.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>Response object.</returns>
        internal override object ParseResponse(EwsServiceXmlReader reader)
        {
            GetEncryptionConfigurationResponse response = new GetEncryptionConfigurationResponse();

            response.LoadFromXml(reader, XmlElementNames.GetEncryptionConfigurationResponse);
            return(response);
        }
        internal static EncryptionConfigurationData GetEncryptionConfiguration(string domain, bool useCache, out EncryptionConfigurationTable.RequestData requestData)
        {
            EncryptionConfigurationData encryptionConfigurationData = null;

            if (useCache && EncryptionConfigurationTable.encryptionConfigurationDataCache.TryGetValue(domain, out encryptionConfigurationData))
            {
                requestData = new EncryptionConfigurationTable.RequestData();
                return(encryptionConfigurationData);
            }
            EncryptionConfigurationTable.RequestData requestDataSave = new EncryptionConfigurationTable.RequestData();
            requestData = requestDataSave;
            EncryptionConfigurationTable.ExecuteWebServicesAction(delegate
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                ExchangeService exchangeService = EncryptionConfigurationTable.CreateExchangeServiceDelegate(domain, requestDataSave);
                if (exchangeService == null)
                {
                    return;
                }
                exchangeService.Timeout = 30000;
                requestDataSave.CreateExchangeServiceTime = stopwatch.ElapsedMilliseconds;
                GetEncryptionConfigurationResponse encryptionConfiguration = exchangeService.GetEncryptionConfiguration();
                stopwatch.Stop();
                requestDataSave.GetEncryptionConfigurationTime = stopwatch.ElapsedMilliseconds - requestDataSave.CreateExchangeServiceTime;
                requestDataSave.ExchangeServiceUri             = exchangeService.Url;
                string text;
                if (exchangeService.HttpResponseHeaders.TryGetValue("request-id", out text))
                {
                    requestDataSave.EwsRequestId = text.Replace("-", string.Empty);
                }
                else
                {
                    requestDataSave.EwsRequestId = "NotFound";
                }
                encryptionConfigurationData = new EncryptionConfigurationData(encryptionConfiguration.ImageBase64, encryptionConfiguration.EmailText, encryptionConfiguration.PortalText, encryptionConfiguration.DisclaimerText, encryptionConfiguration.OTPEnabled);
            });
            if (useCache && encryptionConfigurationData != null)
            {
                EncryptionConfigurationTable.encryptionConfigurationDataCache.Add(domain, encryptionConfigurationData);
            }
            return(encryptionConfigurationData);
        }
 /// <summary>
 /// Parses the response.
 /// </summary>
 /// <param name="reader">The reader.</param>
 /// <returns>Response object.</returns>
 internal override object ParseResponse(EwsServiceXmlReader reader)
 {
     GetEncryptionConfigurationResponse response = new GetEncryptionConfigurationResponse();
     response.LoadFromXml(reader, XmlElementNames.GetEncryptionConfigurationResponse);
     return response;
 }