public async Task <CredentialValue> Value() { var encrypted = await Load(key); var serialized = new DecryptedValue(dataProtector, encrypted).Value(); CredentialValueRecord deserialized; if (string.IsNullOrWhiteSpace(serialized)) { deserialized = new CredentialValueRecord(); } else { deserialized = JsonSerializer.Deserialize <CredentialValueRecord>(serialized) ?? new CredentialValueRecord(); } return(new CredentialValue(deserialized.UserName, deserialized.Password)); }
public void Load() { var cookieText = httpContextAccessor.HttpContext?.Request.Cookies[cookieName]; if (string.IsNullOrWhiteSpace(cookieText)) { SessionKey = ""; SessionExpirationTime = DateTimeOffset.MinValue; RequesterKey = ""; } else { var unprotectedText = new DecryptedValue(protector, cookieText).Value(); var info = XtiSerializer.Deserialize <AnonInfo>(unprotectedText); SessionKey = info.SessionKey; SessionExpirationTime = info.SessionExpirationTime; RequesterKey = info.RequesterKey; } }