Skip to content

Commit 5a29a3b

Browse files
authored
Merge pull request #8 from rchougule/master
Non-Mandatory Proxy Auth Params
2 parents ef2cbd5 + 7f5ce9e commit 5a29a3b

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

README.md

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# automate-client-java
22

3-
## For Code formatting
4-
Code style files are there in code_formatters folder (for eclipse and intellij idea) ,to import formatter instructions are as follows :
5-
* For Eclipse : Under Window/Preferences select Java/Code Style/Formatter. Import the settings file by selecting Import.
6-
* For IntelliJ Idea : Settings → Code Style → Java, click Manage, and import that XML file by simply clicking Import.
3+
<p align="center">
4+
<a href="https://browserstack.com"><img alt="BrowserStack Logo" src="https://d98b8t1nnulk5.cloudfront.net/production/images/layout/logo-invoice.svg"></a>
5+
</p>
6+
7+
Java Package to seamlessly connect with Automate and App-Automate.
8+
9+
## Features
10+
1. Operations on Projects, Builds & Sessions
11+
2. Upload App for App-Automate
12+
3. Account Usage
13+
4. Reset Key
14+

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<groupId>com.browserstack</groupId>
77
<artifactId>automate-client-java</artifactId>
88
<name>automate-client</name>
9-
<version>0.6</version>
9+
<version>0.7</version>
1010
<packaging>jar</packaging>
1111
<description>Java bindings for BrowserStack Automate REST API</description>
1212
<url>https://www.browserstack.com</url>

src/main/java/com/browserstack/client/BrowserStackClient.java

+15-10
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,25 @@ static HttpRequest newRequest(final HttpRequestFactory requestFactory, final Met
157157

158158
public void setProxy(final String proxyHost, final int proxyPort, final String proxyUsername, final String proxyPassword) {
159159

160-
if (proxyHost == null || proxyUsername == null || proxyPassword == null) {
160+
if (proxyHost == null || proxyPort == 0) {
161161
return;
162162
}
163163

164-
final BasicCredentialsProvider basicCredentialsProvider = new BasicCredentialsProvider();
165-
final AuthScope proxyAuthScope = new AuthScope(proxyHost, proxyPort);
166-
UsernamePasswordCredentials proxyAuthentication =
167-
new UsernamePasswordCredentials(proxyUsername, proxyPassword);
168-
basicCredentialsProvider.setCredentials(proxyAuthScope, proxyAuthentication);
169-
170164
final HttpHost proxy = new HttpHost(proxyHost, proxyPort);
171-
final HttpClient client = HttpClientBuilder.create().setProxy(proxy).setDefaultCredentialsProvider(basicCredentialsProvider).build();
172-
final ApacheHttpTransport transport = new ApacheHttpTransport(client);
173-
this.HTTP_TRANSPORT = transport;
165+
HttpClientBuilder clientBuilder = HttpClientBuilder.create().setProxy(proxy);
166+
167+
if (proxyUsername != null && proxyUsername.length() != 0 && proxyPassword != null && proxyPassword.length() != 0) {
168+
final BasicCredentialsProvider basicCredentialsProvider = new BasicCredentialsProvider();
169+
final AuthScope proxyAuthScope = new AuthScope(proxyHost, proxyPort);
170+
UsernamePasswordCredentials proxyAuthentication =
171+
new UsernamePasswordCredentials(proxyUsername, proxyPassword);
172+
basicCredentialsProvider.setCredentials(proxyAuthScope, proxyAuthentication);
173+
174+
clientBuilder.setDefaultCredentialsProvider(basicCredentialsProvider);
175+
}
176+
177+
final HttpClient client = clientBuilder.build();
178+
HTTP_TRANSPORT = new ApacheHttpTransport(client);
174179
this.requestFactory = newRequestFactory();
175180
}
176181

0 commit comments

Comments
 (0)