fix merge issue; refactoring
This commit is contained in:
parent
eafae99b79
commit
60c990b8c1
|
@ -16,6 +16,8 @@
|
|||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
|
|
|
@ -48,12 +48,11 @@ public class HttpClient {
|
|||
}
|
||||
}
|
||||
|
||||
private void setAuthenticator() {
|
||||
Authenticator.setDefault(new Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(user, password.toCharArray());
|
||||
}
|
||||
});
|
||||
private HttpURLConnection createConnection(String urlString) throws MalformedURLException, IOException, ProtocolException {
|
||||
URL url = new URL(String.format(urlString));
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
return connection;
|
||||
}
|
||||
|
||||
private String createBasicAuthHeaderValue() {
|
||||
|
@ -63,10 +62,13 @@ public class HttpClient {
|
|||
return authHeaderValue;
|
||||
}
|
||||
|
||||
private HttpURLConnection createConnection(String urlString) throws MalformedURLException, IOException, ProtocolException {
|
||||
URL url = new URL(String.format(urlString));
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
return connection;
|
||||
private void setAuthenticator() {
|
||||
Authenticator.setDefault(new BasicAuthenticator());
|
||||
}
|
||||
|
||||
private final class BasicAuthenticator extends Authenticator {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(user, password.toCharArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue