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


Java BasicScheme.authenticate方法代碼示例

本文整理匯總了Java中org.apache.http.impl.auth.BasicScheme.authenticate方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicScheme.authenticate方法的具體用法?Java BasicScheme.authenticate怎麽用?Java BasicScheme.authenticate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.http.impl.auth.BasicScheme的用法示例。


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

示例1: read

import org.apache.http.impl.auth.BasicScheme; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
protected final <T> T read(ContentHandler handler) throws IOException {
    String spec = mUri.toString();
    URL url = new URL(spec);
    HttpURLConnection http = (HttpURLConnection) url.openConnection();
    try {
        String password = PasswordManager.get(mContext).getPassword(mUri.getAuthority());
        if (password != null) {
            Credentials credentials = new UsernamePasswordCredentials("", password);
            Header authorization = BasicScheme.authenticate(credentials, HTTP.UTF_8, false);
            http.setRequestProperty(authorization.getName(), authorization.getValue());
        }
        int responseCode = http.getResponseCode();
        String responseMessage = http.getResponseMessage();
        if (responseCode != HttpURLConnection.HTTP_OK) {
            throw new HttpResponseException(responseCode, responseMessage);
        }
        return (T) handler.getContent(http);
    } finally {
        http.disconnect();
    }
}
 
開發者ID:ration,項目名稱:android-vlc-remote,代碼行數:23,代碼來源:MediaServer.java

示例2: generateBasicAuthHeader

import org.apache.http.impl.auth.BasicScheme; //導入方法依賴的package包/類
protected Header generateBasicAuthHeader(HttpUriRequest request, Configuration configuration) {
    Header basicAuthHeader;
    BasicScheme basicScheme = new BasicScheme();

    try {
        basicAuthHeader = basicScheme.authenticate(
                new UsernamePasswordCredentials(configuration.getUsername(), configuration.getPassword()),
                request,
                HttpClientContext.create());
    } catch (Exception e) {
        throw new BasicAuthException(e);
    }
    return basicAuthHeader;
}
 
開發者ID:motech,項目名稱:modules,代碼行數:15,代碼來源:AbstractFormDefinitionImportService.java

示例3: generateBasicAuthHeader

import org.apache.http.impl.auth.BasicScheme; //導入方法依賴的package包/類
private Header generateBasicAuthHeader(HttpUriRequest request, Configuration configuration) {
    Header basicAuthHeader;
    BasicScheme basicScheme = new BasicScheme();
    try {
        basicAuthHeader = basicScheme.authenticate(
                new UsernamePasswordCredentials(configuration.getUsername(), configuration.getPassword()),
                request,
                HttpClientContext.create());
    } catch (Exception e) {
        throw new BasicAuthException(e);
    }
    return basicAuthHeader;
}
 
開發者ID:motech,項目名稱:modules,代碼行數:14,代碼來源:VerificationServiceImpl.java

示例4: generateBasicAuthHeader

import org.apache.http.impl.auth.BasicScheme; //導入方法依賴的package包/類
private Header generateBasicAuthHeader(HttpUriRequest request, Settings settings) {
    Header basicAuthHeader;
    BasicScheme basicScheme = new BasicScheme();
    try {
        basicAuthHeader = basicScheme.authenticate(
                new UsernamePasswordCredentials(settings.getUsername(), settings.getPassword()),
                request,
                HttpClientContext.create());
    } catch (AuthenticationException e) {
        String msg = String.format("Error generating basic auth header for request: %s", request.toString());
        statusMessageService.warn(msg, MODULE_NAME);
        throw new DhisWebException(msg, e);
    }
    return basicAuthHeader;
}
 
開發者ID:motech,項目名稱:modules,代碼行數:16,代碼來源:DhisWebServiceImpl.java

示例5: addBasicAuthenticationHeader

import org.apache.http.impl.auth.BasicScheme; //導入方法依賴的package包/類
private HttpUriRequest addBasicAuthenticationHeader(HttpUriRequest request,
		UsernamePasswordCredentials creds) {
	Header hdr = BasicScheme.authenticate(creds, "utf-8", false);
	request.addHeader(hdr);
	return request;
}
 
開發者ID:devicehive,項目名稱:android-ble,代碼行數:7,代碼來源:NetworkCommand.java

示例6: signRequest

import org.apache.http.impl.auth.BasicScheme; //導入方法依賴的package包/類
private void signRequest(HttpUriRequest request) {
    UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, signUrl(privateKey, request.getURI().toString()));
    Header basicAuthHeader = BasicScheme.authenticate(credentials, "US-ASCII", false);
    request.addHeader(basicAuthHeader);
}
 
開發者ID:smartlogic,項目名稱:smartchat-android,代碼行數:6,代碼來源:ApiClient.java


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