/// <summary> /// Registers a /// <see cref="AuthSchemeFactory">AuthSchemeFactory</see> /// with the given identifier. If a factory with the /// given name already exists it will be overridden. This name is the same one used to /// retrieve the /// <see cref="AuthScheme">authentication scheme</see> /// from /// <see cref="GetAuthScheme(string, Apache.Http.Params.HttpParams)">GetAuthScheme(string, Apache.Http.Params.HttpParams) /// </see> /// . /// <p> /// Please note that custom authentication preferences, if used, need to be updated accordingly /// for the new /// <see cref="AuthScheme">authentication scheme</see> /// to take effect. /// </p> /// </summary> /// <param name="name">the identifier for this scheme</param> /// <param name="factory"> /// the /// <see cref="AuthSchemeFactory">AuthSchemeFactory</see> /// class to register /// </param> /// <seealso cref="GetAuthScheme(string, Apache.Http.Params.HttpParams)">GetAuthScheme(string, Apache.Http.Params.HttpParams) /// </seealso> public void Register(string name, AuthSchemeFactory factory) { Args.NotNull(name, "Name"); Args.NotNull(factory, "Authentication scheme factory"); registeredSchemes.Put(name.ToLower(Sharpen.Extensions.GetEnglishCulture()), factory ); }
/// <summary> /// Gets the /// <see cref="AuthScheme">authentication scheme</see> /// with the given name. /// </summary> /// <param name="name"> /// the /// <see cref="AuthScheme">authentication scheme</see> /// identifier /// </param> /// <param name="params"> /// the /// <see cref="Apache.Http.Params.HttpParams">HTTP parameters</see> /// for the authentication /// scheme. /// </param> /// <returns> /// /// <see cref="AuthScheme">authentication scheme</see> /// </returns> /// <exception cref="System.InvalidOperationException">if a scheme with the given name cannot be found /// </exception> public AuthScheme GetAuthScheme(string name, HttpParams @params) { Args.NotNull(name, "Name"); AuthSchemeFactory factory = registeredSchemes.Get(name.ToLower(Sharpen.Extensions.GetEnglishCulture() )); if (factory != null) { return(factory.NewInstance(@params)); } else { throw new InvalidOperationException("Unsupported authentication scheme: " + name); } }