Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #31 from Microsoft/support_proxy_servers
Browse files Browse the repository at this point in the history
Add support for proxy servers
  • Loading branch information
olivierdagenais committed Mar 17, 2016
2 parents 4673a81 + 2416823 commit cf9f524
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ Licensed under the MIT license. See License.txt in the project root. -->
<dependency>
<groupId>com.microsoft.alm</groupId>
<artifactId>oauth2-useragent</artifactId>
<version>0.5.4</version>
<version>0.7.1</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,9 @@ static void configureGit(final TestableProcessFactory processFactory, final Stri
// escape spaces (if any) in paths to java and path to JAR
// i.e. !/usr/bin/jre\ 1.6/bin/java -Ddebug=false -jar /home/example/with\ spaces/gcm.jar
sb.append("!").append(escapeSpaces(pathToJava));
sb.append(" -Ddebug=").append(isDebug).append(" -jar ");
sb.append(escapeSpaces(pathToJar));
sb.append(" -Ddebug=").append(isDebug);
sb.append(" -Djava.net.useSystemProxies=true");
sb.append(" -jar ").append(escapeSpaces(pathToJar));
final String gcmCommandLine = sb.toString();

final String[] command =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public TestableProcess create(final String... strings) throws IOException
Assert.assertEquals("--global", strings[2]);
Assert.assertEquals("--add", strings[3]);
Assert.assertEquals("credential.helper", strings[4]);
Assert.assertEquals("!/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.fc22.x86_64/bin/java -Ddebug=false -jar /usr/bin/git-credential-manager-1.1.0.jar", strings[5]);
Assert.assertEquals("!/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.fc22.x86_64/bin/java -Ddebug=false -Djava.net.useSystemProxies=true -jar /usr/bin/git-credential-manager-1.1.0.jar", strings[5]);
return process;
}
};
Expand All @@ -260,7 +260,7 @@ public TestableProcess create(final String... strings) throws IOException
Assert.assertEquals("--system", strings[2]);
Assert.assertEquals("--add", strings[3]);
Assert.assertEquals("credential.helper", strings[4]);
Assert.assertEquals("!/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java -Ddebug=true -jar /usr/local/bin/git-credential-manager-1.1.0.jar", strings[5]);
Assert.assertEquals("!/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java -Ddebug=true -Djava.net.useSystemProxies=true -jar /usr/local/bin/git-credential-manager-1.1.0.jar", strings[5]);
return process;
}
};
Expand Down
34 changes: 31 additions & 3 deletions templates/Install.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Download [${project.artifactId}-${project.version}.jar](https://github.com/Micro
1. Configure the `credential.helper` setting to launch Java with the absolute path to the JAR (make sure you surround the whole value with 'single quotes'):

```
git config --global credential.helper '!java -Ddebug=false -jar /home/example/${project.artifactId}/${project.artifactId}-${project.version}.jar'
git config --global credential.helper '!java -Ddebug=false -Djava.net.useSystemProxies=true -jar /home/example/${project.artifactId}/${project.artifactId}-${project.version}.jar'
```


Expand All @@ -107,9 +107,37 @@ Debug mode will turn on tracing and assertions, producing a lot of output to `st
...it should look like this:

```
!java -Ddebug=false -jar /home/example/${project.artifactId}/${project.artifactId}-${project.version}.jar
!java -Ddebug=false -Djava.net.useSystemProxies=true -jar /home/example/${project.artifactId}/${project.artifactId}-${project.version}.jar
```
2. Set a new value for the `credential.helper` configuration (essentially repeating the _manual configuration_ installation step, being careful with quoting and spaces), changing the value of the `debug` property to `true` (or `false` to disable).


## How to configure the proxy server
If your network does not allow a direct connection to remote hosts, you can configure the GCM to perform requests through a web proxy.

### Automatic configuration (recommended)
If you are running Gnome 2.x or greater, you can configure the proxy settings using the GUI and the GCM will use those settings thanks to a JVM feature that's activated by setting the `java.net.useSystemProxies` system property to `true` (this is now done automatically when running the GCM in `install` mode).

### Manual configuration

If it's not possible to use the automatic proxy server configuration, you must set the appropriate [networking properties](http://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html). Aside from SOCKS proxy servers, which can have their credentials specified through specific properties, authenticated proxy servers are currently not supported.

1. Retrieve the value of the `credential.helper` configuration:

```
git config --global --get credential.helper ${project.artifactId}
```
...it should look like this:

```
!java -Ddebug=false -Djava.net.useSystemProxies=true -jar /home/example/${project.artifactId}/${project.artifactId}-${project.version}.jar
```
2. Set a new value for the `credential.helper` configuration (essentially repeating the _manual configuration_ installation step, being careful with quoting and spaces), adding the appropriate properties. For example, if you have a proxy server that can do HTTP and HTTPS, running on the host `192.168.0.117`, listening on port `8123`, then you would run the following (notice there's a pair of properties for http and one for https).


```
git config --global credential.helper '!java -Ddebug=false -Dhttp.proxyHost=192.168.0.117 -Dhttp.proxyPort=8123 -Dhttps.proxyHost=192.168.0.117 -Dhttps.proxyPort=8123 -jar /home/example/${project.artifactId}/${project.artifactId}-${project.version}.jar'
```
2. Set a new value for the `credential.helper` configuration (essentially repeating the _manual configuration step_, being careful with quoting and spaces), changing the value of the `debug` property to `true` (or `false` to disable).


## How to remove or uninstall
Expand Down

0 comments on commit cf9f524

Please sign in to comment.