Skip to content

Commit 207ec08

Browse files
authored
Unify two entrypoints (#677)
1 parent b329c48 commit 207ec08

File tree

6 files changed

+378
-609
lines changed

6 files changed

+378
-609
lines changed

docs/inbound-agent.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ This mechanism requires a download of the `agent.jar`, as described for "Downloa
7878

7979
Once all the prerequisite files and data have been obtained, the agent can be launched with a command like this
8080
```
81-
java -cp agent.jar hudson.remoting.jnlp.Main \
81+
java -jar agent.jar \
8282
-workDir <work directory> \
8383
-direct <HOST:PORT> \
8484
-protocols JNLP4-connect \
8585
-instanceIdentity <instance identity> \
86-
<secretString> <agentName>
86+
-secret <secretString> \
87+
-name <agentName>
8788
```
8889
The "-protocols" parameter is optional, but is useful to limit the agent to protocols the server supports.
8990
The only currently supported and recommended protocol is "JNLP4-connect".
@@ -102,7 +103,7 @@ Additional descriptions of configuring this mechanism are located at [Installing
102103

103104
There are a number of different launch parameters that control how the agent connects and behaves.
104105
The parameters available and the default behavior may vary depending upon the entry point.
105-
You can obtain usage information by executing `java -cp agent.jar hudson.remoting.jnlp.Main` or `java -jar agent.jar --help`.
106+
You can obtain usage information by executing `java -jar agent.jar --help`.
106107
Not all parameters work together and some parameters require the use of others.
107108

108109
There are also system or environment variables that control some advanced behaviors documented at [Remoting Configuration](https://github.com/jenkinsci/remoting/blob/master/docs/configuration.md).

src/main/java/hudson/remoting/Engine.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494
import org.jenkinsci.remoting.protocol.impl.ConnectionRefusalException;
9595
import org.jenkinsci.remoting.util.KeyUtils;
9696
import org.jenkinsci.remoting.util.VersionNumber;
97+
import org.kohsuke.accmod.Restricted;
98+
import org.kohsuke.accmod.restrictions.NoExternalUse;
9799

98100
/**
99101
* Agent engine that proactively connects to Jenkins controller.
@@ -166,10 +168,10 @@ public Thread newThread(@NonNull final Runnable r) {
166168
private Map<String, String> webSocketHeaders;
167169
private String credentials;
168170
private String protocolName;
169-
private String proxyCredentials = System.getProperty("proxyCredentials");
171+
private String proxyCredentials;
170172

171173
/**
172-
* See {@link hudson.remoting.jnlp.Main#tunnel} for the documentation.
174+
* See {@link Launcher#tunnel} for the documentation.
173175
*/
174176
@CheckForNull
175177
private String tunnel;
@@ -885,7 +887,7 @@ private JnlpEndpointResolver createEndpointResolver(List<String> jenkinsUrls) {
885887
if (directConnection == null) {
886888
SSLSocketFactory sslSocketFactory = null;
887889
try {
888-
sslSocketFactory = getSSLSocketFactory();
890+
sslSocketFactory = getSSLSocketFactory(candidateCertificates);
889891
} catch (Exception e) {
890892
events.error(e);
891893
}
@@ -1034,16 +1036,18 @@ private static FileInputStream getFileInputStream(final File file) throws Privil
10341036
});
10351037
}
10361038

1037-
private SSLSocketFactory getSSLSocketFactory()
1039+
@CheckForNull
1040+
@Restricted(NoExternalUse.class)
1041+
static SSLSocketFactory getSSLSocketFactory(List<X509Certificate> x509Certificates)
10381042
throws PrivilegedActionException, KeyStoreException, NoSuchProviderException, CertificateException,
10391043
NoSuchAlgorithmException, IOException, KeyManagementException {
10401044
SSLSocketFactory sslSocketFactory = null;
1041-
if (candidateCertificates != null && !candidateCertificates.isEmpty()) {
1045+
if (x509Certificates != null && !x509Certificates.isEmpty()) {
10421046
KeyStore keyStore = getCacertsKeyStore();
10431047
// load the keystore
10441048
keyStore.load(null, null);
10451049
int i = 0;
1046-
for (X509Certificate c : candidateCertificates) {
1050+
for (X509Certificate c : x509Certificates) {
10471051
keyStore.setCertificateEntry(String.format("alias-%d", i++), c);
10481052
}
10491053
// prepare the trust manager

0 commit comments

Comments
 (0)