FileDocCategorySizeDatePackage
AuthSchemeRegistry.javaAPI DocAndroid 1.5 API5507Wed May 06 22:41:10 BST 2009org.apache.http.auth

AuthSchemeRegistry

public final class AuthSchemeRegistry extends Object
Authentication scheme registry that can be used to obtain the corresponding authentication scheme implementation for a given type of authorization challenge.
author
Oleg Kalnichevski
version
$Revision: 652950 $
since
4.0

Fields Summary
private final Map
registeredSchemes
Constructors Summary
public AuthSchemeRegistry()

        super();
        this.registeredSchemes = new LinkedHashMap<String,AuthSchemeFactory>();
    
Methods Summary
public synchronized org.apache.http.auth.AuthSchemegetAuthScheme(java.lang.String name, org.apache.http.params.HttpParams params)
Gets the {@link AuthScheme authentication scheme} with the given name.

param
name the {@link AuthScheme authentication scheme} identifier
param
params the {@link HttpParams HTTP parameters} for the authentication scheme.
return
{@link AuthScheme authentication scheme}
throws
IllegalStateException if a scheme with the given name cannot be found


        if (name == null) {
            throw new IllegalArgumentException("Name may not be null");
        }
        AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase(Locale.ENGLISH));
        if (factory != null) {
            return factory.newInstance(params);
        } else {
            throw new IllegalStateException("Unsupported authentication scheme: " + name);
        }
    
public synchronized java.util.ListgetSchemeNames()
Obtains a list containing names of all registered {@link AuthScheme authentication schemes} in their default order.

return
list of registered scheme names

        return new ArrayList<String>(registeredSchemes.keySet()); 
    
public synchronized voidregister(java.lang.String name, org.apache.http.auth.AuthSchemeFactory factory)
Registers a {@link AuthSchemeFactory} 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 {@link AuthScheme authentication scheme} from {@link #getAuthScheme}.

Please note that custom authentication preferences, if used, need to be updated accordingly for the new {@link AuthScheme authentication scheme} to take effect.

param
name the identifier for this scheme
param
factory the {@link AuthSchemeFactory} class to register
see
#getAuthScheme

         if (name == null) {
             throw new IllegalArgumentException("Name may not be null");
         }
        if (factory == null) {
            throw new IllegalArgumentException("Authentication scheme factory may not be null");
        }
        registeredSchemes.put(name.toLowerCase(Locale.ENGLISH), factory);
    
public synchronized voidsetItems(java.util.Map map)
Populates the internal collection of registered {@link AuthScheme authentication schemes} with the content of the map passed as a parameter.

param
map authentication schemes

        if (map == null) {
            return;
        }
        registeredSchemes.clear();
        registeredSchemes.putAll(map);
    
public synchronized voidunregister(java.lang.String name)
Unregisters the class implementing an {@link AuthScheme authentication scheme} with the given name.

param
name the identifier of the class to unregister

         if (name == null) {
             throw new IllegalArgumentException("Name may not be null");
         }
        registeredSchemes.remove(name.toLowerCase(Locale.ENGLISH));