Android UsernamePasswordCredentials - 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 UsernamePasswordCredentials class.

This code example shows how to use the following methods:
    } 
 
    private DefaultHttpClient createHttpClient(final URL webAppURL, final String userName, final String userPassword) {
        DefaultHttpClient httpClient = new DefaultHttpClient();
 
        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(userName, userPassword);
 
        httpClient.getCredentialsProvider().setCredentials(new AuthScope(webAppURL.getHost(), webAppURL.getPort(), DEPLOYMENT_REALM_NAME), credentials);
 
        return httpClient;
    } 
 
    /** 
     * A {@link org.jboss.as.arquillian.api.ServerSetupTask} instance which creates security domains for this test case. 
     * 
     * @author Pedro Igor 
     */ 
    static class SecurityDomainsSetup extends AbstractSecurityDomainsServerSetupTask { 
 
        public static final String UNDERTOW_MODULE_NAME = "org.wildfly.extension.undertow";
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
            httpClient = HttpClientUtils.wrapHttpsClient(new DefaultHttpClient());
        } else { 
            httpClient = new DefaultHttpClient();
        } 
 
        ((DefaultHttpClient) httpClient).getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY),
                new UsernamePasswordCredentials(user, pass));
 
        HttpGet get = new HttpGet(url);
        HttpResponse hr;
        try { 
            hr = httpClient.execute(get);
        } catch (Exception e) {
            if (responseSubstring == null)
                return false; 
            else // in case substring is defined, rethrow exception so, we can easier analyze the cause 
                throw new Exception(e);
        } 
 
        int statusCode = hr.getStatusLine().getStatusCode();
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
     * @param password 
     * @param scope - an AuthScope object 
     * 
     */ 
    public void setBasicAuth( String user, String pass, AuthScope scope){
        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user,pass);
        this.httpClient.getCredentialsProvider().setCredentials(scope, credentials);
    } 
 
    /** 
     * Cancels any pending (or potentially active) requests associated with the 
     * passed Context. 
     * <p> 
     * <b>Note:</b> This will only affect requests which were created with a non-null 
     * android Context. This method is intended to be used in the onDestroy 
     * method of your android activities to destroy all requests which are no 
     * longer required. 
     * 
     * @param context the android Context instance associated to the request. 
     * @param mayInterruptIfRunning specifies if active requests should be cancelled along with pending requests. 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        } 
    } 
 
    private void addBasicAuthCredentials(DefaultHttpClient client, String domainName, String username, String password) {
        if (!isEmptyOrWhitespace(username) || !isEmptyOrWhitespace(password)) {
            UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
            client.getCredentialsProvider().setCredentials(new AuthScope(domainName, 443), credentials);
        } 
    } 
 
    private DefaultHttpClient getHttpClient() {
        if (httpClient == null) {
            HttpParams parameters = new BasicHttpParams();
            SchemeRegistry schemeRegistry = new SchemeRegistry();
            schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
            schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
            httpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(parameters, schemeRegistry), parameters);
        } 
        return httpClient;
    } 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
						new HttpHost(proxy, proxyPort, protocol));
			} 
			DefaultHttpClient client = new DefaultHttpClient(
					configureConnectionManager(params), params);
			if (username != null && password != null) {
				client.getCredentialsProvider().setCredentials(
						new AuthScope(host, port, AuthScope.ANY_REALM),
						new UsernamePasswordCredentials(username, password));
				client.addRequestInterceptor(
						new PreemptiveAuthRequestInterceptor(), 0); 
			} 
 
 
 
			return client;
		} 
 
		public Builder port(int i) {
			port = i;
			return this;
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
httpClient = new DefaultHttpClient();
             
            if( getUsername() != null || getPassword() != null ) 
            { 
                httpClient.getCredentialsProvider().setCredentials(
                    new AuthScope( getHost(), getHttpPort() ),
                    new UsernamePasswordCredentials( getUsername(), getPassword() ) );
            } 
        } 
         
        return httpClient;
    } 
 
    public int getHttpPort() 
    { 
        return httpPort;
    } 
 
    protected String getHttpResponse( HttpUriRequest request ) throws Exception
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    } 
 
    @Override 
    public void setCredentials(String username, String password) {
        AuthScope authScope = new AuthScope(AUTH_SCOPE, AUTH_PORT, AUTH_REALM, AUTH_TYPE);
        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password);
        httpClient.getCredentialsProvider().setCredentials(authScope, credentials);
    } 
 
    public void setClientId(String clientId) {
        this.clientId = clientId;
    } 
 
    @Override 
    public Release lookupReleaseUsingBarcode(String barcode) throws IOException {
        HttpEntity entity = get(QueryBuilder.barcodeSearch(barcode));
        String barcodeMbid = responseParser.parseMbidFromBarcode(entity.getContent());
        entity.consumeContent();
        if (barcodeMbid == null) {
            throw new BarcodeNotFoundException(barcode);
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
		HttpClientParams.setRedirecting(params, true);
		DefaultHttpClient httpClient = new DefaultHttpClient(params);
		CredentialsProvider credential = httpClient.getCredentialsProvider();
		if (login != null && login.length() > 0 && password != null
				&& password.length() > 0)
			credential.setCredentials(
					new AuthScope(uri.getHost(), uri.getPort()),
					new UsernamePasswordCredentials(login, password));
		else 
			credential.clear();
 
		HttpPost httpPost = new HttpPost(uri);
		MultipartEntity reqEntity = new MultipartEntity();
		new Monitor().writeToPost(reqEntity);
		try { 
			reqEntity.addPart("instanceId", new StringBody(instanceId));
		} catch (UnsupportedEncodingException e) {
			throw new SearchLibException(e);
		} 
		httpPost.setEntity(reqEntity);
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
     * @param password 
     * @param scope - an AuthScope object 
     * 
     */ 
    public void setBasicAuth( String user, String pass, AuthScope scope){
        UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user,pass);
        this.httpClient.getCredentialsProvider().setCredentials(scope, credentials);
    } 
 
    /** 
     * Cancels any pending (or potentially active) requests associated with the 
     * passed Context. 
     * <p> 
     * <b>Note:</b> This will only affect requests which were created with a non-null 
     * android Context. This method is intended to be used in the onDestroy 
     * method of your android activities to destroy all requests which are no 
     * longer required. 
     * 
     * @param context the android Context instance associated to the request. 
     * @param mayInterruptIfRunning specifies if active requests should be cancelled along with pending requests. 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
		} 
		throw new RuntimeException("Method not supported: " + method);
	} 
 
	public void setUser(String user, String pass) {
		client.getCredentialsProvider().setCredentials(
				new AuthScope("localhost", AuthScope.ANY_PORT,
						AuthScope.ANY_REALM),
				new UsernamePasswordCredentials(user, pass));
 
		// client.getParams().setAuthenticationPreemptive(true); 
	} 
 
	public WebResponse invoke(RequestMethod type, String uri, String... params) {
		WebRequest m = createRequest(type);
		m.setUri(uri);
		for (String param : params) {
			int idx = param.indexOf("=");
			String key = param.substring(0, idx);
			String value = param.substring(idx + 1);
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android UsernamePasswordCredentials Questions & Answers:

See Code Examples for Android UsernamePasswordCredentials Methods: