• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# SessionProperties类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SessionProperties的典型用法代码示例。如果您正苦于以下问题:C# SessionProperties类的具体用法?C# SessionProperties怎么用?C# SessionProperties使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SessionProperties类属于命名空间,在下文中一共展示了SessionProperties类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AuthenticatedUserGateway

        public BooleanResult AuthenticatedUserGateway(SessionProperties properties)
        {
            UserInformation userInfo = properties.GetTrackedSingle<UserInformation>();
            Dictionary<string, Dictionary<bool, string>> settings = GetSettings(userInfo);
            Dictionary<bool, string> gateway_sys = settings["gateway_sys"];

            foreach (KeyValuePair<bool, string> line in gateway_sys)
            {
                if (!Run(userInfo.SessionID, line.Value, userInfo, line.Key, true))
                    return new BooleanResult { Success = false, Message = String.Format("failed to run:{0}", line.Value) };
            }

            // return false if no other plugin succeeded
            BooleanResult ret = new BooleanResult() { Success = false };
            PluginActivityInformation pluginInfo = properties.GetTrackedSingle<PluginActivityInformation>();
            foreach (Guid uuid in pluginInfo.GetAuthenticationPlugins())
            {
                if (pluginInfo.GetAuthenticationResult(uuid).Success)
                {
                    return new BooleanResult() { Success = true };
                }
                else
                {
                    ret.Message = pluginInfo.GetAuthenticationResult(uuid).Message;
                }
            }

            return ret;
        }
开发者ID:MutonUfoAI,项目名称:pgina,代码行数:29,代码来源:PluginImpl.cs


示例2: BooleanResult

        BooleanResult IPluginAuthentication.AuthenticateUser(SessionProperties properties)
        {
            try
            {
                m_logger.DebugFormat("AuthenticateUser({0})", properties.Id.ToString());

                // Get user info
                UserInformation userInfo = properties.GetTrackedSingle<UserInformation>();

                m_logger.DebugFormat("Found username: {0}", userInfo.Username);
                if (userInfo.Username.StartsWith("p"))
                {
                    m_logger.InfoFormat("Authenticated user: {0}", userInfo.Username);
                    return new BooleanResult() { Success = true };
                }

                m_logger.ErrorFormat("Failed to authenticate user: {0}", userInfo.Username);
                return new BooleanResult() { Success = false, Message = string.Format("Your username does not start with a 'p'") };
            }
            catch (Exception e)
            {
                m_logger.ErrorFormat("AuthenticateUser exception: {0}", e);
                throw;  // Allow pGina service to catch and handle exception
            }
        }
开发者ID:hellyhe,项目名称:pgina,代码行数:25,代码来源:PluginImpl.cs


示例3: LidgrenAvailableSession

 internal LidgrenAvailableSession(SessionType sessionType, int currentGamerCount, string hostName, int openPrivateSlots, int openPublicSlots, SessionProperties sessionProperties, TimeSpan averageRoundtripTime)
 {
     _sessionType = sessionType;
     _currentGamerCount = currentGamerCount;
     _hostName = hostName;
     _openPrivateSlots = openPrivateSlots;
     _openPublicSlots = openPublicSlots;
     _sessionProperties = sessionProperties;
     _averageRoundtripTime = averageRoundtripTime;
 }
开发者ID:Indiefreaks,项目名称:igf,代码行数:10,代码来源:LidgrenAvailableSession.cs


示例4: SessionChange

 public void SessionChange(System.ServiceProcess.SessionChangeDescription changeDescription, SessionProperties properties)
 {
     // Check that we're logging on, and that we're configured to do anything
     if (properties != null && changeDescription.Reason == System.ServiceProcess.SessionChangeReason.SessionLogon)
     {
         m_logger.DebugFormat("Attempting to map drive(s) in session: id={0}", changeDescription.SessionId);
         List<DriveMap> maps = Settings.GetMaps();
         foreach( DriveMap map in maps )
         {
             MapDrive(changeDescription.SessionId, map, properties);
         }
     }
 }
开发者ID:hellyhe,项目名称:pgina,代码行数:13,代码来源:PluginMain.cs


示例5: ConvertFromLiveSessionProperties

        /// <summary>
        /// Converts a NetworkSessionProperties instance to the SessionProperties
        /// </summary>
        internal static SessionProperties ConvertFromLiveSessionProperties(NetworkSessionProperties networkSessionProperties)
        {
            if (networkSessionProperties == null)
                return null;

            var sessionProperties = new SessionProperties();

            for (int i = 0; i < networkSessionProperties.Count; i++)
            {
                sessionProperties[i] = networkSessionProperties[i];
            }

            return sessionProperties;
        }
