public void Bootstrap(AuthorizationConfiguration 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(AuthorizationManager));
                        Log(meth, LogLevel.Info, "Called");
                    }

                    if (config != null)
                    {
                        TypeNameReference typ = config.PermissionFactoryTypeName;
                        if (typ != null)
                        {
                            this.permissionFactory = NameReflectionUtils.CreateInstance <PermissionProviderFactory>(typ);
                            if (this.permissionFactory != null)
                            {
                                typ = config.RoleFactoryTypeName;
                                if (typ != null)
                                {
                                    this.roleFactory = NameReflectionUtils.CreateInstance <RoleProviderFactory>(typ);
                                    if (this.roleFactory != null)
                                    {
                                        this.roleFactory.LocalContext       = new UserSecurityContext(new LocalSystemUser(user.Uid, user.Name, user.UserState));
                                        this.permissionFactory.LocalContext = new UserSecurityContext(new LocalSystemUser(user.Uid, user.Name, user.UserState));
                                        Log(meth, LogLevel.Info, "Succeeded");
                                        this.State = RunState.Bootstrapped;
                                        return;
                                    }
                                    else
                                    {
                                        Log(meth, LogLevel.Error, "Failed to create role factory instance");
                                    }
                                }
                                else
                                {
                                    Log(meth, LogLevel.Error, "Failed to extract role typename");
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to create permission factory instance");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to extract permission typename");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "No config provided");
                    }
                    this.State = RunState.FailedBootstrapping;
                }
            }
        }
        public void Bootstrap()
        {
            lock (instance)
            {
                if (RuntimeUtils.Bootstrappable(this.State))
                {
                    string meth = "Bootstrap";
                    this.State  = RunState.Bootstrapping;
                    this.logger = LogManager.Instance.GetProvider(typeof(AuthorizationManager));
                    Log(meth, LogLevel.Info, "Called");

                    ConfigurationProviderBase config = ConfigurationManager.Instance.GetProvider();
                    if (config != null)
                    {
                        ConfigurationParameter param = config.Get(typeof(AuthorizationManager), "roleProvider");
                        if (param != null)
                        {
                            string tName = param.Value as string;
                            if (!string.IsNullOrEmpty(tName))
                            {
                                TypeNameReference typeName = TypeNameReference.Parse(tName);
                                if (typeName != null)
                                {
                                    AuthorizationConfiguration iConfig = new AuthorizationConfiguration();
                                    iConfig.RoleFactoryTypeName = typeName;

                                    param = config.Get(typeof(AuthorizationManager), "permissionProvider");
                                    if (param != null)
                                    {
                                        tName = param.Value as string;
                                        if (!string.IsNullOrEmpty(tName))
                                        {
                                            typeName = TypeNameReference.Parse(tName);
                                            if (typeName != null)
                                            {
                                                iConfig.PermissionFactoryTypeName = typeName;
                                                Bootstrap(iConfig);
                                                return;
                                            }
                                            else
                                            {
                                                Log(meth, LogLevel.Error, "Failed to parse permission provider param value");
                                            }
                                        }
                                        else
                                        {
                                            Log(meth, LogLevel.Error, "Failed to get permission provider param value");
                                        }
                                    }
                                    else
                                    {
                                        Log(meth, LogLevel.Error, "Failed to get permission provider param");
                                    }
                                }
                                else
                                {
                                    Log(meth, LogLevel.Error, "Failed to parse role provider param value");
                                }
                            }
                            else
                            {
                                Log(meth, LogLevel.Error, "Failed to get role provider param value");
                            }
                        }
                        else
                        {
                            Log(meth, LogLevel.Error, "Failed to get role provider param");
                        }
                    }
                    else
                    {
                        Log(meth, LogLevel.Error, "Failed to get ConfigurationProvider");
                    }


                    this.State = RunState.FailedBootstrapping;
                }
            }
        }