Exemplo n.º 1
0
        internal bool ValidateSessionByToken(ejsSessionToken claimsToken)
        {
            bool validationResult = false;

            if (ejsSessionPool._sessionDictionary.ContainsKey(claimsToken.Id))
            {
                if (claimsToken.SourceHostId ==
                    ejsSessionPool._sessionDictionary[claimsToken.Id].SessionToken.SourceHostId)
                {
                    if (ejsSessionPool._sessionDictionary[claimsToken.Id].SessionToken.IsAuthenticated)
                    {
                        if (ejsSessionPool._sessionDictionary[claimsToken.Id].
                            SessionToken.GetRemainingLifeTime().TotalMilliseconds > 0.0000)
                        {
                            validationResult = true;
                        }
                    }
                }
            }

            //Provide some simple logging on failure.
            if (validationResult == false)
            {
                ejsLogHelper.LogMessage("Token validation failed for Token: " +
                                        claimsToken.Id.ToString(), false);
            }

            return(validationResult);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns an array of all sessionTokens in the pool, without
        /// host Ids.
        /// </summary>
        internal ejsSessionToken[] GetSafePoolCopy()
        {
            try
            {
                List <ejsSessionToken> result = new List <ejsSessionToken>();

                foreach (KeyValuePair <Guid, ejsSessionUserData> record in
                         ejsSessionPool._sessionDictionary)
                {
                    ejsSessionToken t = new ejsSessionToken(
                        Guid.Empty, Guid.Empty, record.Value.SessionToken.UserId,
                        record.Value.SessionToken.CreationTimeStamp,
                        record.Value.SessionToken.ExpireTimeStamp,
                        record.Value.SessionToken.IsAuthenticated,
                        record.Value.SessionToken.FirstName,
                        record.Value.SessionToken.LastName);

                    result.Add(t);
                }

                return(result.ToArray());
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Adds an authenticated session with a corresponding session token Id
 /// to the session dictionary.
 /// </summary>
 internal bool AddAuthenticatedSession(ejsSessionToken Token, ejsSessionUserData UserData)
 {
     lock (this.threadLock)
     {
         try
         {
             if (ejsSessionPool._sessionDictionary.Keys.Contains(Token.Id))
             {
                 string message = "The given user Token Id already exists in the session pool.\n\n" +
                                  "Cannot add the same user Token Id twice.";
                 ejsLogHelper.LogMessage(message, false);
                 throw new ApplicationException(message);
             }
             ejsSessionPool._sessionDictionary.Add(Token.Id, UserData);
             return(true);
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Exemplo n.º 4
0
 public ejsSessionUserData(string UserName, ejsSessionToken SessionToken)
 {
     this._userName     = UserName;
     this._sessionToken = SessionToken;
 }