michael@0: * Please note that custom authentication preferences, if used, need to be updated accordingly michael@0: * for the new {@link AuthScheme authentication scheme} to take effect. michael@0: *
michael@0: * michael@0: * @param name the identifier for this scheme michael@0: * @param factory the {@link AuthSchemeFactory} class to register michael@0: * michael@0: * @see #getAuthScheme michael@0: */ michael@0: public void register( michael@0: final String name, michael@0: final AuthSchemeFactory factory) { michael@0: if (name == null) { michael@0: throw new IllegalArgumentException("Name may not be null"); michael@0: } michael@0: if (factory == null) { michael@0: throw new IllegalArgumentException("Authentication scheme factory may not be null"); michael@0: } michael@0: registeredSchemes.put(name.toLowerCase(Locale.ENGLISH), factory); michael@0: } michael@0: michael@0: /** michael@0: * Unregisters the class implementing an {@link AuthScheme authentication scheme} with michael@0: * the given name. michael@0: * michael@0: * @param name the identifier of the class to unregister michael@0: */ michael@0: public void unregister(final String name) { michael@0: if (name == null) { michael@0: throw new IllegalArgumentException("Name may not be null"); michael@0: } michael@0: registeredSchemes.remove(name.toLowerCase(Locale.ENGLISH)); michael@0: } michael@0: michael@0: /** michael@0: * Gets the {@link AuthScheme authentication scheme} with the given name. michael@0: * michael@0: * @param name the {@link AuthScheme authentication scheme} identifier michael@0: * @param params the {@link HttpParams HTTP parameters} for the authentication michael@0: * scheme. michael@0: * michael@0: * @return {@link AuthScheme authentication scheme} michael@0: * michael@0: * @throws IllegalStateException if a scheme with the given name cannot be found michael@0: */ michael@0: public AuthScheme getAuthScheme(final String name, final HttpParams params) michael@0: throws IllegalStateException { michael@0: michael@0: if (name == null) { michael@0: throw new IllegalArgumentException("Name may not be null"); michael@0: } michael@0: AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase(Locale.ENGLISH)); michael@0: if (factory != null) { michael@0: return factory.newInstance(params); michael@0: } else { michael@0: throw new IllegalStateException("Unsupported authentication scheme: " + name); michael@0: } michael@0: } michael@0: michael@0: /** michael@0: * Obtains a list containing the names of all registered {@link AuthScheme authentication michael@0: * schemes} michael@0: * michael@0: * @return list of registered scheme names michael@0: */ michael@0: public List