/// <summary>
        /// Initiates a new instance of the <see cref="SpecializedAuthenticationMethodBase"/> class.
        /// </summary>
        /// <param name="authenticationMethod">The generic authentication method.</param>
        /// <param name="supportedMethodName">The method name this specialized class supports.</param>
        protected SpecializedAuthenticationMethodBase(AuthenticationMethod authenticationMethod, string supportedMethodName)
        {
            if (authenticationMethod == null)
            {
                throw new ArgumentNullException(nameof(authenticationMethod));
            }
            if (authenticationMethod.MethodName != supportedMethodName)
            {
                throw new InvalidOperationException(Resources.InvalidAuthenticationMethodSupplied);
            }

            BaseAuthenticationMethod = authenticationMethod;
            SupportedMethodName      = supportedMethodName;

            base.MethodName = supportedMethodName;
        }
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                var authenticationMethodObject = JObject.Load(reader);
                var authenticationMethod       = new AuthenticationMethod
                {
                    MethodName = authenticationMethodObject.Value <string>(NamePropertyName)
                };

                var parameterProperties = authenticationMethodObject.Properties()
                                          .Where(p => p.Name != NamePropertyName);

                foreach (var parameterProperty in parameterProperties)
                {
                    authenticationMethod.Parameters.Add(parameterProperty.Name, parameterProperty.Value.ToString());
                }

                return(authenticationMethod);
            }
Ejemplo n.º 3
0
 /// <summary>
 /// Initiates a new instance of the <see cref="FormBasedAuthenticationMethod"/> class.
 /// </summary>
 /// <param name="authenticationMethod">The generic authentication method.</param>
 public FormBasedAuthenticationMethod(AuthenticationMethod authenticationMethod)
     : base(authenticationMethod, AuthenticationMethodNameConstants.FormBased)
 {
 }