当前位置: 首页>>代码示例>>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;未经允许,请勿转载。