org.jvnet.hudson.client_demo
Class SecuredMain

java.lang.Object
  extended by org.jvnet.hudson.client_demo.SecuredMain

public class SecuredMain
extends java.lang.Object

Java client program to demonstrate how to access Hudson remote API, when authentication is involved.

Author:
Kohsuke Kawaguchi
See Also:
http://hudson.gotdns.com/wiki/display/HUDSON/Remote+access+API

Constructor Summary
SecuredMain()
           
 
Method Summary
static void main(java.lang.String[] args)
          On most security configurations, except "delegate to servlet container" authentication, simply sending in the BASIC authentication pre-emptively works.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecuredMain

public SecuredMain()
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
On most security configurations, except "delegate to servlet container" authentication, simply sending in the BASIC authentication pre-emptively works. See http://hc.apache.org/httpclient-3.x/authentication.html for how to configure pre-emptive authentication.

However, in the "delegate to servlet container" mode, BASIC auth support depends on the container implementation, and hence inherently unreliable. The following code uses Jakarta Commons HTTP client to work around this problem by essentially emulating what the user does through the browser.

The code first emulates a click of the "login" link, then submit the login form. Once that's done, you are authenticated, so you can access the information you wanted. This is all possible because HttpClient maintains a cookie jar in it.

Throws:
java.io.IOException


Copyright © 2006-2008. All Rights Reserved.