Ejemplo n.º 1
0
        public BooleanResult AuthorizeUser(SessionProperties properties)
        {
            UserInformation userInfo = properties.GetTrackedSingle <UserInformation>();
            Dictionary <string, List <notify> > settings = GetSettings(userInfo);
            List <notify> autho_sys = new List <notify>();

            try { autho_sys = settings["autho_sys"]; }
            catch { }


            foreach (notify line in autho_sys)
            {
                if (!Run(userInfo.SessionID, line.script, userInfo, line.pwd, true, GetAuthenticationPluginResults(properties), GetAuthorizationResults(properties), ""))
                {
                    return new BooleanResult {
                               Success = false, Message = String.Format("failed to run:{0}", line.script)
                    }
                }
                ;
            }

            // return false if no other plugin succeeded
            BooleanResult ret = new BooleanResult()
            {
                Success = false, Message = this.Name + " plugin can't authorize a user on its own"
            };
            PluginActivityInformation pluginInfo = properties.GetTrackedSingle <PluginActivityInformation>();

            foreach (Guid uuid in pluginInfo.GetAuthorizationPlugins())
            {
                if (pluginInfo.GetAuthorizationResult(uuid).Success)
                {
                    return(new BooleanResult()
                    {
                        Success = true
                    });
                }
                else
                {
                    ret.Message = pluginInfo.GetAuthorizationResult(uuid).Message;
                }
            }

            return(ret);
        }
Ejemplo n.º 2
0
        internal string GetAuthorizationResults(SessionProperties properties)
        {
            string autho = "";

            try
            {
                PluginActivityInformation pluginInfo = properties.GetTrackedSingle <PluginActivityInformation>();
                foreach (Guid uuid in pluginInfo.GetAuthorizationPlugins())
                {
                    if (pluginInfo.GetAuthorizationResult(uuid).Success)
                    {
                        autho += "{" + uuid + "}";
                    }
                }
            }
            catch (Exception ex)
            {
                m_logger.ErrorFormat("GetAuthorizationResults Exception:", ex);
            }

            return(autho);
        }