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