當前位置: 首頁>>代碼示例>>Java>>正文


Java UsernamePasswordCredentials類代碼示例

本文整理匯總了Java中ch.boye.httpclientandroidlib.auth.UsernamePasswordCredentials的典型用法代碼示例。如果您正苦於以下問題:Java UsernamePasswordCredentials類的具體用法?Java UsernamePasswordCredentials怎麽用?Java UsernamePasswordCredentials使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UsernamePasswordCredentials類屬於ch.boye.httpclientandroidlib.auth包,在下文中一共展示了UsernamePasswordCredentials類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setCredentials

import ch.boye.httpclientandroidlib.auth.UsernamePasswordCredentials; //導入依賴的package包/類
/**
 * @param username
 *            Use in authentication header credentials
 * @param password
 *            Use in authentication header credentials
 * @param domain
 *            NTLM authentication
 * @param workstation
 *            NTLM authentication
 */
public void setCredentials(String username, String password, String domain,
		String workstation) {
	if (username != null) {
		this.client.getCredentialsProvider().setCredentials(
				new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT,
						AuthScope.ANY_REALM, AuthPolicy.NTLM),
				new NTCredentials(username, password, workstation, domain));
		this.client.getCredentialsProvider().setCredentials(
				new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT,
						AuthScope.ANY_REALM, AuthPolicy.BASIC),
				new UsernamePasswordCredentials(username, password));
		this.client.getCredentialsProvider().setCredentials(
				new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT,
						AuthScope.ANY_REALM, AuthPolicy.DIGEST),
				new UsernamePasswordCredentials(username, password));
	}
}
 
開發者ID:starn,項目名稱:encdroidMC,代碼行數:28,代碼來源:SardineImpl.java

示例2: getCredentials

import ch.boye.httpclientandroidlib.auth.UsernamePasswordCredentials; //導入依賴的package包/類
public Credentials getCredentials(final AuthScope authscope) {
    Args.notNull(authscope, "Auth scope");
    final Credentials localcreds = internal.getCredentials(authscope);
    if (localcreds != null) {
        return localcreds;
    }
    if (authscope.getHost() != null) {
        PasswordAuthentication systemcreds = getSystemCreds(
                authscope, Authenticator.RequestorType.SERVER);
        if (systemcreds == null) {
            systemcreds = getSystemCreds(
                    authscope, Authenticator.RequestorType.PROXY);
        }
        if (systemcreds != null) {
            final String domain = System.getProperty("http.auth.ntlm.domain");
            if (domain != null) {
                return new NTCredentials(
                        systemcreds.getUserName(),
                        new String(systemcreds.getPassword()),
                        null, domain);
            } else {
                if (AuthSchemes.NTLM.equalsIgnoreCase(authscope.getScheme())) {
                    // Domian may be specified in a fully qualified user name
                    return new NTCredentials(
                            systemcreds.getUserName(),
                            new String(systemcreds.getPassword()),
                            null, null);
                } else {
                    return new UsernamePasswordCredentials(
                            systemcreds.getUserName(),
                            new String(systemcreds.getPassword()));
                }
            }
        }
    }
    return null;
}
 
開發者ID:mozilla-mobile,項目名稱:FirefoxData-android,代碼行數:38,代碼來源:SystemDefaultCredentialsProvider.java

示例3: getAuthHeader

import ch.boye.httpclientandroidlib.auth.UsernamePasswordCredentials; //導入依賴的package包/類
/**
 * Return a Header object representing an Authentication header for HTTP
 * Basic.
 */
@Override
public Header getAuthHeader(HttpRequestBase request, BasicHttpContext context, DefaultHttpClient client) {
  Credentials creds = new UsernamePasswordCredentials(credentials);

  // This must be UTF-8 to generate the same Basic Auth headers as desktop for non-ASCII passwords.
  return BasicScheme.authenticate(creds, "UTF-8", false);
}
 
開發者ID:jrconlin,項目名稱:mc_backup,代碼行數:12,代碼來源:BasicAuthHeaderProvider.java


注:本文中的ch.boye.httpclientandroidlib.auth.UsernamePasswordCredentials類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。