public static AuthorizationSettings GetAuthorizationSettings()
        {
            AuthorizationSettings authorizationSettings;

            if (null != HttpContext.Current)
            {
                authorizationSettings = HttpContext.Current.Cache[CacheKey] as AuthorizationSettings;
            }
            else
            {
                authorizationSettings = _authorizationSettings;
            }

            if (null != authorizationSettings)
            {
                return(authorizationSettings);
            }

            authorizationSettings = ConfigurationManager.GetSection(SectionName) as AuthorizationSettings;

            if (null == authorizationSettings)
            {
                throw new ConfigurationErrorsException(SectionName);
            }

            if (null != HttpContext.Current)
            {
                HttpContext.Current.Cache.Insert(CacheKey, authorizationSettings);
            }
            else
            {
                _authorizationSettings = authorizationSettings;
            }

            return(authorizationSettings);
        }
        public Configurator()
        {
            AuthorizationSettings authorizationSettings = ConfigurationAccessor.GetAuthorizationSettings();

            Mode = authorizationSettings.AuthorizationMode;

            switch (Mode)
            {
            case AuthorizationMode.Merchant:
                Id        = authorizationSettings.Merchant.WmId;
                SecretKey = authorizationSettings.Merchant.SecretKey;
                break;

            case AuthorizationMode.Classic:
                Id      = authorizationSettings.KeeperClassic.WmId;
                _signer = new Signer();
                _signer.Initialize(authorizationSettings.KeeperClassic.WmKey);
                break;

            case AuthorizationMode.Light:
                if (null != authorizationSettings.KeeperLight.LightContainer)
                {
                    X509Certificate2 certificate;
                    var store = new X509Store(authorizationSettings.KeeperLight.LightContainer.StoreName,
                                              authorizationSettings.KeeperLight.LightContainer.StoreLocation);

                    try
                    {
                        store.Open(OpenFlags.ReadOnly);

                        var collection =
                            store.Certificates.Find(X509FindType.FindByThumbprint,
                                                    authorizationSettings.KeeperLight.LightContainer.Thumbprint, false);

                        if (0 == collection.Count || !collection[0].HasPrivateKey)
                        {
                            throw new ConfigurationErrorsException("webMoneyConfiguration/applicationInterfaces/keeperLight/containerInfo/thumbprint");
                        }

                        certificate = collection[0];
                    }
                    finally
                    {
                        store.Close();
                    }

                    Certificate = certificate;
                }
                else
                {
                    var certificate = new X509Certificate2(authorizationSettings.KeeperLight.RawData,
                                                           string.Empty);

                    Certificate = certificate;
                }
                break;

            default:
                throw new InvalidOperationException("Mode=" + Mode);
            }
        }