Methods Summary |
---|
private final java.lang.String | asURLSpec(java.lang.String path)Return a string which can be used as the specification to
form an URL.
return this.getConnectorType()
+"://"+this.getAuthority()
+(path != null? path : "");
|
public AuthenticationInfo | getAuthenticationInfo()
return authInfo;
|
private final java.lang.String | getAuthority()Return the authority portion of the URL spec
return this.getHost() + ":" + this.getPort();
|
private static final java.lang.String | getBase64Encoded(java.lang.String clearString)
return new BASE64Encoder().encode(clearString.getBytes());
|
private final java.lang.String | getBasicAuthString()
return AUTHORIZATION_TYPE+ this.getBase64Encoded(this.getUser() + ":" + this.getPassword());
|
public java.lang.String | getConnectorType()get the protocol prefix to be used for a connection for the
receiver
return this.isSecure() ? HTTPS_CONNECTOR : HTTP_CONNECTOR;
|
public java.lang.String | getHost()
return host;
|
private final java.lang.String | getPassword()
return authInfo != null ? authInfo.getPassword() : "";
|
public int | getPort()
return port;
|
private final java.lang.String | getUser()
return authInfo != null ? authInfo.getUser() : "";
|
public boolean | isSecure()Indicate if the reciever represents a secure address
return secure;
|
private final java.net.URLConnection | makeConnection(java.net.URL url)
URLConnection uc = url.openConnection();
if (uc instanceof HttpsURLConnection){
setHostnameVerifier((HttpsURLConnection) uc);
}
return uc;
|
private final java.net.URLConnection | openConnection(java.net.URL url)
return this.setOptions(this.makeConnection(url));
|
public java.net.URLConnection | openConnection(java.lang.String path)Open a connection using the reciever and the given path
return this.openConnection(this.toURL(path));
|
private final java.net.URLConnection | setAuthentication(java.net.URLConnection uc)
if (authInfo != null) {
uc.setRequestProperty(AUTHORIZATION_KEY, this.getBasicAuthString());
}
return uc;
|
public void | setAuthenticationInfo(AuthenticationInfo authInfo)
this.authInfo = authInfo;
|
public void | setHost(java.lang.String host)
this.host = host;
|
private final java.net.URLConnection | setHostnameVerifier(javax.net.ssl.HttpsURLConnection uc)Set the hostname verifier on the given connection so that a
peer which appears to be the one we want to connect to is accepted.
uc.setHostnameVerifier(
new HostnameVerifier() {
private final String expected = host;
public boolean verify(String h, SSLSession s){
return expected.equals(h);
}
}
);
return uc;
|
private final java.net.URLConnection | setOptions(java.net.URLConnection uc)
uc.setDoOutput(true);
uc.setUseCaches(false);
uc.setRequestProperty("Content-type", "application/octet-stream");
return this.setAuthentication(uc);
|
public void | setPort(int port)
this.port = port;
|
public void | setSecure(boolean secure)Set the security attibute
this.secure = secure;
|
private final java.net.URL | toURL(java.lang.String path)
return new URL(this.asURLSpec(path));
|