Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
佳 邓
Gitlab4j Api
Commits
d971f9aa
Commit
d971f9aa
authored
Jun 22, 2019
by
Greg Messner
Browse files
Added support for NTLM proxies (#395).
parent
522234a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gitlab4j/api/ProxyClientConfig.java
View file @
d971f9aa
...
...
@@ -3,6 +3,11 @@ package org.gitlab4j.api;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.http.auth.AuthScope
;
import
org.apache.http.auth.NTCredentials
;
import
org.apache.http.client.CredentialsProvider
;
import
org.apache.http.impl.client.BasicCredentialsProvider
;
import
org.glassfish.jersey.apache.connector.ApacheClientProperties
;
import
org.glassfish.jersey.client.ClientProperties
;
/**
...
...
@@ -45,4 +50,28 @@ public class ProxyClientConfig {
return
(
clientConfig
);
}
/**
* Create a Map instance set up to use an NTLM proxy server that can be passed to the GitLabAPi constructors
* and login methods to configure the GitLabApi instance to use an NTLM proxy server.
*
* @param proxyUri the URI of the proxy server
* @param username the user name. This should not include the domain to authenticate with.
* For example: "user" is correct whereas "DOMAIN\user" is not.
* @param password the password
* @param workstation the workstation the authentication request is originating from. Essentially, the computer name for this machine.
* @param domain the domain to authenticate within
* @return a Map set up to allow GitLabApi to use an NTLM proxy server
*/
public
static
Map
<
String
,
Object
>
createNtlmProxyClientConfig
(
String
proxyUri
,
String
username
,
String
password
,
String
workstation
,
String
domain
)
{
Map
<
String
,
Object
>
clientConfig
=
new
HashMap
<>();
clientConfig
.
put
(
ClientProperties
.
PROXY_URI
,
proxyUri
);
CredentialsProvider
credentials
=
new
BasicCredentialsProvider
();
credentials
.
setCredentials
(
AuthScope
.
ANY
,
new
NTCredentials
(
username
,
password
,
workstation
,
domain
));
clientConfig
.
put
(
ApacheClientProperties
.
CREDENTIALS_PROVIDER
,
credentials
);
return
(
clientConfig
);
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment