public ServiceInterfacePrincipal(TokenObject tokenObject, string host, Uri urlReferrer, IIdentity identity, string callGuid, string bearerToken) : base(identity, null) { this.TokenObject = tokenObject; this.Host = host; this.UrlReferrer = urlReferrer; this.Cono = tokenObject.Cono; this.CallGuid = callGuid; this.BearerToken = bearerToken; }
public static bool TokenToObject(string token, string encryptKey, string encryptIv, out TokenObject tokenObject) { tokenObject = new TokenObject(); try { if (string.IsNullOrEmpty(token)) { return(false); } token = StringProtector.Unprotect(token, encryptKey, encryptIv); tokenObject = JsonConvert.DeserializeObject <TokenObject>(token); return(true); } catch (Exception) { return(false); } }
public static string ObjectToToken(TokenObject tokenObject, string encryptKey, string encryptIv) { var token = JsonConvert.SerializeObject(tokenObject); return(StringProtector.Protect(token, encryptKey, encryptIv)); }