Token Expiration Date. How?

Giganews Newsgroups
Subject: Token Expiration Date. How?
Posted by:  Shapper (mdmou…@gmail.com)
Date: Thu, 30 Aug 2012

Hello,

I created a class and a few extensions to create a token:

    public String Issue(String data) {
      Sash sash = new Sash(new SHA256Managed(), 64);
      Byte[] hash = sash.CalculateHash(Encoding.UTF8.GetBytes(data), Encoding.UTF8.GetBytes(SaltProvider.GetSalt());
      sash.Dispose();
      return Convert.ToBase64String(hash);
    } // Issue

    public Boolean Check(String data, String token) {
      Sash sash = new Sash(new SHA256Managed(), 256);
      Boolean valid = sash.CheckHash(Encoding.UTF8.GetBytes(data), Encoding.UTF8.GetBytes(SaltProvider.GetSalt()), Encoding.UTF8.GetBytes(token));
      sash.Dispose();
      return valid;
    } // Check

I am building data variable according to the use of the token. Can be for example:

String data = String.Concat(user.Username, user.Created)

But how can I define a Token Issue and Expiration date?

I am not sure how to include this in data and later user as ...

I am not sure how this is usually done.

Could someone, please, help me out?

Thank You,

Miguel

Replies