public override bool Equals(object obj) { if (obj is AuthorizeToken) { AuthorizeToken obj1 = (AuthorizeToken)obj; if (obj1.Id == Id) { return(true); } } return(false); }
public (AuthorizeToken, byte[]) CreateToken(Guid userId) { AuthorizeToken token = new AuthorizeToken() { UserId = userId.ToString(), Id = Guid.NewGuid(), TimeStamp = DateTime.Now, }; token.Livetime = Settings.TokenTimelife(token); RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(); token.Params = rsa.ExportParameters(true); RSAPKCS1SignatureFormatter rsaFormatter = new RSAPKCS1SignatureFormatter(rsa); rsaFormatter.SetHashAlgorithm("SHA512"); byte[] hash = SHA512.Create().ComputeHash(token.Id.ToByteArray()); byte[] signature = rsaFormatter.CreateSignature(hash); return(token, token.Id.ToByteArray().Concat(signature).ToArray()); }
public void Update(AuthorizeToken item) { Remove(item); Add(item); }
public void Remove(AuthorizeToken item) { provider.Data.Remove(item); }
public void Add(AuthorizeToken item) { provider.Data.Add(item); }