private string ValidateDigitalSignatureCredentials(DigitalSignatureCredentialsExt credentials) { if (string.IsNullOrEmpty(credentials.Username)) { _messageBuilder.AppendLine("Username cannot be empty."); } else { if (ContainsIllegalCharacters(credentials.Username)) { _messageBuilder.AppendLine("Username contains illegal characters."); } if (credentials.Username.Length > UsernameMaxLength) { _messageBuilder.AppendLine($"Username is too long, maximal length is {UsernameMaxLength}"); } } if (string.IsNullOrEmpty(credentials.Noise)) { _messageBuilder.AppendLine("Noise cannot be empty."); } else if (ContainsIllegalCharacters(credentials.Noise)) { _messageBuilder.AppendLine("Noise contains illegal characters."); } if (credentials.DigitalSignature == null) { _messageBuilder.AppendLine("DigitalSignature cannot be empty."); } return(_messageBuilder.ToString()); }
public override ValidationResult Validate() { string message = _validationObject switch { PasswordCredentialsExt ext => ValidateUserPasswordCredentials(ext), OpenIdCredentialsExt ext => ValidateOpenIdCredentials(ext), DigitalSignatureCredentialsExt ext => ValidateDigitalSignatureCredentials(ext), AsymmetricKeyCredentialsExt ext => ValidateAsymmetricKeyCredentials(ext), _ => string.Empty }; return(new ValidationResult(string.IsNullOrEmpty(message), message)); }