- 
    Patch 
- 
    Resolution: Duplicate
- 
    Major 
- 
    None
- 
    Platform: Macintosh, OS: All
the jnlp slaves can't ship the auth credentials right now to get past a HTTP
Basic Authed hudson setup. This little patch may be a bit hacky and only support
Basic Auth, but it does the job for me.
$ java -jar slave.jar -noCertificateCheck -jnlpUrl
https://example.org/hudson/computer/NAME/slave-agent.jnlp -jnlpCredentials
user:password
Index: main/remoting/src/main/java/hudson/remoting/Launcher.java
===================================================================
— main/remoting/src/main/java/hudson/remoting/Launcher.java   (revision 19965)
+++ main/remoting/src/main/java/hudson/remoting/Launcher.java   (working copy)
@@ -94,6 +94,9 @@
             "Connection parameters are obtained by parsing the JNLP file.")
     public URL slaveJnlpURL = null;
+    @Option(name="-jnlpCredentials")
+    public String slaveJnlpCredentials = null;
+
     @Option(name="-cp",aliases="-classpath",metaVar="PATH",
             usage="add the given classpath elements to the system classloader.")
     public void addClasspath(String pathList) throws Exception {
@@ -185,6 +188,12 @@
         while (true) {
             try {
                 URLConnection con = slaveJnlpURL.openConnection();
+                if (con instanceof HttpURLConnection && slaveJnlpCredentials !=
null) 
con.connect();
                 if (con instanceof HttpURLConnection) {
@@ -216,6 +225,10 @@
                 List<String> jnlpArgs = new ArrayList<String>();
                 for( int i=0; i<argElements.getLength(); i++ )
                         jnlpArgs.add(argElements.item .getTextContent());
.getTextContent());
+                if (slaveJnlpCredentials != null) 
                 // force a headless mode
                 jnlpArgs.add("-headless");
                 return jnlpArgs;
Index: main/remoting/src/main/java/hudson/remoting/Engine.java
===================================================================
— main/remoting/src/main/java/hudson/remoting/Engine.java     (revision 19965)
+++ main/remoting/src/main/java/hudson/remoting/Engine.java     (working copy)
@@ -78,6 +78,7 @@
     private final String secretKey;
     public final String slaveName;
+    private String credentials;
/**
- See Main#tunnel in the jnlp-agent module for the details.
 @@ -103,6 +104,10 @@
 this.tunnel = tunnel;
 }
+ public void setCredentials(String creds)
{ + this.credentials = creds; + }+
     public void setNoReconnect(boolean noReconnect) 
@@ -130,6 +135,11 @@
                     // find out the TCP port
                     HttpURLConnection con =
(HttpURLConnection)salURL.openConnection();
+                if (con instanceof HttpURLConnection && credentials != null) 
try
{ con.connect(); } catch (IOException x) {
Index: main/remoting/src/main/java/hudson/remoting/jnlp/Main.java
===================================================================
— main/remoting/src/main/java/hudson/remoting/jnlp/Main.java  (revision 19965)
+++ main/remoting/src/main/java/hudson/remoting/jnlp/Main.java  (working copy)
@@ -64,6 +64,10 @@
             usage="Specify the Hudson root URLs to connect to.")
     public final List<URL> urls = new ArrayList<URL>();
+    @Option(name="-credentials",metaVar="USER:PASSWORD",
+            usage="Specify the Hudson credentials")
+    public String credentials;
+
     @Option(name="-noreconnect",
             usage="If the connection ends, don't retry and just exit.")
     public boolean noReconnect = false;
@@ -111,6 +115,8 @@
                 urls, args.get(0), args.get(1));
         if(tunnel!=null)
             engine.setTunnel(tunnel);
+        if(credentials!=null)
+            engine.setCredentials(credentials);
         engine.setNoReconnect(noReconnect);
         engine.start();
         engine.join();
- duplicates
- 
                    JENKINS-4071 jnlp slaves doesn't support HTTP Auth -         
- Closed
 
-