Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.downloader / org.gvsig.downloader.lib / org.gvsig.downloader.lib.impl / src / main / java / org / gvsig / downloader / lib / impl / types / httpbasic / DownloaderHTTPBasicAuthenticationFactory.java @ 47841

History | View | Annotate | Download (1.66 KB)

1
package org.gvsig.downloader.lib.impl.types.httpbasic;
2

    
3
import org.gvsig.compat.CompatLocator;
4
import org.gvsig.downloader.DownloaderAuthenticationFactory;
5
import org.gvsig.downloader.DownloaderManager;
6
import org.gvsig.downloader.spi.AbstractDownloaderAuthenticationFactory;
7
import org.gvsig.json.Json;
8
import static org.gvsig.tools.util.CachedValue.LOGGER;
9

    
10

    
11
/**
12
 *
13
 * @author jjdelcerro
14
 */
15
@SuppressWarnings("UseSpecificCatch")
16
public class DownloaderHTTPBasicAuthenticationFactory 
17
        extends
18
            AbstractDownloaderAuthenticationFactory
19
        implements 
20
            DownloaderAuthenticationFactory 
21
    {
22
    public static final String HTTPBASIC_AUTHENTICATION_NAME = "HTTP Basic";
23

    
24
    public DownloaderHTTPBasicAuthenticationFactory() {
25
        super(HTTPBASIC_AUTHENTICATION_NAME);
26
    }
27
    
28
    @Override
29
    public DownloaderHTTPBasicAuthenticationConfig create(Object... parameters) {
30
        return new DownloaderHTTPBasicAuthenticationConfig(this, (String)parameters[0]);
31
    }
32

    
33
    @Override
34
    public String toString() {
35
        return this.getProviderName();
36
    }
37
    
38
    public static void selfRegister() {
39
        try {
40
            DownloaderManager downloader = (DownloaderManager) CompatLocator.getDownloader();
41
            downloader.registerAuthenticationType(new DownloaderHTTPBasicAuthenticationFactory());
42
            Json.registerSerializer(DownloaderHTTPBasicAuthenticationConfig.class);
43
        } catch(Throwable t) {
44
            LOGGER.warn("Can't register http-basic downloader authentication factory ",t);
45
        }
46
    }
47

    
48
    @Override
49
    public String getDescription() {
50
        return "Authentication using HTTP Basic Authorization";
51
    }
52
    
53
}