本文整理汇总了Java中org.apache.http.auth.MalformedChallengeException类的典型用法代码示例。如果您正苦于以下问题:Java MalformedChallengeException类的具体用法?Java MalformedChallengeException怎么用?Java MalformedChallengeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MalformedChallengeException类属于org.apache.http.auth包,在下文中一共展示了MalformedChallengeException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseChallenge
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
protected void parseChallenge(
final CharArrayBuffer buffer,
int beginIndex,
int endIndex ) throws MalformedChallengeException {
String challenge = buffer.substringTrimmed(beginIndex, endIndex);
if (log.isDebugEnabled()) {
log.debug("Received challenge '" + challenge + "' from the auth server");
}
if (state == State.UNINITIATED) {
token = base64codec.decode(challenge.getBytes());
state = State.CHALLENGE_RECEIVED;
} else {
log.debug("Authentication already attempted");
state = State.FAILED;
}
}
开发者ID:Axway,项目名称:ats-framework,代码行数:19,代码来源:GGSSchemeBase.java
示例2: parseChallenge
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
protected void parseChallenge(
final CharArrayBuffer buffer,
int beginIndex, int endIndex) throws MalformedChallengeException {
String challenge = buffer.substringTrimmed(beginIndex, endIndex);
if (challenge.length() == 0) {
if (this.state == State.UNINITIATED) {
this.state = State.CHALLENGE_RECEIVED;
} else {
this.state = State.FAILED;
}
this.challenge = null;
} else {
this.state = State.MSG_TYPE2_RECEVIED;
this.challenge = challenge;
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:NTLMScheme.java
示例3: parseChallenge
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
protected void parseChallenge(
final CharArrayBuffer buffer,
int beginIndex, int endIndex) throws MalformedChallengeException {
String challenge = buffer.substringTrimmed(beginIndex, endIndex);
if (log.isDebugEnabled()) {
log.debug("Received challenge '" + challenge + "' from the auth server");
}
if (state == State.UNINITIATED) {
token = base64codec.decode(challenge.getBytes());
state = State.CHALLENGE_RECEIVED;
} else {
log.debug("Authentication already attempted");
state = State.FAILED;
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:GGSSchemeBase.java
示例4: parseChallenge
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
protected void parseChallenge(
final CharArrayBuffer buffer,
final int beginIndex, final int endIndex) throws MalformedChallengeException {
this.challenge = buffer.substringTrimmed(beginIndex, endIndex);
if (this.challenge.length() == 0) {
if (this.state == State.UNINITIATED) {
this.state = State.CHALLENGE_RECEIVED;
} else {
this.state = State.FAILED;
}
} else {
if (this.state.compareTo(State.MSG_TYPE1_GENERATED) < 0) {
this.state = State.FAILED;
throw new MalformedChallengeException("Out of sequence NTLM response message");
} else if (this.state == State.MSG_TYPE1_GENERATED) {
this.state = State.MSG_TYPE2_RECEVIED;
}
}
}
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:21,代码来源:NTLMSchemeHC4.java
示例5: parseChallenge
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
protected void parseChallenge(
final CharArrayBuffer buffer,
final int beginIndex, final int endIndex) throws MalformedChallengeException {
this.challenge = buffer.substringTrimmed(beginIndex, endIndex);
if (this.challenge.isEmpty()) {
if (this.state == State.UNINITIATED) {
this.state = State.CHALLENGE_RECEIVED;
} else {
this.state = State.FAILED;
}
} else {
if (this.state.compareTo(State.MSG_TYPE1_GENERATED) < 0) {
this.state = State.FAILED;
throw new MalformedChallengeException("Out of sequence NTLM response message");
} else if (this.state == State.MSG_TYPE1_GENERATED) {
this.state = State.MSG_TYPE2_RECEVIED;
}
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:21,代码来源:NTLMScheme.java
示例6: parseChallenge
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
protected void parseChallenge(
final CharArrayBuffer buffer,
final int beginIndex, final int endIndex) throws MalformedChallengeException {
final String challenge = buffer.substringTrimmed(beginIndex, endIndex);
if (log.isDebugEnabled()) {
log.debug("Received challenge '" + challenge + "' from the auth server");
}
if (state == State.UNINITIATED) {
token = Base64.decodeBase64(challenge.getBytes());
state = State.CHALLENGE_RECEIVED;
} else {
log.debug("Authentication already attempted");
state = State.FAILED;
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:GGSSchemeBase.java
示例7: testAuthenticationException
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Test
public void testAuthenticationException() throws Exception {
final HttpHost host = new HttpHost("somehost", 80);
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_UNAUTHORIZED, "UNAUTHORIZED");
this.authState.setState(AuthProtocolState.CHALLENGED);
Mockito.doThrow(new MalformedChallengeException()).when(this.defltAuthStrategy).getChallenges(
Mockito.any(HttpHost.class),
Mockito.any(HttpResponse.class),
Mockito.any(HttpContext.class));
Assert.assertFalse(this.httpAuthenticator.handleAuthChallenge(host,
response, this.defltAuthStrategy, this.authState, this.context));
Assert.assertEquals(AuthProtocolState.UNCHALLENGED, this.authState.getState());
Assert.assertNull(this.authState.getAuthScheme());
Assert.assertNull(this.authState.getCredentials());
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:20,代码来源:TestHttpAuthenticator.java
示例8: parseChallenge
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
protected void parseChallenge(
final CharArrayBuffer buffer,
final int beginIndex,
final int endIndex) throws MalformedChallengeException {
this.challenge = buffer.substringTrimmed(beginIndex, endIndex);
if (this.challenge.isEmpty()) {
if (clientCred != null) {
dispose(); // run cleanup first before throwing an exception otherwise can leak OS resources
if (continueNeeded) {
throw new RuntimeException("Unexpected token");
}
}
}
}
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:17,代码来源:WindowsNegotiateScheme.java
示例9: select
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
public Queue<AuthOption> select(final Map<String, Header> challengeHeaders,
final HttpHost authhost,
final HttpResponse response,
final HttpContext context)
throws MalformedChallengeException {
final HttpClientContext httpClientContext = HttpClientContext.adapt(context);
final AuthState state = httpClientContext.getTargetAuthState();
final Queue<AuthOption> queue = new LinkedList<>();
if (state == null || !state.getState().equals(AuthProtocolState.CHALLENGED)) {
queue.add(authOption);
} else {
System.out.println("does this happen?");
}
return queue;
}
开发者ID:joyent,项目名称:java-http-signature,代码行数:19,代码来源:HttpSignatureAuthenticationStrategy.java
示例10: processChallenges
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
private void processChallenges(
final Map<String, Header> challenges,
final AuthState authState,
final AuthenticationHandler authHandler,
final HttpResponse response,
final HttpContext context)
throws MalformedChallengeException, AuthenticationException {
AuthScheme authScheme = authState.getAuthScheme();
if (authScheme == null) {
// Authentication not attempted before
authScheme = authHandler.selectScheme(challenges, response, context);
authState.setAuthScheme(authScheme);
}
String id = authScheme.getSchemeName();
Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
if (challenge == null) {
throw new AuthenticationException(id +
" authorization challenge expected, but not found");
}
authScheme.processChallenge(challenge);
this.log.debug("Authorization challenge processed");
}
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:25,代码来源:DefaultRequestDirector.java
示例11: parseChallenge
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
protected void parseChallenge(
final CharArrayBuffer buffer, int pos, int len) throws MalformedChallengeException {
String challenge = buffer.substringTrimmed(pos, len);
if (challenge.length() == 0) {
if (this.state == State.UNINITIATED) {
this.state = State.CHALLENGE_RECEIVED;
} else {
this.state = State.FAILED;
}
this.challenge = null;
} else {
this.state = State.MSG_TYPE2_RECEVIED;
this.challenge = challenge;
}
}
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:17,代码来源:NTLMScheme.java
示例12: processChallenges
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
private void processChallenges(
final Map<String, Header> challenges,
final AuthState authState,
final AuthenticationHandler authHandler,
final HttpResponse response,
final HttpContext context)
throws MalformedChallengeException, AuthenticationException {
AuthScheme authScheme = authState.getAuthScheme();
if (authScheme == null) {
// Authentication not attempted before
authScheme = authHandler.selectScheme(challenges, response, context);
authState.setAuthScheme(authScheme);
}
String id = authScheme.getSchemeName();
Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
if (challenge == null) {
throw new AuthenticationException(id +
" authorization challenge expected, but not found");
}
authScheme.processChallenge(challenge);
this.log.debug("Authorization challenge processed");
}
开发者ID:tdopires,项目名称:cJUnit-mc626,代码行数:25,代码来源:DefaultRequestDirector.java
示例13: processChallenges
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
private void processChallenges(
final Map<String, Header> challenges,
final AuthState authState,
final AuthenticationHandler authHandler,
final HttpResponse response,
final HttpContext context)
throws MalformedChallengeException, AuthenticationException {
AuthScheme authScheme = authState.getAuthScheme();
if (authScheme == null) {
// Authentication not attempted before
authScheme = authHandler.selectScheme(challenges, response, context);
authState.setAuthScheme(authScheme);
}
String id = authScheme.getSchemeName();
Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
if (challenge == null) {
throw new AuthenticationException(id +
" authorization challenge expected, but not found");
}
authScheme.processChallenge(challenge);
if (DEBUG) {
Logger.debug("Authorization challenge processed");
}
}
开发者ID:cattong,项目名称:YiBo,代码行数:27,代码来源:LibRequestDirector.java
示例14: processChallenges
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
private void processChallenges(
final Map<String, Header> challenges,
final AuthState authState,
final AuthenticationHandler authHandler,
final HttpResponse response,
final HttpContext context)
throws MalformedChallengeException, AuthenticationException {
AuthScheme authScheme = authState.getAuthScheme();
if (authScheme == null) {
// Authentication not attempted before
authScheme = authHandler.selectScheme(challenges, response, context);
authState.setAuthScheme(authScheme);
}
String id = authScheme.getSchemeName();
Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
if (challenge == null) {
throw new AuthenticationException(id +
" authorization challenge expected, but not found");
}
authScheme.processChallenge(challenge);
if (Constants.DEBUG) {
logger.debug("Authorization challenge processed");
}
}
开发者ID:yibome,项目名称:yibo-library,代码行数:27,代码来源:YiBoRequestDirector.java
示例15: parseChallenge
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
protected void parseChallenge(
final CharArrayBuffer buffer, int pos, int len) throws MalformedChallengeException {
HeaderValueParser parser = BasicHeaderValueParser.DEFAULT;
ParserCursor cursor = new ParserCursor(pos, buffer.length());
HeaderElement[] elements = parser.parseElements(buffer, cursor);
if (elements.length == 0) {
throw new MalformedChallengeException("Authentication challenge is empty");
}
this.params.clear();
for (HeaderElement element : elements) {
this.params.put(element.getName(), element.getValue());
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:RFC2617Scheme.java
示例16: getChallenges
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
public Map<String, Header> getChallenges(
final HttpResponse response,
final HttpContext context) throws MalformedChallengeException {
if (response == null) {
throw new IllegalArgumentException("HTTP response may not be null");
}
Header[] headers = response.getHeaders(AUTH.WWW_AUTH);
return parseChallenges(headers);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DefaultTargetAuthenticationHandler.java
示例17: getChallenges
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
public Map<String, Header> getChallenges(
final HttpResponse response,
final HttpContext context) throws MalformedChallengeException {
if (response == null) {
throw new IllegalArgumentException("HTTP response may not be null");
}
Header[] headers = response.getHeaders(AUTH.PROXY_AUTH);
return parseChallenges(headers);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:DefaultProxyAuthenticationHandler.java
示例18: select
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
public Queue<AuthOption> select(final Map<String, Header> challenges, final HttpHost authhost, final HttpResponse response, final HttpContext context) throws MalformedChallengeException {
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final Queue<AuthOption> options = new LinkedList<AuthOption>();
final Lookup<AuthSchemeProvider> registry = clientContext.getAuthSchemeRegistry();
if(registry == null) {
return options;
}
final RequestConfig config = clientContext.getRequestConfig();
Collection<String> authPrefs = config.getProxyPreferredAuthSchemes();
if(authPrefs == null) {
authPrefs = DEFAULT_SCHEME_PRIORITY;
}
if(log.isDebugEnabled()) {
log.debug("Authentication schemes in the order of preference: " + authPrefs);
}
for(final String id : authPrefs) {
final Header challenge = challenges.get(id.toLowerCase(Locale.ROOT));
if(challenge != null) {
final AuthSchemeProvider authSchemeProvider = registry.lookup(id);
if(authSchemeProvider == null) {
continue;
}
final AuthScheme authScheme = authSchemeProvider.create(context);
authScheme.processChallenge(challenge);
final Credentials saved = keychain.getCredentials(authhost.getHostName());
if(StringUtils.isEmpty(saved.getPassword())) {
try {
final Credentials input = prompt.prompt(bookmark,
StringUtils.EMPTY,
String.format("%s %s", LocaleFactory.localizedString("Login", "Login"), authhost.getHostName()),
authScheme.getRealm(),
new LoginOptions()
.icon(bookmark.getProtocol().disk())
.usernamePlaceholder(LocaleFactory.localizedString("Username", "Credentials"))
.passwordPlaceholder(LocaleFactory.localizedString("Password", "Credentials"))
.user(true).password(true)
);
if(input.isSaved()) {
context.setAttribute(PROXY_CREDENTIALS_INPUT_ID, input);
}
options.add(new AuthOption(authScheme, new NTCredentials(input.getUsername(), input.getPassword(),
preferences.getProperty("webdav.ntlm.workstation"), preferences.getProperty("webdav.ntlm.domain"))));
}
catch(LoginCanceledException ignored) {
// Ignore dismiss of prompt
throw new MalformedChallengeException(ignored.getMessage(), ignored);
}
}
else {
options.add(new AuthOption(authScheme, new NTCredentials(saved.getUsername(), saved.getPassword(),
preferences.getProperty("webdav.ntlm.workstation"), preferences.getProperty("webdav.ntlm.domain"))));
}
}
else {
if(log.isDebugEnabled()) {
log.debug("Challenge for " + id + " authentication scheme not available");
// Try again
}
}
}
return options;
}
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:65,代码来源:CallbackProxyAuthenticationStrategy.java
示例19: parseChallenge
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
protected void parseChallenge(
final CharArrayBuffer buffer, final int pos, final int len) throws MalformedChallengeException {
final HeaderValueParser parser = BasicHeaderValueParserHC4.INSTANCE;
final ParserCursor cursor = new ParserCursor(pos, buffer.length());
final HeaderElement[] elements = parser.parseElements(buffer, cursor);
if (elements.length == 0) {
throw new MalformedChallengeException("Authentication challenge is empty");
}
this.params.clear();
for (final HeaderElement element : elements) {
this.params.put(element.getName().toLowerCase(Locale.ENGLISH), element.getValue());
}
}
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:15,代码来源:RFC2617SchemeHC4.java
示例20: select
import org.apache.http.auth.MalformedChallengeException; //导入依赖的package包/类
public Queue<AuthOption> select(
final Map<String, Header> challenges,
final HttpHost authhost,
final HttpResponse response,
final HttpContext context) throws MalformedChallengeException {
Args.notNull(challenges, "Map of auth challenges");
Args.notNull(authhost, "Host");
Args.notNull(response, "HTTP response");
Args.notNull(context, "HTTP context");
final HttpClientContext clientContext = HttpClientContext.adapt(context);
final Queue<AuthOption> options = new LinkedList<AuthOption>();
final Lookup<AuthSchemeProvider> registry = clientContext.getAuthSchemeRegistry();
if (registry == null) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Auth scheme registry not set in the context");
}
return options;
}
final CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
if (credsProvider == null) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Credentials provider not set in the context");
}
return options;
}
final RequestConfig config = clientContext.getRequestConfig();
Collection<String> authPrefs = getPreferredAuthSchemes(config);
if (authPrefs == null) {
authPrefs = DEFAULT_SCHEME_PRIORITY;
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Authentication schemes in the order of preference: " + authPrefs);
}
for (final String id: authPrefs) {
final Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
if (challenge != null) {
final AuthSchemeProvider authSchemeProvider = registry.lookup(id);
if (authSchemeProvider == null) {
if (Log.isLoggable(TAG, Log.WARN)) {
Log.w(TAG, "Authentication scheme " + id + " not supported");
// Try again
}
continue;
}
final AuthScheme authScheme = authSchemeProvider.create(context);
authScheme.processChallenge(challenge);
final AuthScope authScope = new AuthScope(
authhost.getHostName(),
authhost.getPort(),
authScheme.getRealm(),
authScheme.getSchemeName());
final Credentials credentials = credsProvider.getCredentials(authScope);
if (credentials != null) {
options.add(new AuthOption(authScheme, credentials));
}
} else {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Challenge for " + id + " authentication scheme not available");
// Try again
}
}
}
return options;
}
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:69,代码来源:AuthenticationStrategyImpl.java
注:本文中的org.apache.http.auth.MalformedChallengeException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论