Code example for BasicCredentialsProvider

Methods: setCredentials

0
     * @param password 
     */ 
    public EasyHttpClient(String username, String password) {
        if(username != null && password != null) {
            UsernamePasswordCredentials c = new UsernamePasswordCredentials(username,password);
            BasicCredentialsProvider cP = new BasicCredentialsProvider();
            cP.setCredentials(AuthScope.ANY, c);
            setCredentialsProvider(cP);
        } 
    } 
 
    /** 
     * Function that creates a ClientConnectionManager which can handle http and https. 
     * In case of https self signed or invalid certificates will be accepted. 
     */ 
    @Override 
    protected ClientConnectionManager createClientConnectionManager() {
        HttpParams params = new BasicHttpParams();
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, "utf-8");
        params.setBooleanParameter("http.protocol.expect-continue", false);