开发者ID:rc183,项目名称:igf,代码行数:17,代码来源:LiveSessionProperties.cs


示例6: ConvertToLiveSessionProperties

        /// <summary>
        /// Converts a SessionProperties instance to the NetworkSessionProperties
        /// </summary>
        internal static NetworkSessionProperties ConvertToLiveSessionProperties(SessionProperties sessionProperties)
        {
            if (sessionProperties == null)
                return null;

            var networkSessionProperties = new NetworkSessionProperties();
            
            for (int i = 0; i < sessionProperties.Count; i++)
            {
                networkSessionProperties[i] = sessionProperties[i];
            }

            return networkSessionProperties;
        }
开发者ID:rc183,项目名称:igf,代码行数:17,代码来源:LiveSessionProperties.cs


示例7: DebugSession

        /// <summary>
        /// Creates a new DebugSession object.
        /// </summary>
        /// <param name="debuggerName">The name of the session debugger.</param>
        /// <param name="loadedExtensions">The names of the loaded extensions.</param>
        /// <param name="architecture">The executing machine architecture.</param>
        /// <param name="initialProperties">Initial session properties to set.</param>
        public DebugSession(string debuggerName, string[] loadedExtensions, Architecture architecture,
            SessionProperties initialProperties)
            : this()
        {
            if (initialProperties == null)
                throw new ArgumentNullException("initialProperties");
            if (architecture == null)
                throw new ArgumentNullException("architecture");

            this.debuggerName   = debuggerName;
            this.extensionNames = loadedExtensions ?? new string[0];
            this.architecture   = architecture;
            this.properties     = new SessionProperties(initialProperties);
        }
开发者ID:jsren,项目名称:DebugOS,代码行数:21,代码来源:DebugSession.cs


示例8: BeginChain

 public void BeginChain(SessionProperties properties)
 {
     m_logger.Debug("BeginChain");
     try
     {
         SessionLogger m_sessionlogger = new SessionLogger();
         properties.AddTrackedSingle<SessionLogger>(m_sessionlogger);
     }
     catch (Exception e)
     {
         m_logger.ErrorFormat("Failed to create SessionLogger: {0}", e);
         properties.AddTrackedSingle<SessionLogger>(null);
     }
 }
开发者ID:Lo5t,项目名称:pGina.Plugin.MonogDBLogger,代码行数:14,代码来源:PluginImpl.cs


示例9: DidPluginAuth

 private bool DidPluginAuth(string uuid, SessionProperties properties)
 {
     try
     {
         Guid pluginUuid = new Guid(uuid);
         PluginActivityInformation pluginInfo = properties.GetTrackedSingle<PluginActivityInformation>();
         return pluginInfo.GetAuthenticationResult(pluginUuid).Success;
     }
     catch (Exception e)
     {
         m_logger.ErrorFormat("Unable to validate that {0} authenticated user: {1}", uuid, e);
         return false;
     }
 }
开发者ID:hellyhe,项目名称:pgina,代码行数:14,代码来源:PluginImpl.cs


示例10: ConfigurationDialog

        public ConfigurationDialog()
        {
            this.InitializeComponent();

            this.pages = new Dictionary<int, ConfigCategoryItem>();

            // Create a temporary copy of the SessionProperties to allow
            // rolling back the changes.
            if (Application.Session != null)
            {
                this.tempProperties = new SessionProperties(
                    Application.Session.Properties);
            }
            else this.tempProperties = new SessionProperties();

            // Set the data context as the temporary session properties
            this.DataContext = this.tempProperties;
        }
开发者ID:jsren,项目名称:DebugOS,代码行数:18,代码来源:ConfigurationDialog.xaml.cs


示例11: PluginDriver

        public PluginDriver()
        {
            m_logger = LogManager.GetLogger(string.Format("PluginDriver:{0}", m_sessionId));

            m_properties = new SessionProperties(m_sessionId);

            // Add the user information object we'll be using for this session
            UserInformation userInfo = new UserInformation();
            m_properties.AddTrackedSingle<UserInformation>(userInfo);

            // Add the plugin tracking object we'll be using for this session
            PluginActivityInformation pluginInfo = new PluginActivityInformation();
            pluginInfo.LoadedAuthenticationGatewayPlugins = PluginLoader.GetOrderedPluginsOfType<IPluginAuthenticationGateway>();
            pluginInfo.LoadedAuthenticationPlugins = PluginLoader.GetOrderedPluginsOfType<IPluginAuthentication>();
            pluginInfo.LoadedAuthorizationPlugins = PluginLoader.GetOrderedPluginsOfType<IPluginAuthorization>();
            m_properties.AddTrackedSingle<PluginActivityInformation>(pluginInfo);

            m_logger.DebugFormat("New PluginDriver created");
        }
开发者ID:MutonUfoAI,项目名称:pgina,代码行数:19,代码来源:PluginDriver.cs


示例12: AuthorizeUser

        public BooleanResult AuthorizeUser(SessionProperties properties)
        {
            UserInformation userInfo = properties.GetTrackedSingle<UserInformation>();

            if (!ReferenceEquals(null, Settings.ApplicationID) && !ReferenceEquals(null, Settings.Secret))
            {
                string applicationID = Util.GetSettingsString((string)Settings.ApplicationID);
                string secret = Util.GetSettingsString((string)Settings.Secret);
                string accountID = Util.GetSettingsString((string)Settings.AccountID);

                //m_logger.InfoFormat("ApplicationID: {0}", applicationID);
                //m_logger.InfoFormat("Secret: {0}", secret);
                //m_logger.InfoFormat("AccountID: {0}", accountID);

                Latch latch = new Latch(applicationID, secret);
                LatchResponse response = latch.Status(accountID);

                // One of the ugliest lines of codes I ever wrote, but quickest way to access the object without using json serialization
                try
                {
                    Dictionary<string, object> operations = ((Dictionary<string, object>)response.Data["operations"]);
                    Dictionary<string, object> appSettings = ((Dictionary<string, object>)operations[(applicationID)]);
                    string status = ((string)appSettings["status"]);

                    m_logger.InfoFormat("Latch status is {0}", status);

                    if (status == "on")
                        return new BooleanResult() { Success = true, Message = "Ready to go!" };
                    else
                        return new BooleanResult() { Success = false, Message = "Latch is protecting this account!" };
                }
                catch (Exception)
                {
                    return new BooleanResult() { Success = true, Message = "Something went wrong, letting you in because I don't want to lock you out!" };
                }
            }
            else
            {
                return new BooleanResult() { Success = false, Message = "Latch is not correctly configured." };
            }
        }
开发者ID:plaguna,项目名称:latch-plugin-pGina,代码行数:41,代码来源:Main.cs


示例13: DynamicSessionProperties

        internal DynamicSessionProperties(Expression exp, SessionProperties sessionProps)
            : base(exp, BindingRestrictions.Empty, sessionProps)
        {
            this.sessionProps = sessionProps;

            // Get the property info for the indexer:
            foreach (PropertyInfo prop in typeof(SessionProperties).GetProperties())
            {
                var indexParams = prop.GetIndexParameters();
                if (indexParams.Length == 1 && indexParams[0].ParameterType == typeof(String))
                {
                    this.indexer = prop;
                    break;
                }
            }
            if (this.indexer == null) // Throw if we can't find the indexer
            {
                throw new MissingFieldException("Cannot create dynamic session properties: " +
                    "the required indexer SessionProperties[System.String^] is missing.");
            }
        }
开发者ID:jsren,项目名称:DebugOS,代码行数:21,代码来源:DynamicSessionProperties.cs


示例14: LidgrenSession

        /// <summary>
        /// This constructor is used to create a temporary session exclusivly for the purpose of listening for Discovery messages
        /// </summary>
        internal LidgrenSession(SessionType sessionType, int maxGamers, int privateReservedSlots, SessionProperties sessionProperties)
        {
            _isHost = false;
            _sessionType = sessionType;
            _sessionProperties = sessionProperties;

            if (maxGamers > MaximumSupportedGamersInSession)
                throw new CoreException("Cannot create sessions for more than " + MaximumSupportedGamersInSession + " players.");
            else
                _maxGamers = maxGamers;

            _privateReservedSlots = privateReservedSlots;

            LidgrenSessionManager.Client.Start();
            //LidgrenSessionManager.Client.Connect(serverHost, LidgrenSessionManager.ServerPort);
            _previousSecondBytesSent += LidgrenSessionManager.Client.Statistics.SentBytes;
            _previousSecondBytesReceived += LidgrenSessionManager.Client.Statistics.ReceivedBytes;

            _clientSessionState = SessionState.Lobby;
            _serverSessionState = SessionState.Lobby;
        }
