Android BasicCredentialsProvider - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android BasicCredentialsProvider class.

This code example shows how to use the following methods:setCredentials
	@Override 
	protected String[] doInBackground(String... arg0)
	{ 
		AuthScope scope = new AuthScope("maties2.sun.ac.za", 443);
		Credentials mCredentials = new UsernamePasswordCredentials(arg0[0], arg0[1]);
		CredentialsProvider mProvider = new BasicCredentialsProvider();
		mProvider.setCredentials(scope, mCredentials);
		((AbstractHttpClient) this.client).setCredentialsProvider(mProvider);
		 
		HttpGet fwusage = new HttpGet(FW_URL);
		 
		String response;
		 
		try { 
			response = getResponse(fwusage);
		} catch (SocketTimeoutException e) {
			// TODO Auto-generated catch block 
			return null; 
		} catch (ClientProtocolException e) {
			// TODO Auto-generated catch block 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setCredentials
This code example shows how to use the following methods:setCredentials
This code example shows how to use the following methods:setCredentials
This code example shows how to use the following methods:setCredentials
This code example shows how to use the following methods:setCredentials
	 
	ReusableHttpClientBlocking(int timeout, String user, String password) {
		Log.d(TAG, "Creating a new HTTP client");
		mHttpClient = new DefaultHttpClient();
		if (!TextUtils.isEmpty(password)) {
			CredentialsProvider credProvider = new BasicCredentialsProvider();
		    credProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), 
		    		new UsernamePasswordCredentials(user, password));
		    mHttpClient.setCredentialsProvider(credProvider);
		} 
		mRequest = new HttpGet();
		mRequest.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, new Integer(timeout));
		mRequest.getParams().setParameter(CoreConnectionPNames.SO_LINGER, new Integer(timeout/2));
		mRequest.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, new Integer(timeout));
	} 
 
	/** 
	 * Perform the blocking fetch. 
	 * @throws IOException  
	 * @throws URISyntaxException  
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setCredentials
This code example shows how to use the following methods:
        params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE, new ConnPerRouteBean(1));
        params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
        HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
        HttpProtocolParams.setContentCharset(params, "utf8");
  
        CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
         
//	        credentialsProvider.setCredentials(new AuthScope("cooper.apphb.com", AuthScope.ANY_PORT) 
//	        	, new UsernamePasswordCredentials("UserNameHere", "UserPasswordHere")); 
        clientConnectionManager = new ThreadSafeClientConnManager(params, schemeRegistry);
  
        context = new BasicHttpContext();
        context.setAttribute("http.auth.credentials-provider", credentialsProvider);
	} 
	 
	public DefaultHttpClient getHttpClient()
	{ 
		 
		DefaultHttpClient httpClient = new DefaultHttpClient(clientConnectionManager, params);
		 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setCredentials
    public ClientRestTemplate() { 
    } 
 
    public ClientRestTemplate(String username, String password) {
        DefaultHttpClient httpClient = new DefaultHttpClient();
        BasicCredentialsProvider credentialsProvider =  new BasicCredentialsProvider();
        credentialsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(username, password));
        httpClient.setCredentialsProvider(credentialsProvider);
        httpClient.addRequestInterceptor(new PreemptiveAuthInterceptor(), 0);
        ClientHttpRequestFactory rf = new HttpComponentsClientHttpRequestFactory(httpClient);
 
        this.setRequestFactory(rf);
    } 
 
    static class PreemptiveAuthInterceptor implements HttpRequestInterceptor {
 
        public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
            AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
 
            if (authState.getAuthScheme() == null) {
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:setCredentials
	static public HttpResponse doHttpGet(String URL, String user, String pswd) {
		HttpResponse response = null;
	    // Create a new HttpClient and Post Header 
	    DefaultHttpClient http = new DefaultHttpClient();
	    // Basic Auth 
	    CredentialsProvider credProvider = new BasicCredentialsProvider();
	    credProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
	        new UsernamePasswordCredentials(user, pswd)); 
	    http.setCredentialsProvider(credProvider);
	    //Perform HTTP GET 
	    HttpGet httpget = new HttpGet(URL);
	    Log.d("QA test", "doHttpGet() " + URL);
	    try { 
	        // Execute HTTP Get Request 
	        response = http.execute(httpget);
	    } catch (ClientProtocolException e) {
	        // TODO Auto-generated catch block 
	    } catch (IOException e) {
	        // TODO Auto-generated catch block 
	    } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android BasicCredentialsProvider Questions & Answers:

See Code Examples for Android BasicCredentialsProvider Methods: