Revision 47845 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/DownloaderHTTPBasicAuthenticationConfig.java
DownloaderHTTPBasicAuthenticationConfig.java | ||
---|---|---|
5 | 5 |
*/ |
6 | 6 |
package org.gvsig.downloader.lib.impl.types.httpbasic; |
7 | 7 |
|
8 |
import org.apache.commons.lang3.StringUtils; |
|
8 | 9 |
import org.gvsig.downloader.DownloaderAuthenticationConfig; |
9 | 10 |
import org.gvsig.downloader.DownloaderAuthenticationRequester; |
10 |
import org.gvsig.downloader.DownloaderCredentials; |
|
11 |
import org.gvsig.downloader.DownloaderManager; |
|
12 | 11 |
import static org.gvsig.downloader.lib.impl.types.httpbasic.DownloaderHTTPBasicAuthenticationFactory.HTTPBASIC_AUTHENTICATION_NAME; |
13 | 12 |
import org.gvsig.downloader.spi.AbstractDownloaderAuthenticationConfig; |
14 | 13 |
import org.gvsig.json.JsonObjectBuilder; |
... | ... | |
45 | 44 |
} |
46 | 45 |
|
47 | 46 |
@Override |
48 |
public DownloaderCredentials getCredentials(DownloaderCredentials credentials) { |
|
49 |
if(!(credentials instanceof DownloaderHTTPBasicCredentials)){ |
|
50 |
return null; |
|
51 |
} |
|
52 |
DownloaderHTTPBasicCredentials theCredentials = (DownloaderHTTPBasicCredentials)credentials; |
|
53 |
if (DownloaderManager.urlStartsWith(this.getServiceUrl(), theCredentials.getServiceUrl())) { |
|
54 |
return new DownloaderHTTPBasicCredentials( |
|
55 |
this.getServiceUrl(), |
|
56 |
theCredentials.getUserid(), |
|
57 |
theCredentials.getPassword() |
|
58 |
); |
|
59 |
} |
|
60 |
return null; |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 | 47 |
public JsonObjectBuilder toJsonBuilder() { |
65 | 48 |
JsonObjectBuilder builder = super.toJsonBuilder(); |
66 | 49 |
builder.add_class(this); |
67 | 50 |
return builder; |
68 | 51 |
} |
69 | 52 |
|
53 |
@Override |
|
54 |
public DownloaderAuthenticationConfig createAuthenticationConfig(String serviceUrl) { |
|
55 |
if (StringUtils.isBlank(serviceUrl)) { |
|
56 |
return null; |
|
57 |
} |
|
58 |
|
|
59 |
DownloaderAuthenticationConfig other = new DownloaderHTTPBasicAuthenticationConfig(null, serviceUrl); |
|
60 |
return other; |
|
61 |
} |
|
70 | 62 |
|
71 | 63 |
} |
Also available in: Unified diff