本文整理汇总了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;
}
}
示例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);
}
示例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());
}
示例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());
}