Exemple #1
0
        /// <summary>
        /// Retrieves the Client Session Data for the given session ID
        /// </summary>
        /// <param name="sessionId">The Id of the session to retrieve the data for</param>
        /// <returns>The Client Session Data</returns>
        public Model.ClientSessionData GetSessionData(string sessionId)
        {
            if (this.SessionDetails.ContainsKey(sessionId))
            {
                return(this.sessionDetails[sessionId]);
            }
            else if (this.securedData.ContainsKey(sessionId.Substring(0, ClientSessionStore.SessionIdSubstringLength)))
            {
                List <SecuredClientsessionData> d = this.securedData[sessionId.Substring(0, ClientSessionStore.SessionIdSubstringLength)];
                foreach (SecuredClientsessionData scsd in d)
                {
                    try
                    {
                        // SecuredClientsessionData scsd = this.securedData[sessionId.Substring(0, ClientSessionStore.SessionIdSubstringLength)];
                        string data = scsd.SecuredData;
                        UserSessionConfiguration config = this.Deserialize <UserSessionConfiguration>(MachineKeyEncryption.Decrypt(data, sessionId));
                        ClientSessionData        csd    = new ClientSessionData()
                        {
                            LastTimeUpdated = scsd.LastUpdated, UserSessionConfiguration = config
                        };

                        this.SessionDetails.AddOrUpdate(sessionId, csd, (k, v) => { return(csd); });
                        d.Remove(scsd);
                        return(this.sessionDetails[sessionId]);
                    }
                    catch (Exception)
                    {
                        // Obviously it wasn't this one
                    }
                }
            }

            return(null);
        }
Exemple #2
0
        /// <summary>
        /// Sets the client session to be a session with the given User Session Configuration
        /// </summary>
        /// <param name="config">The user session configuration for the current client session</param>
        public static void SetClientSession(UserSessionConfiguration config)
        {
            if (config == null || string.IsNullOrWhiteSpace(config.SessionId))
            {
                return;
            }

            ClientSessionData data = new ClientSessionData()
            {
                LastTimeUpdated = DateTime.Now, UserSessionConfiguration = config
            };

            WcfUserClientSession.SessionStore.StoreSession(config.SessionId, data);
            WcfUserClientSession.Current = new WcfUserClientSession(config);
        }
Exemple #3
0
        /// <summary>
        /// Gets the currents security string and passes it to the client
        /// </summary>
        /// <param name="reply">The reply message</param>
        /// <param name="correlationState">The correclation state of the message</param>
        public void BeforeSendReply(ref Message reply, object correlationState)
        {
            /*
             * string userDisplayName = string.Empty;
             * IEnumerable<string> roleNames = null;
             * if (WcfUserSessionSecurity.Current.User != null)
             * {
             *  userDisplayName = WcfUserSessionSecurity.Current.User.DisplayName;
             *  if (string.IsNullOrWhiteSpace(userDisplayName)) userDisplayName = WcfUserSessionSecurity.Current.User.UserName;
             *  roleNames = WcfUserSessionSecurity.Current.User.RoleNames;
             * }
             */

            UserSessionConfiguration config = WcfUserSessionSecurity.Current.GetSessionConfig();
            var typedHeader   = new MessageHeader <UserSessionConfiguration>(config);
            var untypedHeader = typedHeader.GetUntypedHeader(WcfUserSessionBehaviour.HeaderName, WcfUserSessionBehaviour.HeaderNamespace);

            reply.Headers.Add(untypedHeader);
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WcfUserClientSession"/> class
 /// </summary>
 /// <param name="config">The configuration to set</param>
 public WcfUserClientSession(UserSessionConfiguration config)
 {
     this.config = config;
 }