本文整理汇总了Java中org.apache.commons.httpclient.auth.MalformedChallengeException类的典型用法代码示例。如果您正苦于以下问题:Java MalformedChallengeException类的具体用法?Java MalformedChallengeException怎么用?Java MalformedChallengeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MalformedChallengeException类属于org.apache.commons.httpclient.auth包,在下文中一共展示了MalformedChallengeException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testParsingChallenge
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
public void testParsingChallenge() {
String challenge =
"Basic realm=\"realm1\", test, test1 = stuff, test2 = \"stuff, stuff\", test3=\"crap";
String scheme = null;
Map elements = null;
try {
scheme = AuthChallengeParser.extractScheme(challenge);
elements = AuthChallengeParser.extractParams(challenge);
} catch (MalformedChallengeException e) {
fail("Unexpected exception: " + e.toString());
}
assertEquals("basic", scheme);
assertEquals("realm1", elements.get("realm"));
assertEquals(null, elements.get("test"));
assertEquals("stuff", elements.get("test1"));
assertEquals("stuff, stuff", elements.get("test2"));
assertEquals("\"crap", elements.get("test3"));
}
示例2: processChallenge
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
/**
* Processes the NTLM challenge.
*
* @param challenge
* the challenge string
*
* @throws MalformedChallengeException
* is thrown if the authentication challenge is malformed
*
* @since 3.0
*/
public void processChallenge(final String challenge)
throws MalformedChallengeException {
String s = AuthChallengeParser.extractScheme(challenge);
if (!s.equalsIgnoreCase(getSchemeName())) {
throw new MalformedChallengeException("Invalid NTLM challenge: "
+ challenge);
}
int i = challenge.indexOf(' ');
if (i != -1) {
s = challenge.substring(i, challenge.length());
this.ntlmchallenge = s.trim();
this.state = TYPE2_MSG_RECEIVED;
} else {
this.ntlmchallenge = "";
if (this.state == UNINITIATED) {
this.state = INITIATED;
} else {
this.state = FAILED;
}
}
}
示例3: parseChallenge
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
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;
}
}
示例4: processChallenge
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
/**
* Processes the NTLM challenge.
*
* @param challenge
* the challenge string
*
* @throws MalformedChallengeException
* is thrown if the authentication challenge is malformed
*
* @since 3.0
*/
public void processChallenge(final String challenge) throws MalformedChallengeException {
String s = AuthChallengeParser.extractScheme(challenge);
if (!s.equalsIgnoreCase(getSchemeName())) {
throw new MalformedChallengeException("Invalid NTLM challenge: "
+ challenge);
}
int i = challenge.indexOf(' ');
if (i != -1) {
s = challenge.substring(i, challenge.length());
this.ntlmchallenge = s.trim();
this.state = TYPE2_MSG_RECEIVED;
} else {
this.ntlmchallenge = "";
if (this.state == UNINITIATED) {
this.state = INITIATED;
} else {
this.state = FAILED;
}
}
}
示例5: processChallenge
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
/**
* Processes the Bearer challenge.
*
* @param challenge The challenge string
*
* @throws MalformedChallengeException Thrown if the authentication challenge is malformed
*/
public void processChallenge(String challenge) throws MalformedChallengeException {
String s = AuthChallengeParser.extractScheme(challenge);
if (!s.equalsIgnoreCase(getSchemeName())) {
throw new MalformedChallengeException(
"Invalid " + getSchemeName() + " challenge: " + challenge);
}
mParams = AuthChallengeParser.extractParams(challenge);
mComplete = true;
}
示例6: processChallenge
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
public void processChallenge(String challenge)
throws MalformedChallengeException {
// Nothing to do here, this is not a challenge based
// auth scheme. See NTLMScheme for a good example.
}
示例7: processChallenge
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
/**
* Processes the given challenge token. Some authentication schemes
* may involve multiple challenge-response exchanges. Such schemes must be able
* to maintain the state information when dealing with sequential challenges
*
* @param authheader the challenge header
*
* @throws MalformedChallengeException is thrown if the authentication challenge
* is malformed
*/
public void processChallenge(final String authheader) throws MalformedChallengeException {
if (authheader == null) {
throw new IllegalArgumentException("Header may not be null");
}
//String authheader = header.getName();
/* TEST
if (authheader.equalsIgnoreCase(WWW_AUTH)) {
this.challengeState = ChallengeState.TARGET;
} else if (authheader.equalsIgnoreCase(PROXY_AUTH)) {
this.challengeState = ChallengeState.PROXY;
} else {
throw new MalformedChallengeException("Unexpected header name: " + authheader);
} */
CharArrayBuffer buffer;
int pos;
/* if (header instanceof FormattedHeader) {
buffer = ((FormattedHeader) header).getBuffer();
pos = ((FormattedHeader) header).getValuePos();
} else {
String s = header.getValue(); */
String s = authheader;
if (s == null) {
throw new MalformedChallengeException("Header value is null");
}
buffer = new CharArrayBuffer(s.length());
buffer.append(s);
pos = 0;
//}
while (pos < buffer.length() && EncodingUtils.isWhitespace(buffer.charAt(pos))) {
pos++;
}
int beginIndex = pos;
while (pos < buffer.length() && !EncodingUtils.isWhitespace(buffer.charAt(pos))) {
pos++;
}
int endIndex = pos;
String s2 = buffer.substring(beginIndex, endIndex);
if (!s2.equalsIgnoreCase(getSchemeName())) {
throw new MalformedChallengeException("Invalid scheme identifier: " + s2);
}
parseChallenge(buffer, pos, buffer.length());
}
示例8: parseChallenge
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
protected abstract void parseChallenge(
CharArrayBuffer buffer, int beginIndex, int endIndex) throws MalformedChallengeException;
示例9: NTLMScheme
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
public NTLMScheme(final String challenge) throws MalformedChallengeException {
super();
processChallenge(challenge);
}
示例10: processChallenge
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
@Override
public void processChallenge(String challenge) throws MalformedChallengeException {
super.processChallenge(challenge);
this.rotate = true;
}
示例11: BearerAuthScheme
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
/**
* Constructor for the basic authentication scheme.
*
* @param challenge Authentication challenge
*
* @throws MalformedChallengeException Thrown if the authentication challenge is malformed
*
* @deprecated Use parameterless constructor and {@link AuthScheme#processChallenge(String)} method
*/
public BearerAuthScheme(final String challenge) throws MalformedChallengeException {
processChallenge(challenge);
mComplete = true;
}
示例12: processChallenge
import org.apache.commons.httpclient.auth.MalformedChallengeException; //导入依赖的package包/类
/**
* Processes the NTLM challenge.
*
* @param challenge
* the challenge string
*
* @throws MalformedChallengeException
* is thrown if the authentication challenge is malformed
*
* @since 3.0
*/
public void processChallenge(final String challenge)
throws MalformedChallengeException {
String s = AuthChallengeParser.extractScheme(challenge);
if (!s.equalsIgnoreCase(getSchemeName())) {
throw new MalformedChallengeException("Invalid NTLM challenge: "
+ challenge);
}
int i = challenge.indexOf(' ');
if (i != -1) {
s = challenge.substring(i, challenge.length());
this.ntlmchallenge = s.trim();
this.state = TYPE2_MSG_RECEIVED;
} else {
this.ntlmchallenge = "";
if (this.state == UNINITIATED) {
this.state = INITIATED;
} else {
this.state = FAILED;
}
}
}