public static bool TryParse(string tokenText, out RequestToken token) { token = null; if (string.IsNullOrEmpty(tokenText)) { return(false); } string textToDecypt = HttpUtility.UrlDecode(tokenText); string[] vector = null; if (!SsoCipher.TryParseVector(textToDecypt, out vector)) { return(false); } if (vector.Length != 3) { return(false); } string returnUrl = vector[0]; DateTime timeStamp = Convert.ToDateTime(vector[1]); string seed = vector[2]; token = new RequestToken(returnUrl, timeStamp, seed); return(true); }
public static bool TryParse(string tokenText, out ResponseToken token) { token = null; if (string.IsNullOrEmpty(tokenText)) { return(false); } string textToDecypt = HttpUtility.UrlDecode(tokenText); string[] vector = null; if (!SsoCipher.TryParseVector(textToDecypt, out vector)) { return(false); } if (vector.Length != 5) { return(false); } string userId = vector[0]; DateTime timeStamp = Convert.ToDateTime(vector[1]); int expire = Convert.ToInt32(vector[2]); string seed = vector[3]; int resultCode = Convert.ToInt32(vector[4]); token = new ResponseToken(userId, timeStamp, expire, seed, resultCode); return(true); }
public string Encode() { return(SsoCipher.EncryptVector( _userId, _timeStamp == default(DateTime)?null:_timeStamp.ToString(), _expireDuration.ToString())); }
public string Encode() { string encodedText = SsoCipher.EncryptVector( _returnUrl, _timeStamp == default(DateTime)?null:_timeStamp.ToString(), _seed); return(HttpUtility.UrlEncode(encodedText)); }
public string Encode() { string encodedText = SsoCipher.EncryptVector (_userId, _timeStamp == default(DateTime) ? null : _timeStamp.ToString(), _expireDuration.ToString(), _seed, _resultCode.ToString()); return(HttpUtility.UrlEncode(encodedText)); }
private static string NextSeed() { Random random = new Random((int)DateTime.Now.Ticks); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 32; i++) { int idx = random.Next(0, Constants.SeedChars.Length); sb.Append(Constants.SeedChars.Substring(idx, 1)); } sb.Append(Guid.NewGuid().ToString()); return(Seed = SsoCipher.Hash(sb.ToString())); }
public static bool TryParse(string text, out SsoTicket ticket) { ticket = null; string[] vector; if (!SsoCipher.TryParseVector(text, out vector)) { return(false); } if (vector.Length != 3) { return(false); } ticket = new SsoTicket(); ticket._userId = vector[0]; ticket._timeStamp = Convert.ToDateTime(vector[1]); ticket._expireDuration = Convert.ToInt32(vector[2]); return(true); }