Example #1
0
 public BigBoxTextFixture()
 {
     Authentication  = new KeyAuthentication(Environment.GetEnvironmentVariable("BigBox-Key"));
     MainApiUsername = Environment.GetEnvironmentVariable("MainApi-Username");
     MainApiPassword = Environment.GetEnvironmentVariable("MainApi-Password");
     MainApiSenderId = Environment.GetEnvironmentVariable("MainApi-SenderId");
 }
        private Authentication GetAuthenticationScheme()
        {
            Authentication result = null;

            if (IsGuest(Identifier))
            {
                result = new GuestAuthentication();
            }

            if (Password != null)
            {
                result = new PlainAuthentication()
                {
                    Password = Password
                };
            }

            if (AccessKey != null)
            {
                result = new KeyAuthentication {
                    Key = AccessKey
                };
            }

            if (result == null)
            {
                throw new InvalidOperationException(
                          $"A password or accessKey should be defined. Please use the '{nameof(UsingPassword)}' or '{nameof(UsingAccessKey)}' methods for that.");
            }

            return(result);
        }
        /// <summary>
        /// Sets the authentication key to be used in the session establishment.
        /// </summary>
        /// <param name="key">The authentication key.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        public IEstablishedClientChannelBuilder WithKeyAuthentication(string key)
        {
            Guard.Argument(key, nameof(key)).NotNull();

            var authentication = new KeyAuthentication();

            authentication.SetToBase64Key(key);
            return(WithAuthentication(authentication));
        }
        /// <summary>
        /// Sets the authentication key to be used in the session establishment.
        /// </summary>
        /// <param name="key">The authentication key.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        public EstablishedClientChannelBuilder WithKeyAuthentication(string key)
        {
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }
            var authentication = new KeyAuthentication();

            authentication.SetToBase64Key(key);
            return(WithAuthentication(authentication));
        }