Esempio n. 1
0
 public LoginTokenID(int uid, string pwd, UniqueObjectID oldUniqueObjectID)
 {
     _uniqueObjectID = oldUniqueObjectID;
     _timestamp      = UniqueObjectID.GetTimestampFromDateTime(DateTime.UtcNow);
     _machine        = _uniqueObjectID.Machine;
     _pid            = _uniqueObjectID.Pid;
     _increment      = _uniqueObjectID.Increment;
     _uid            = uid;
     _pwd            = pwd;
 }
Esempio n. 2
0
 public LoginTokenID(long uid, string pwd = "niciaiwomima")
 {
     _uniqueObjectID = UniqueObjectID.GenerateNewId();
     _timestamp      = UniqueObjectID.GetTimestampFromDateTime(DateTime.UtcNow);
     _machine        = _uniqueObjectID.Machine;
     _pid            = _uniqueObjectID.Pid;
     _increment      = _uniqueObjectID.Increment;
     _uid            = uid;
     _pwd            = pwd;
 }
Esempio n. 3
0
        /// <summary>
        /// Tries to parse a string and create a new ObjectId.
        /// </summary>
        /// <param name="s">The string value.</param>
        /// <param name="objectId">The new ObjectId.</param>
        /// <returns>True if the string was parsed successfully.</returns>
        public static bool TryParse(string s, out UniqueObjectID objectId)
        {
            // don't throw ArgumentNullException if s is null
            if (s != null && s.Length == 24)
            {
                byte[] bytes;
                if (BsonUtils.TryParseHexString(s, out bytes))
                {
                    objectId = new UniqueObjectID(bytes);
                    return(true);
                }
            }

            objectId = default(UniqueObjectID);
            return(false);
        }
Esempio n. 4
0
        public LoginTokenID(string value)
        {
            //int test = UniqueObjectID.GetTimestampFromDateTime(DateTime.UtcNow);
            //DateTime saddas = BsonConstants.UnixEpoch.AddSeconds(test);
            if (value == null)
            {
                return;
            }

            try
            {
                value = EncryptionFunc.Decrypt(value, token_ekey);
            }
            catch (Exception)
            {
                return;
            }
            string[] _stemp = value.Split(new string[] { "\f" }, StringSplitOptions.RemoveEmptyEntries);
            try
            {
                if (_stemp.Length == 4)
                {
                    _uid            = int.Parse(_stemp[0]);
                    _pwd            = _stemp[1];
                    _uniqueObjectID = new UniqueObjectID(_stemp[2]);
                    _timestamp      = Convert.ToInt32(_stemp[3]);
                }
                else if (_stemp.Length == 3)
                {
                    _uid            = int.Parse(_stemp[0]);
                    _pwd            = _stemp[1];
                    _uniqueObjectID = new UniqueObjectID(_stemp[2]);
                    _timestamp      = UniqueObjectID.GetTimestampFromDateTime(DateTime.UtcNow);
                }
            }
            catch (Exception)
            {
                return;
            }
            if (_uniqueObjectID == null)
            {
                return;
            }
            _machine   = _uniqueObjectID.Machine;
            _pid       = _uniqueObjectID.Pid;
            _increment = _uniqueObjectID.Increment;
        }