當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。