Skip to content

Commit cff589a

Browse files
committed
Initial commit (#141).
1 parent e40e917 commit cff589a

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.gitlab4j.api;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
import org.glassfish.jersey.client.ClientProperties;
7+
8+
/**
9+
* This class provides convenience methods to create ClientConfig properties so GitLabApi can use a proxy server.
10+
*/
11+
public class ProxyClientConfig {
12+
13+
/**
14+
* Create a Map instance with properties set up to use a proxy server that can be passed to the
15+
* GitLabAPi constructors and login methods to configure the GitLabApi instance to use a proxy server.
16+
*
17+
* @param proxyUri the URI of the proxy server
18+
* @return a Map set up to allow GitLabApi to use a proxy server
19+
*/
20+
public static Map<String, Object> createProxyClientConfig(String proxyUri) {
21+
return (createProxyClientConfig(proxyUri, null, null));
22+
}
23+
24+
/**
25+
* Create a Map instance set up to use a proxy server that can be passed to the GitLabAPi constructors
26+
* and login methods to configure the GitLabApi instance to use a proxy server.
27+
*
28+
* @param proxyUri the URI of the proxy server
29+
* @param username the username for basic auth with the proxy server
30+
* @param password the password for basic auth with the proxy server
31+
* @return a Map set up to allow GitLabApi to use a proxy server
32+
*/
33+
public static Map<String, Object> createProxyClientConfig(String proxyUri, String username, String password) {
34+
35+
Map<String, Object> clientConfig = new HashMap<>();
36+
clientConfig.put(ClientProperties.PROXY_URI, proxyUri);
37+
38+
if (username != null && username.trim().length() > 0) {
39+
clientConfig.put(ClientProperties.PROXY_USERNAME, username);
40+
}
41+
42+
if (password != null && password.trim().length() > 0) {
43+
clientConfig.put(ClientProperties.PROXY_PASSWORD, password);
44+
}
45+
46+
return (clientConfig);
47+
}
48+
}

0 commit comments

Comments
 (0)