/// <summary> /// Implements <see cref="SASLMechanism.ChallengeAsync"/> by calling <see cref="Challenge(ref SASLChallengeArguments, TCredentials)"/>. /// If <see cref="SASLChallengeArguments.Credentials"/> is not of type <typeparamref name="TCredentials"/>, or if <see cref="Challenge(ref SASLChallengeArguments, TCredentials)"/> throws, then the exception is catched and error code returned by <see cref="GetExceptionErrorCode(Exception)"/> is returned. /// </summary> /// <param name="args">The <see cref="SASLChallengeArguments"/>.</param> /// <returns>The result of <see cref="Challenge(ref SASLChallengeArguments, TCredentials)"/>, or error code returned by <see cref="GetExceptionErrorCode(Exception)"/>.</returns> public TAsyncSyncChallengeResult ChallengeAsync( SASLChallengeArguments args ) { try { return(new TAsyncSyncChallengeResult(this.Challenge(ref args, (TCredentials)args.Credentials))); } catch (Exception exc) { return(new TAsyncSyncChallengeResult(this.GetExceptionErrorCode(exc))); } }
/// <summary> /// The derived classes should implement this method for their SASL challenge logic. /// </summary> /// <param name="args">The <see cref="SASLChallengeArguments"/>.</param> /// <param name="credentials">The credentials.</param> /// <returns>Result indicating how the challenge went, either tuple of how many bytes were written along with <see cref="SASLChallengeResult"/>, or a integer with error code.</returns> protected abstract TAsyncSyncChallengeResult ChallengeAsync( SASLChallengeArguments args, TCredentials credentials );
/// <summary> /// Implements <see cref="AbstractAsyncSASLMechanism{TCredentials}.ChallengeAsync(SASLChallengeArguments, TCredentials)"/> by delegating implementation to <see cref="ChallengeAsync(SASLChallengeArguments, SASLCredentialsHolder, TCredentials)"/>. /// </summary> /// <param name="args">The <see cref="SASLChallengeArguments"/>.</param> /// <param name="credentials">The <see cref="SASLCredentialsHolder"/>.</param> /// <returns>Result of <see cref="ChallengeAsync(SASLChallengeArguments, SASLCredentialsHolder, TCredentials)"/>.</returns> protected sealed override TAsyncSyncChallengeResult ChallengeAsync( SASLChallengeArguments args, SASLCredentialsHolder credentials ) => this.ChallengeAsync(args, credentials, (TCredentials)(credentials ?? throw new InvalidOperationException("No credential holder supplied")).Credentials);
/// <summary> /// The derived classes should implement this method for their SASL challenge logic. /// </summary> /// <param name="args">The <see cref="SASLChallengeArguments"/>.</param> /// <param name="credentials">The credentials.</param> /// <returns>Result indicating how the challenge went, either tuple of how many bytes were written along with <see cref="SASLChallengeResult"/>, or a integer with error code.</returns> protected abstract TSyncChallengeResult Challenge( ref SASLChallengeArguments args, TCredentials credentials );