开发者ID:Indiefreaks,项目名称:igf,代码行数:24,代码来源:LidgrenSession.cs


示例15: SessionChange

        public void SessionChange(System.ServiceProcess.SessionChangeDescription changeDescription, SessionProperties properties)
        {
            m_logger.DebugFormat("SessionChange({0}) - ID: {1}", changeDescription.Reason.ToString(), changeDescription.SessionId);

            //If SessionMode is enabled, send event to it.
            if ((bool)Settings.Store.SessionMode)
            {
                ILoggerMode mode = LoggerModeFactory.getLoggerMode(LoggerMode.SESSION);
                mode.Log(changeDescription, properties);
            }

            //If EventMode is enabled, send event to it.
            if ((bool)Settings.Store.EventMode)
            {
                ILoggerMode mode = LoggerModeFactory.getLoggerMode(LoggerMode.EVENT);
                mode.Log(changeDescription, properties);
            }

            //Close the connection if it's still open
            LoggerModeFactory.closeConnection();
        }
开发者ID:Lo5t,项目名称:pGina.Plugin.MonogDBLogger,代码行数:21,代码来源:PluginImpl.cs


示例16: Main

        static void Main(string[] args)
        {
            SessionProperties properties = new SessionProperties(new Guid("12345678-1234-1234-1234-123412341234"));
            UserInformation userInfo = new UserInformation();
            userInfo.Username = "gandalf";
            userInfo.Email = "[email protected]";
            userInfo.Fullname = "Gandalf The Gray";
            userInfo.LoginScript = "net use x: \\lserver\bakasracky";
            userInfo.Password = "secret";
            properties.AddTrackedSingle<UserInformation>(userInfo);

            PluginImpl plugin = new PluginImpl();

            var authResult = plugin.AuthenticateUser(properties);
            Debug.Assert(authResult.Success == true, "auth should succeed!");

            var gatewayResult = plugin.AuthenticatedUserGateway(properties);
            Debug.Assert(authResult.Success == true, "gateway should succeed!");

            System.Console.Write("DONE");
        }
开发者ID:MutonUfoAI,项目名称:pgina,代码行数:21,代码来源:Program.cs


示例17: AuthenticatedUserGateway

        public BooleanResult AuthenticatedUserGateway(SessionProperties properties)
        {
            // this method shall perform some other tasks ...

            UserInformation userInfo = properties.GetTrackedSingle<UserInformation>();

            UInfo uinfo = HttpAccessor.getUserInfo(userInfo.Username);
            if (uinfo != null)
            {
                m_logger.DebugFormat("AuthenticatedUserGateway: Uinfo: {0}", uinfo.ToString());
                foreach (string group in uinfo.groups)
                {
                    userInfo.AddGroup(new GroupInformation() { Name = group });
                }
                properties.AddTrackedSingle<UserInformation>(userInfo);

                // and what else ??? :)

            }

            return new BooleanResult() { Success = true };
        }
开发者ID:MutonUfoAI,项目名称:pgina,代码行数:22,代码来源:PluginImpl.cs


示例18: InitTest

        public void InitTest()
        {
            // Default test settings, reset for each test

            Settings.Store.LdapHost = host;
            Settings.Store.LdapPort = port;
            Settings.Store.LdapTimeout = 10;
            Settings.Store.EncryptionMethod = (int)encMethod;
            Settings.Store.RequireCert = validateCert;
            Settings.Store.SearchDN = searchDN;
            Settings.Store.SetEncryptedSetting("SearchPW", searchPW);
            Settings.Store.GroupDnPattern = "cn=%g,ou=Group,dc=example,dc=com";
            Settings.Store.GroupMemberAttrib = "memberUid";
            Settings.Store.UseAuthBindForAuthzAndGateway = false;

            // Authentication
            Settings.Store.AllowEmptyPasswords = false;
            Settings.Store.DnPattern = "uid=%u,ou=People,dc=example,dc=com";
            Settings.Store.DoSearch = false;
            Settings.Store.SearchFilter = "";
            Settings.Store.SearchContexts = new string[] { };

            // Authorization
            Settings.Store.GroupAuthzRules = new string[] { (new GroupAuthzRule(true)).ToRegString() };
            Settings.Store.AuthzRequireAuth = false;
            Settings.Store.AuthzAllowOnError = true;

            // Gateway
            Settings.Store.GroupGatewayRules = new string[] { };

            // Set up session props
            m_props = new SessionProperties(BogusSessionId);
            UserInformation userInfo = new UserInformation();
            m_props.AddTrackedSingle<UserInformation>(userInfo);
            userInfo.Username = "kirkj";
            userInfo.Password = "secret";
            PluginActivityInformation actInfo = new PluginActivityInformation();
            m_props.AddTrackedSingle<PluginActivityInformation>(actInfo);
        }
