Exemplo n.º 1
0
        public void Bootstrap()
        {
            lock (instance)
            {
                if (RuntimeUtils.Bootstrappable(this.State))
                {
                    string meth = "Bootstrap";
                    this.State  = RunState.Bootstrapping;
                    this.logger = LogManager.Instance.GetProvider(typeof(IdentityManager));
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(typeof(IdentityManager), "provider");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                TypeNameReference typeName = TypeNameReference.Parse(tName);
                                if (typeName != null)
                                {
                                    IdentityConfiguration iConfig = new IdentityConfiguration();
                                    iConfig.FactoryTypeName = typeName;
                                    Bootstrap(iConfig);
                                    return;
                                }
                                else
                                {
                                    Log(meth, LogLevel.Error, "Failed to parse provider param value");
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get provider param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get provider param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }


                    this.State = RunState.FailedBootstrapping;
                }
            }
        }
Exemplo n.º 2
0
        public void Bootstrap(IdentityConfiguration config)
        {
            lock (instance)
            {
                if (RuntimeUtils.Bootstrappable(this.State) || this.State == RunState.Bootstrapping)
                {
                    this.State = RunState.Bootstrapping;
                    string meth = "Bootstrap";
                    if (this.logger == null) //in case we're directly bootstrapping
                    {
                        this.logger = LogManager.Instance.GetProvider(typeof(IdentityManager));
                        Log(meth, LogLevel.Info, "Called");
                    }

                    if (config != null)
                    {
                        TypeNameReference typ = config.FactoryTypeName;
                        if (typ != null)
                        {
                            this.factory = NameReflectionUtils.CreateInstance <IdentityProviderFactory>(typ);
                            if (this.factory != null)
                            {
                                Log(meth, LogLevel.Info, "Succeeded");
                                this.State = RunState.Bootstrapped;
                                return;
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to create factory instance");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to extract typename");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "No config provided");
                    }
                    this.State = RunState.FailedBootstrapping;
                }
            }
        }