• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BasicScheme类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



BasicScheme类属于org.apache.commons.httpclient.auth包,在下文中一共展示了BasicScheme类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: beforeTest

import org.apache.commons.httpclient.auth.BasicScheme; //导入依赖的package包/类
@Before
public void beforeTest() {
    // Now we need to use the basic authentication to send the request
    httpClient = new HttpClient();
    httpClient.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin", "admin"));
    // Use basic authentication
    scheme = new BasicScheme();

}
 
开发者ID:jboss-fuse,项目名称:fuse-karaf,代码行数:10,代码来源:CrmSecureTest.java


示例3: 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


示例4: setCredentials

import org.apache.commons.httpclient.auth.BasicScheme; //导入依赖的package包/类
private static void setCredentials(final @NotNull HttpClient httpClient,
                                   final @NotNull Credentials credentials,
                                   final @NotNull URI serverUri) {
  if (credentials.getType() == Credentials.Type.Alternate) {
    HostParams parameters = httpClient.getHostConfiguration().getParams();
    Collection<Header> headers = (Collection<Header>)parameters.getParameter(HostParams.DEFAULT_HEADERS);

    if (headers == null) {
      headers = new ArrayList<Header>();
      parameters.setParameter(HostParams.DEFAULT_HEADERS, headers);
    }

    Header authHeader = ContainerUtil.find(headers, new Condition<Header>() {
      @Override
      public boolean value(Header header) {
        return header.getName().equals(HTTPConstants.HEADER_AUTHORIZATION);
      }
    });

    if (authHeader == null) {
      authHeader = new Header(HTTPConstants.HEADER_AUTHORIZATION, "");
      headers.add(authHeader);
    }

    authHeader
      .setValue(BasicScheme.authenticate(new UsernamePasswordCredentials(credentials.getUserName(), credentials.getPassword()), "UTF-8"));
  }
  else {
    final NTCredentials ntCreds =
      new NTCredentials(credentials.getUserName(), credentials.getPassword(), serverUri.getHost(), credentials.getDomain());
    httpClient.getState().setCredentials(AuthScope.ANY, ntCreds);
    httpClient.getParams().setBooleanParameter(USE_NATIVE_CREDENTIALS, credentials.getType() == Credentials.Type.NtlmNative);
  }
}
 
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:35,代码来源:WebServiceHelper.java


示例5: 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


示例6: 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类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ActionManagerEx类代码示例发布时间:2022-05-23
下一篇:
Java JAnnotatable类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap