|                                                                                                              1
 30  package org.apache.commons.httpclient.contrib.auth;
 31
 32  import java.util.ArrayList
  ; 33
 34  import org.apache.commons.httpclient.Credentials;
 35  import org.apache.commons.httpclient.HttpClient;
 36  import org.apache.commons.httpclient.auth.AuthPolicy;
 37  import org.apache.commons.httpclient.auth.AuthScope;
 38  import org.apache.commons.httpclient.methods.GetMethod;
 39  import org.apache.commons.httpclient.params.DefaultHttpParams;
 40  import org.apache.commons.httpclient.params.HttpParams;
 41
 42
 78  public class CustomAuthenticationNegotiateExample {
 79
 80      public static void main(String
  [] args) { 81
 82                  AuthPolicy.registerAuthScheme("Negotiate", NegotiateScheme.class);
 84
 85                  ArrayList
  schemes = new ArrayList  (); 87          schemes.add("Negotiate");
 88
 89          HttpParams params = DefaultHttpParams.getDefaultParams();
 90          params.setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, schemes);
 91
 92                          HttpClient client = new HttpClient();
 95
 96                                  Credentials use_jaas_creds = new Credentials() {};
 100         client.getState().setCredentials(
 101             new AuthScope(null, -1, null),
 102             use_jaas_creds);
 103         GetMethod httpget = new GetMethod(args[0]);
 104
 105         try {
 106             client.executeMethod(httpget);
 107                                 } catch (Exception
  e) { 110             e.printStackTrace();
 111         } finally {
 112                         httpget.releaseConnection();
 114         }
 115
 116     }
 117 }
 118
                                                                                                                                                                                                             |                                                                       
 
 
 
 
 
                                                                                   Popular Tags                                                                                                                                                                                              |