当前位置: 首页>>代码示例>>Java>>正文


Java AuthScope.ANY_SCHEME属性代码示例

本文整理汇总了Java中org.apache.commons.httpclient.auth.AuthScope.ANY_SCHEME属性的典型用法代码示例。如果您正苦于以下问题:Java AuthScope.ANY_SCHEME属性的具体用法?Java AuthScope.ANY_SCHEME怎么用?Java AuthScope.ANY_SCHEME使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.httpclient.auth.AuthScope的用法示例。


在下文中一共展示了AuthScope.ANY_SCHEME属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeHttpRequest

public static String makeHttpRequest(HttpMethod method, String username, String password)
{
    try
    {
        HttpClient httpClient = new HttpClient();

        AuthScope authScope = new AuthScope(method.getURI().getHost(), AuthScope.ANY_PORT, null,
                AuthScope.ANY_SCHEME);
        httpClient.getParams().setAuthenticationPreemptive(true);
        httpClient.getState().setCredentials(authScope, new UsernamePasswordCredentials(username, password));

        httpClient.executeMethod(method);
        return method.getResponseBodyAsString();
    } catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:18,代码来源:HttpSenderUtils.java

示例2: getCredentials

private Credentials getCredentials() {
	Credentials credentials = null;
	if (httpState != null) {
		if (host != null) {
			AuthScope authScope = new AuthScope(host, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME);
			credentials = httpState.getCredentials(authScope);
		}
	}
	return credentials;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:10,代码来源:HttpStateEvent.java

示例3: addAuth

@Override
public void addAuth(AuthCredentials creds) {
    String host = (StringUtils.isBlank(creds.getHost()) || "*".equals(creds.getHost())) ? AuthScope.ANY_HOST : creds.getHost();
    String realm = (StringUtils.isBlank(creds.getRealm()) || "*".equals(creds.getRealm())) ? AuthScope.ANY_REALM : creds.getRealm();
    int port = NumberUtils.toInt(creds.getPortString(), AuthScope.ANY_PORT);
    String scheme = creds.getScheme() != null ? creds.getScheme().getRepresentation() : AuthScope.ANY_SCHEME;

    Credentials defaultcreds = new UsernamePasswordCredentials(creds.getUserName(), creds.getPassword());
    httpclient.getState().setCredentials(new AuthScope(host, port, realm, scheme), defaultcreds);
}
 
开发者ID:intuit,项目名称:Tank,代码行数:10,代码来源:TankHttpClient3.java

示例4: getCommonsHttpSolrServer

public static CommonsHttpSolrServer getCommonsHttpSolrServer(JobConf job) throws MalformedURLException {
  HttpClient client=new HttpClient();

  // Check for username/password
  if (job.getBoolean(SolrConstants.USE_AUTH, false)) {
    String username = job.get(SolrConstants.USERNAME);

    LOG.info("Authenticating as: " + username);

    AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM, AuthScope.ANY_SCHEME);

    client.getState().setCredentials(scope, new UsernamePasswordCredentials(username, job.get(SolrConstants.PASSWORD)));

    HttpClientParams params = client.getParams();
    params.setAuthenticationPreemptive(true);

    client.setParams(params);
  }

  return new CommonsHttpSolrServer(job.get(SolrConstants.SERVER_URL), client);
}
 
开发者ID:yahoo,项目名称:anthelion,代码行数:21,代码来源:SolrUtils.java


注:本文中的org.apache.commons.httpclient.auth.AuthScope.ANY_SCHEME属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。