/// <summary>
        /// Updates the phe clients by provided update token.
        /// </summary>
        /// <param name="updateToken">Update token.</param>
        public void UpdatePheClients(string updateToken)
        {
            Validation.NotNullOrWhiteSpace(updateToken);

            var versionedUpdateToken = StringUpdateTokenParser.Parse(updateToken);

            if (versionedUpdateToken.Version != this.CurrentVersion + 1)
            {
                throw new WrongVersionException("Incorrect token version.");
            }

            var pheClient = this.PheClients[this.CurrentVersion];

            this.VersionedUpdateToken = versionedUpdateToken;

            var(newSecretKey, newPublicKey) = pheClient.RotateKeys(
                this.VersionedUpdateToken.UpdateToken.ToByteArray());

            this.PheClients.Add(this.VersionedUpdateToken.Version, new PheClient(newSecretKey, newPublicKey));
            this.CurrentVersion = this.VersionedUpdateToken.Version;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Virgil.PureKit.RecordUpdater"/> class.
 /// </summary>
 /// <param name="token">Update token to be used for updating user's record.
 /// How to generate Update Token you will find
 /// <see href="https://github.com/passw0rd/cli#get-an-update-token">here</see>.</param>
 public RecordUpdater(string token)
 {
     Validation.NotNullOrWhiteSpace(token, "UpdateToken isn't provided.");
     this.VersionedUpdateToken = StringUpdateTokenParser.Parse(token);
     this.pheClient            = new PheClient();
 }