/// <summary>
        /// Initializes the authentication manager.
        /// Reads the configiration and instantiates enabled authentication providers.
        /// </summary>
        /// <param name="kernel">NInject kernel.</param>
        public void Initialize(IKernel kernel)
        {
            var providers = _configuration.Authentication.Providers.Cast<AuthenticationProviderConfigurationElement>().ToArray();
            foreach (var provider in providers.Where(p => p.Enabled))
            {
                var providerType = Type.GetType(provider.Type, false);
                if (providerType == null)
                {
                    throw new Exception(string.Format("Could not load type: '{0}'!" +
                        " Please put the all referenced assemblies into the DeviceHive executable folder.", provider.Type));
                }
                if (!typeof(AuthenticationProvider).IsAssignableFrom(providerType))
                {
                    throw new Exception(string.Format("The type '{0}' must implement AuthenticationProvider" +
                        " in order to be registered as authentication provider!", providerType));
                }

                var providerConfiguration = new AuthenticationProviderConfiguration(provider.ClientId, provider.ClientSecret, provider.Argument);
                var providerInstance = (AuthenticationProvider)kernel.Get(providerType, new ConstructorArgument("providerConfiguration", providerConfiguration));
                var providerInfo = new AuthenticationProviderInfo(provider.Name, providerInstance, providerConfiguration);
                _providers.Add(provider.Name, providerInfo);
            }
        }
        /// <summary>
        /// Initializes the authentication manager.
        /// Reads the configiration and instantiates enabled authentication providers.
        /// </summary>
        /// <param name="kernel">NInject kernel.</param>
        public void Initialize(IKernel kernel)
        {
            var providers = _configuration.Authentication.Providers.Cast <AuthenticationProviderConfigurationElement>().ToArray();

            foreach (var provider in providers.Where(p => p.Enabled))
            {
                var providerType = Type.GetType(provider.Type, false);
                if (providerType == null)
                {
                    throw new Exception(string.Format("Could not load type: '{0}'!" +
                                                      " Please put the all referenced assemblies into the DeviceHive executable folder.", provider.Type));
                }
                if (!typeof(AuthenticationProvider).IsAssignableFrom(providerType))
                {
                    throw new Exception(string.Format("The type '{0}' must implement AuthenticationProvider" +
                                                      " in order to be registered as authentication provider!", providerType));
                }

                var providerConfiguration = new AuthenticationProviderConfiguration(provider.ClientId, provider.ClientSecret, provider.Argument);
                var providerInstance      = (AuthenticationProvider)kernel.Get(providerType, new ConstructorArgument("providerConfiguration", providerConfiguration));
                var providerInfo          = new AuthenticationProviderInfo(provider.Name, providerInstance, providerConfiguration);
                _providers.Add(provider.Name, providerInfo);
            }
        }