private static FormsModel ReadData(JsonReader reader) { bool isPersistent; DateTimeOffset expireUtc; var principal = new ClaimsPrincipal(); reader .StartObject() .Property("p", out isPersistent, true) .Property("e", out expireUtc, DateTimeOffset.MinValue) .StartArray("i"); while (reader.TokenType != JsonToken.EndArray) { string authenticationType; string nameClaimType; string roleClaimType; var claims = new List<Claim>(); reader .StartObject() .Property("at", out authenticationType, null) .Property("nct", out nameClaimType, ClaimsIdentity.DefaultNameClaimType) .Property("rct", out roleClaimType, ClaimsIdentity.DefaultRoleClaimType) .StartArray("c"); while (reader.TokenType != JsonToken.EndArray) { string claimType; string claimValue; reader .StartObject() .Property("t", out claimType, nameClaimType) .Property("v", out claimValue, null) .EndObject(); claims.Add(new Claim(claimType, claimValue)); } reader .EndArray() .EndObject(); principal.AddIdentity(new ClaimsIdentity( claims, authenticationType, nameClaimType, roleClaimType)); } reader .EndArray() .EndObject(final: true); return new FormsModel { IsPersistent = isPersistent, ExpireUtc = expireUtc, Principal = principal }; }