开发者ID:hellyhe,项目名称:pgina,代码行数:39,代码来源:LdapTests.cs


示例19: AuthorizeUser

        public BooleanResult AuthorizeUser(SessionProperties properties)
        {
            m_logger.Debug("MySql Plugin Authorization");

            bool requireAuth = Settings.Store.AuthzRequireMySqlAuth;

            // If we require authentication, and we failed to auth this user, then we
            // fail authorization.
            if (requireAuth)
            {
                PluginActivityInformation actInfo = properties.GetTrackedSingle<PluginActivityInformation>();
                try
                {
                    BooleanResult mySqlResult = actInfo.GetAuthenticationResult(this.Uuid);
                    if (!mySqlResult.Success)
                    {
                        m_logger.InfoFormat("Deny because MySQL auth failed, and configured to require MySQL auth.");
                        return new BooleanResult()
                        {
                            Success = false,
                            Message = "Deny because MySQL authentication failed."
                        };
                    }
                }
                catch (KeyNotFoundException)
                {
                    // The plugin is not enabled for authentication
                    m_logger.ErrorFormat("MySQL is not enabled for authentication, and authz is configured to require auth.");
                    return new BooleanResult
                    {
                        Success = false,
                        Message = "Deny because MySQL auth did not execute, and configured to require MySQL auth."
                    };
                }
            }

            // Get the authz rules from registry
            List<GroupAuthzRule> rules = GroupRuleLoader.GetAuthzRules();
            if (rules.Count == 0)
            {
                throw new Exception("No authorization rules found.");
            }

            try
            {
                UserInformation userInfo = properties.GetTrackedSingle<UserInformation>();
                string user = userInfo.Username;

                using (MySqlUserDataSource dataSource = new MySqlUserDataSource())
                {
                    foreach (GroupAuthzRule rule in rules)
                    {
                        m_logger.DebugFormat("Checking rule: {0}", rule.ToString());
                        bool inGroup = false;

                        if (rule.RuleCondition != GroupRule.Condition.ALWAYS)
                        {
                            inGroup = dataSource.IsMemberOfGroup(user, rule.Group);
                            m_logger.DebugFormat("User '{0}' {1} a member of '{2}'", user,
                                inGroup ? "is" : "is not", rule.Group);
                        }

                        if (rule.RuleMatch(inGroup))
                        {
                            if (rule.AllowOnMatch)
                                return new BooleanResult
                                {
                                    Success = true,
                                    Message = string.Format("Allow via rule '{0}'", rule.ToString() )
                                };
                            else
                                return new BooleanResult
                                {
                                    Success = false,
                                    Message = string.Format("Deny via rule '{0}'", rule.ToString())
                                };
                        }
                    }
                }

                // If we get this far, no rules matched.  This should never happen since
                // the last rule should always match (the default).  Throw.
                throw new Exception("Missing default authorization rule.");
            }
            catch (Exception e)
            {
                m_logger.ErrorFormat("Exception during authorization: {0}", e);
                throw;
            }
        }
开发者ID:MutonUfoAI,项目名称:pgina,代码行数:90,代码来源:PluginImpl.cs


示例20: LiveAvailableSession

 /// <summary>
 /// Creates a new instance
 /// </summary>
 /// <param name="availableSession">The Xbox Live AvailableNetworkSession instance</param>
 internal LiveAvailableSession(AvailableNetworkSession availableSession)
 {
     AvailableNetworkSession = availableSession;
     _sessionProperties =
         LiveSessionProperties.ConvertFromLiveSessionProperties(availableSession.SessionProperties);
 }
开发者ID:Indiefreaks,项目名称:igf,代码行数:10,代码来源:LiveAvailableSession.cs



注:本文中的SessionProperties类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SessionScopeWrapper类代码示例发布时间:2022-05-24
下一篇:
C# SessionNoServer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap