/// <summary> /// Create a signature for parameters /// </summary> private void SignParameters() { if (this.apiValuesConfiguration.CheckSignature) { this.ParametersSignature = SignatureManager.GetInstance(this.credentialsConfiguration.PrivateKey).Sign(this.Parameters); } }
/// <summary> /// Validate the current answer : control the signature if present and parse the Yubico code answer /// </summary> public void Validate() { if (this.Parameters.ContainsKey(this.responseConfiguration.Signature)) { string concat = String.Empty; foreach (string key in this.Parameters.Keys) { if (key != this.responseConfiguration.Signature) { concat += String.Format("{0}={1}&", key, this.Parameters[key]); } } this.IsSignatureValid = SignatureManager.GetInstance(this.credentialsConfiguration.PrivateKey).CheckSignature( concat.Substring(0, concat.Length - 1), this.Parameters[this.responseConfiguration.Signature]); } if (this.Parameters.ContainsKey(this.responseConfiguration.Status)) { this.Status = this.ParseStatus(this.Parameters[this.responseConfiguration.Status]); } }