public class HttpsFileUploaderConfig extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
CONNECT_TIMEOUT_MS
Default connect timeout on the URL connection.
|
static int |
READ_TIMEOUT_MS
Default read timeout on the URL connection.
|
| Constructor and Description |
|---|
HttpsFileUploaderConfig(URL url)
Creates a configuration object with only the URL endpoint defined.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
endpointRequiresAuthentication()
Does the endpoint require authentication?
|
String[] |
getAcceptedIssuers()
Gets list of accepted Issuer Organization names that will be
accepted for the server's certificate.
|
Map<String,String> |
getAdditionalHeaders()
Gets the additional HTTP headers used on the upload POST request.
|
int |
getConnectTimeoutMs()
Gets the connect timeout that is used on the URL connection.
|
String |
getEndpointPassword()
Gets the endpoint authentication password (authentication type: Basic).
|
String |
getEndpointUsername()
Gets the endpoint authentication username (authentication type: Basic).
|
String |
getProxyAddress()
Address of proxy if one has been defined.
|
int |
getProxyPort()
Gets the port number used by the proxy.
|
int |
getReadTimeoutMs()
Gets the read timeout that is used on the URL connection.
|
URL |
getURL()
Gets the
endpointURLString as a URL object. |
boolean |
isValidateCertificates()
Must certificates from the endpoint be validated?
|
void |
setAcceptedIssuers(String[] acceptedIssuers)
Sets the list of Issuer Organization names that will be accepted for
the server's certificate.
|
void |
setAdditionalHeaders(Map<String,String> additionalHeaders)
Sets additional overall HTTP headers to add to the upload POST request.
|
void |
setConnectTimeoutMs(int connectTimeoutMs)
Sets the connect timeout that is used on the URL connection.
|
void |
setEndpointPassword(String endpointPassword)
Sets the un-encrypted password for authentication against the endpoint.
|
void |
setEndpointUsername(String endpointUsername)
Sets the username for authentication against the endpoint.
|
void |
setProxyAddress(String proxyAddress)
Sets the address of the proxy.
|
void |
setProxyPort(int proxyPort)
Sets the port of the proxy.
|
void |
setReadTimeoutMs(int readTimeoutMs)
Gets the read timeout that is used on the URL connection.
|
void |
setValidateCertificates(boolean validateCertificates)
Should certificates from the endpoint be validated ? Default is
true. |
boolean |
usesProxy()
Does the connection go through a proxy server?
|
public static final int CONNECT_TIMEOUT_MS
public static final int READ_TIMEOUT_MS
public HttpsFileUploaderConfig(URL url)
url - Sets the URL of the endpoint. This is expected to start with
either a HTTP or a HTTPS url. The URL can optionally include a port
number.public String getEndpointUsername()
null if the setEndpointUsername(java.lang.String)
hasn't been called. A value of null indicates that the
endpoint does not require authentication.public void setEndpointUsername(String endpointUsername)
endpointUsername - username to use for authenticationpublic String getEndpointPassword()
null
if the setEndpointPassword(java.lang.String) hasn't been called.
A value of null indicates that the endpoint does not require
authentication.public void setEndpointPassword(String endpointPassword)
endpointPassword - un-encrypted passwordpublic boolean isValidateCertificates()
public void setValidateCertificates(boolean validateCertificates)
true. Set to false if the endpoint is trusted but
is using a self-signed certificate.validateCertificates - public String getProxyAddress()
null indicates no use of proxy.setProxyAddress(java.lang.String)public void setProxyAddress(String proxyAddress)
proxyAddress - either a string hostname or an IP addresss. Must
not include a port number.public int getProxyPort()
setProxyPort(int)public void setProxyPort(int proxyPort)
proxyPort - port number, a value between 1 and 65535. Typically
HTTP/HTTPS proxies use port 8080 by convention.public boolean usesProxy()
public boolean endpointRequiresAuthentication()
public URL getURL()
endpointURLString as a URL object.public int getConnectTimeoutMs()
CONNECT_TIMEOUT_MS if
not set explicitly.public void setConnectTimeoutMs(int connectTimeoutMs)
CONNECT_TIMEOUT_MS if
not set explicitly.connectTimeoutMs - connect timeout in millisecondspublic int getReadTimeoutMs()
READ_TIMEOUT_MS if
not set explicitly.public void setReadTimeoutMs(int readTimeoutMs)
READ_TIMEOUT_MS if
not set explicitly.readTimeoutMs - read timeout in millisecondspublic String[] getAcceptedIssuers()
null if all
Issuer Organization names are accepted.setAcceptedIssuers(java.lang.String[])public void setAcceptedIssuers(String[] acceptedIssuers)
This feature only applies when isValidateCertificates() is
false.
The purpose of the feature is to provide some minimal security rather than simply accepting any certificate. If - for example - you create a self-signed certificate then you decide the 'issuer organization' yourself and the issuer organization name you used when you created the certificate can then be validated here.
acceptedIssuers - accept only a certificate from one of these issuer
organizations. Check is done against the Organization (O) field in the 'Issued
By' section of the server's certificate. A null means all issuer
organizations are accepted.public Map<String,String> getAdditionalHeaders()
setAdditionalHeaders(java.util.Map)public void setAdditionalHeaders(Map<String,String> additionalHeaders)
The following header fields are automatically set:
"Connection"
"Cache-Control"
"Content-Type"
"Content-Length"
"Authorization"
and you must never set these here. (if you do they will be
ignored)
However you might want to use this method to
explicitly set e.g. User-Agent or non-standard header fields that
are required for your particular endpoint. For example by overriding
User-Agent you can make the upload operation look to the
endpoint as if it comes from a browser.
additionalHeaders - Map of HTTP request headers. The key is the header field
name and the value is the header field value.Copyright © 2015 Addicticks. All rights reserved.