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) {
+                    HttpURLConnection http = (HttpURLConnection) con;
+		    String userPassword = slaveJnlpCredentials;
+		    String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
+		    http.setRequestProperty ("Authorization", "Basic " + encoding);
+		}
                 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(i).getTextContent());
+                if (slaveJnlpCredentials != null) {
+			jnlpArgs.add("-credentials");
+		       jnlpArgs.add(slaveJnlpCredentials);
+		}
                 // 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) {
         this.noReconnect = noReconnect;
     }
@@ -130,6 +135,11 @@
 
                     // find out the TCP port
                     HttpURLConnection con = (HttpURLConnection)salURL.openConnection();
+                if (con instanceof HttpURLConnection && credentials != null) {
+                    HttpURLConnection http = (HttpURLConnection) con;
+		    String encoding = new sun.misc.BASE64Encoder().encode (credentials.getBytes());
+		    http.setRequestProperty ("Authorization", "Basic " + encoding);
+		}
                     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();
