Android AuthScope - 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 AuthScope 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";
 
        @Override 
7
CodeRank
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
This code example shows how to use the following methods:
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
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
This code example shows how to use the following methods:
        this.clientId = clientId;
    } 
 
    @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) {
6
CodeRank
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
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);
5
CodeRank
This code example shows how to use the following methods:
 
    private static final String SCHEME = "https";
    private static final String PINBOARD_AUTHORITY = "api.pinboard.in";
    private static final int PORT = 443;
  
    private static final AuthScope SCOPE = new AuthScope(PINBOARD_AUTHORITY, PORT);
 
    /** 
     * Attempts to authenticate to Pinboard using a legacy Pinboard account. 
     *  
     * @param username The user's username. 
     * @param password The user's password. 
     * @param handler The hander instance from the calling UI thread. 
     * @param context The context of the calling Activity. 
     * @return The boolean result indicating whether the user was 
     *         successfully authenticated. 
     */ 
    public static boolean pinboardAuthenticate(String username, String password) {
        final HttpResponse resp;
         
5
CodeRank
This code example shows how to use the following methods:
	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

Related Android AuthScope Questions & Answers:

See Code Examples for Android AuthScope Methods: