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


Java BasicScheme.authenticate方法代码示例

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


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

示例1: setCredentials

import org.apache.commons.httpclient.auth.BasicScheme; //导入方法依赖的package包/类
public void setCredentials() {
	//Setting credentials for XUL
	if (this.promptUser == null) {
		this.promptUser = this.proxyUser;
	}
	if (this.promptPassword == null) {
		this.promptPassword = this.proxyPassword;
	}
	if (this.promptUser != null && this.promptPassword.length() > 0 && proxyMethod.equals(ProxyMethod.basic.name())) {
		this.basicValue = BasicScheme.authenticate(new UsernamePasswordCredentials(this.promptUser, this.promptPassword), "UTF-8");
	} else {
		this.basicValue = null;
	}	
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:15,代码来源:ProxyManager.java

示例2: setupStub

import org.apache.commons.httpclient.auth.BasicScheme; //导入方法依赖的package包/类
public static void setupStub(final @NotNull Stub stub, final @NotNull Credentials credentials, final @NotNull URI serverUri) {
  Options options = stub._getServiceClient().getOptions();

  // http params
  options.setProperty(HTTPConstants.CHUNKED, Constants.VALUE_FALSE);
  options.setProperty(HTTPConstants.MC_ACCEPT_GZIP, Boolean.TRUE);
  options.setProperty(HTTPConstants.SO_TIMEOUT, SOCKET_TIMEOUT);
  if (Registry.is("tfs.set.connection.timeout", false)) {
    options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, SOCKET_TIMEOUT);
  }

  // credentials
  if (credentials.getType() == Credentials.Type.Alternate) {
    String basicAuth =
      BasicScheme.authenticate(new UsernamePasswordCredentials(credentials.getUserName(), credentials.getPassword()), "UTF-8");
    Map<String, String> headers = new HashMap<String, String>();
    headers.put(HTTPConstants.HEADER_AUTHORIZATION, basicAuth);
    options.setProperty(HTTPConstants.HTTP_HEADERS, headers);
  }
  else {
    HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
    auth.setUsername(credentials.getUserName());
    auth.setPassword(credentials.getPassword() != null ? credentials.getPassword() : "");
    auth.setDomain(credentials.getDomain());
    auth.setHost(serverUri.getHost());
    options.setProperty(HTTPConstants.AUTHENTICATE, auth);

    HttpMethodParams params = new HttpMethodParams();
    params.setBooleanParameter(USE_NATIVE_CREDENTIALS, credentials.getType() == Credentials.Type.NtlmNative);
    options.setProperty(HTTPConstants.HTTP_METHOD_PARAMS, params);
  }

  // proxy
  final HttpTransportProperties.ProxyProperties proxyProperties;
  final HTTPProxyInfo proxy = HTTPProxyInfo.getCurrent();
  if (proxy.host != null) {
    proxyProperties = new HttpTransportProperties.ProxyProperties();
    Pair<String, String> domainAndUser = getDomainAndUser(proxy.user);
    proxyProperties.setProxyName(proxy.host);
    proxyProperties.setProxyPort(proxy.port);
    proxyProperties.setDomain(domainAndUser.first);
    proxyProperties.setUserName(domainAndUser.second);
    proxyProperties.setPassWord(proxy.password);
  }
  else {
    proxyProperties = null;
  }

  options.setProperty(HTTPConstants.PROXY, proxyProperties);
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:51,代码来源:WebServiceHelper.java

示例3: checkAuthorization

import org.apache.commons.httpclient.auth.BasicScheme; //导入方法依赖的package包/类
/**
 * Checks if the credentials provided by the client match the required
 * credentials
 * 
 * @return true if the client is authorized, false if not.
 * @param clientAuth
 */
private boolean checkAuthorization(Header clientAuth) {
    String expectedAuthString = BasicScheme.authenticate(
        (UsernamePasswordCredentials)credentials,
        "ISO-8859-1");
    return expectedAuthString.equals(clientAuth.getValue());
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:14,代码来源:ProxyAuthRequestHandler.java

示例4: checkAuthorization

import org.apache.commons.httpclient.auth.BasicScheme; //导入方法依赖的package包/类
/**
 * Checks if the credentials provided by the client match the required
 * credentials
 * 
 * @return true if the client is authorized, false if not.
 * @param clientAuth
 */
private boolean checkAuthorization(final Header clientAuth) {
    String expectedAuthString = BasicScheme.authenticate(
        (UsernamePasswordCredentials)credentials,
        "ISO-8859-1");
    return expectedAuthString.equals(clientAuth.getValue());
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:14,代码来源:AuthRequestHandler.java


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