本文整理汇总了Java中org.apache.commons.httpclient.auth.AuthState类的典型用法代码示例。如果您正苦于以下问题:Java AuthState类的具体用法?Java AuthState怎么用?Java AuthState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AuthState类属于org.apache.commons.httpclient.auth包,在下文中一共展示了AuthState类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: authenticateProxy
import org.apache.commons.httpclient.auth.AuthState; //导入依赖的package包/类
private void authenticateProxy(final HttpMethod method) throws AuthenticationException {
// Clean up existing authentication headers
if (!cleanAuthHeaders(method, PROXY_AUTH_RESP)) {
// User defined authentication header(s) present
return;
}
AuthState authstate = method.getProxyAuthState();
AuthScheme authscheme = authstate.getAuthScheme();
if (authscheme == null) {
return;
}
if (authstate.isAuthRequested() || !authscheme.isConnectionBased()) {
AuthScope authscope = new AuthScope(
conn.getProxyHost(), conn.getProxyPort(),
authscheme.getRealm(),
authscheme.getSchemeName());
if (LOG.isDebugEnabled()) {
LOG.debug("Authenticating with " + authscope);
}
Credentials credentials = this.state.getProxyCredentials(authscope);
if (credentials != null) {
String authstring = authscheme.authenticate(credentials, method);
if (authstring != null) {
method.addRequestHeader(new Header(PROXY_AUTH_RESP, authstring, true));
}
} else {
if (LOG.isWarnEnabled()) {
LOG.warn("Required proxy credentials not available for " + authscope);
if (method.getProxyAuthState().isPreemptive()) {
LOG.warn("Preemptive authentication requested but no default " +
"proxy credentials available");
}
}
}
}
}
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:37,代码来源:HttpMethodDirector.java
示例2: authenticateHost
import org.apache.commons.httpclient.auth.AuthState; //导入依赖的package包/类
private void authenticateHost(final HttpMethod method) throws AuthenticationException {
// Clean up existing authentication headers
if (!cleanAuthHeaders(method, WWW_AUTH_RESP)) {
// User defined authentication header(s) present
return;
}
AuthState authstate = method.getHostAuthState();
AuthScheme authscheme = authstate.getAuthScheme();
if (authscheme == null) {
return;
}
if (authstate.isAuthRequested() || !authscheme.isConnectionBased()) {
String host = method.getParams().getVirtualHost();
if (host == null) {
host = conn.getHost();
}
int port = conn.getPort();
AuthScope authscope = new AuthScope(
host, port,
authscheme.getRealm(),
authscheme.getSchemeName());
if (LOG.isDebugEnabled()) {
LOG.debug("Authenticating with " + authscope);
}
Credentials credentials = this.state.getCredentials(authscope);
if (credentials != null) {
String authstring = authscheme.authenticate(credentials, method);
if (authstring != null) {
method.addRequestHeader(new Header(WWW_AUTH_RESP, authstring, true));
}
} else {
if (LOG.isWarnEnabled()) {
LOG.warn("Required credentials not available for " + authscope);
if (method.getHostAuthState().isPreemptive()) {
LOG.warn("Preemptive authentication requested but no default " +
"credentials available");
}
}
}
}
}
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:42,代码来源:HttpMethodDirector.java
示例3: executeConnect
import org.apache.commons.httpclient.auth.AuthState; //导入依赖的package包/类
/**
* Executes a ConnectMethod to establish a tunneled connection.
*
* @return <code>true</code> if the connect was successful
*
* @throws IOException
* @throws HttpException
*/
private boolean executeConnect()
throws IOException, HttpException {
this.connectMethod = new ConnectMethod(this.hostConfiguration);
this.connectMethod.getParams().setDefaults(this.hostConfiguration.getParams());
int code;
for (;;) {
if (!this.conn.isOpen()) {
this.conn.open();
}
if (this.params.isAuthenticationPreemptive()
|| this.state.isAuthenticationPreemptive()) {
LOG.debug("Preemptively sending default basic credentials");
this.connectMethod.getProxyAuthState().setPreemptive();
this.connectMethod.getProxyAuthState().setAuthAttempted(true);
}
try {
authenticateProxy(this.connectMethod);
} catch (AuthenticationException e) {
LOG.error(e.getMessage(), e);
}
applyConnectionParams(this.connectMethod);
this.connectMethod.execute(state, this.conn);
code = this.connectMethod.getStatusCode();
boolean retry = false;
AuthState authstate = this.connectMethod.getProxyAuthState();
authstate.setAuthRequested(code == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
if (authstate.isAuthRequested()) {
if (processAuthenticationResponse(this.connectMethod)) {
retry = true;
}
}
if (!retry) {
break;
}
if (this.connectMethod.getResponseBodyAsStream() != null) {
this.connectMethod.getResponseBodyAsStream().close();
}
}
if ((code >= 200) && (code < 300)) {
this.conn.tunnelCreated();
// Drop the connect method, as it is no longer needed
this.connectMethod = null;
return true;
} else {
this.conn.close();
return false;
}
}
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:59,代码来源:HttpMethodDirector.java
示例4: executeConnect
import org.apache.commons.httpclient.auth.AuthState; //导入依赖的package包/类
/**
* Executes a ConnectMethod to establish a tunneled connection.
*
* @return <code>true</code> if the connect was successful
*
* @throws IOException
* @throws HttpException
*/
private boolean executeConnect()
throws IOException, HttpException {
this.connectMethod = new ConnectMethod();
this.connectMethod.getParams().setDefaults(this.hostConfiguration.getParams());
int code;
for (;;) {
if (!this.conn.isOpen()) {
this.conn.open();
}
if (this.params.isAuthenticationPreemptive()
|| this.state.isAuthenticationPreemptive()) {
LOG.debug("Preemptively sending default basic credentials");
this.connectMethod.getProxyAuthState().setPreemptive();
this.connectMethod.getProxyAuthState().setAuthAttempted(true);
}
try {
authenticateProxy(this.connectMethod);
} catch (AuthenticationException e) {
LOG.error(e.getMessage(), e);
}
applyConnectionParams(this.connectMethod);
this.connectMethod.execute(state, this.conn);
code = this.connectMethod.getStatusCode();
boolean retry = false;
AuthState authstate = this.connectMethod.getProxyAuthState();
authstate.setAuthRequested(code == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
if (authstate.isAuthRequested()) {
if (processAuthenticationResponse(this.connectMethod)) {
retry = true;
}
}
if (!retry) {
break;
}
if (this.connectMethod.getResponseBodyAsStream() != null) {
this.connectMethod.getResponseBodyAsStream().close();
}
}
if ((code >= 200) && (code < 300)) {
this.conn.tunnelCreated();
// Drop the connect method, as it is no longer needed
this.connectMethod = null;
return true;
} else {
return false;
}
}
开发者ID:magneticmoon,项目名称:httpclient3-ntml,代码行数:58,代码来源:HttpMethodDirector.java
示例5: getHostAuthState
import org.apache.commons.httpclient.auth.AuthState; //导入依赖的package包/类
/**
* Returns the target host {@link AuthState authentication state}
*
* @return host authentication state
*
* @since 3.0
*/
public AuthState getHostAuthState();
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:9,代码来源:HttpMethod.java
示例6: getProxyAuthState
import org.apache.commons.httpclient.auth.AuthState; //导入依赖的package包/类
/**
* Returns the proxy {@link AuthState authentication state}
*
* @return host authentication state
*
* @since 3.0
*/
public AuthState getProxyAuthState();
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:9,代码来源:HttpMethod.java
示例7: getHostAuthState
import org.apache.commons.httpclient.auth.AuthState; //导入依赖的package包/类
/**
* Returns the target host {@link AuthState authentication state}
*
* @return host authentication state
*
* @since 3.0
*/
public AuthState getHostAuthState() {
return this.hostAuthState;
}
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:11,代码来源:HttpMethodBase.java
示例8: getProxyAuthState
import org.apache.commons.httpclient.auth.AuthState; //导入依赖的package包/类
/**
* Returns the proxy {@link AuthState authentication state}
*
* @return host authentication state
*
* @since 3.0
*/
public AuthState getProxyAuthState() {
return this.proxyAuthState;
}
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:11,代码来源:HttpMethodBase.java
注:本文中的org.apache.commons.httpclient.auth.AuthState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论