1 17 package org.apache.servicemix.http; 18 19 import org.apache.commons.httpclient.HttpClient; 20 import org.apache.commons.httpclient.Credentials; 21 import org.apache.commons.httpclient.UsernamePasswordCredentials; 22 import org.apache.commons.httpclient.auth.AuthScope; 23 24 31 public class BasicAuthCredentials { 32 33 protected String username; 34 protected String password; 35 36 public BasicAuthCredentials() 37 { 38 } 39 40 43 public String getUsername() { 44 return username; 45 } 46 47 50 public void setUsername(String username) { 51 this.username = username; 52 } 53 54 57 public String getPassword() { 58 return password; 59 } 60 61 64 public void setPassword(String password) { 65 this.password = password; 66 } 67 68 72 public void applyCredentials( HttpClient client ) 73 { 74 AuthScope scope = new AuthScope( AuthScope.ANY_HOST, AuthScope.ANY_PORT ); 75 Credentials credentials = new UsernamePasswordCredentials( this.username, this.password ); 76 client.getState().setCredentials( scope, credentials ); 77 } 78 79 } 80 | Popular Tags |