Refine search
int pos; if (header instanceof FormattedHeader) { buffer = ((FormattedHeader) header).getBuffer(); pos = ((FormattedHeader) header).getValuePos(); } else { String s = header.getValue(); if (s == null) { throw new MalformedChallengeException("Header value is null"); buffer = new CharArrayBuffer(s.length()); buffer.append(s); pos = 0; while (pos < buffer.length() && HTTP.isWhitespace(buffer.charAt(pos))) { pos++; while (pos < buffer.length() && !HTTP.isWhitespace(buffer.charAt(pos))) { pos++;
hcChallengeHeaders = authStrategy.getChallenges(null, response, null); } catch (MalformedChallengeException e) { logger.fine("Failed challenge parse: " + e.getMessage()); hcChallengeHeaders = new HashMap<String, Header>(); challenges.put(challenge.getKey(), challenge.getValue().getValue());
return header.getValue(); } catch (final org.apache.http.auth.AuthenticationException e) { throw new AuthenticationException("AuthenticationException", e); final String s = AuthChallengeParser.extractScheme(challenge); if (!s.equalsIgnoreCase(getSchemeName())) { throw new MalformedChallengeException("Invalid NTLM challenge: " + challenge); challengeBuffer = new CharArrayBuffer(challenge.length()); challengeBuffer.append(challenge); } else { challengeBuffer = new CharArrayBuffer(0); challengeIdx = 0;
@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 = new HashMap<String, String>(elements.length); for (HeaderElement element : elements) { this.params.put(element.getName(), element.getValue()); } }
@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; } } }
throw new MalformedChallengeException("missing realm in challange"); throw new MalformedChallengeException("missing nonce in challange"); throw new MalformedChallengeException("None of the qop methods is supported");
protected AuthScheme chooseAuthScheme(Map<String, String> challenges, String challengeHeaderKey) { HashSet<String> authSchemesLeftToTry = new HashSet<String>(challenges.keySet()); for (String authSchemeName: new String[]{"digest","basic"}) { if (authSchemesLeftToTry.remove(authSchemeName)) { AuthScheme authScheme = AUTH_SCHEME_REGISTRY.lookup(authSchemeName).create(null);; BasicHeader challenge = new BasicHeader(challengeHeaderKey, challenges.get(authSchemeName)); try { authScheme.processChallenge(challenge); } catch (MalformedChallengeException e) { logger.fine(e.getMessage() + " " + challenge); continue; } if (authScheme.isConnectionBased()) { logger.fine("Connection based " + authScheme); continue; } if (authScheme.getRealm() == null || authScheme.getRealm().length() <= 0) { logger.fine("Empty realm " + authScheme); continue; } return authScheme; } } for (String unsupportedSchemeName: authSchemesLeftToTry) { logger.fine("Unsupported http auth scheme: " + unsupportedSchemeName); } return null; }
@Override protected void parseChallenge( final CharArrayBuffer buffer, final int pos, final int len) throws MalformedChallengeException { final HeaderValueParser parser = BasicHeaderValueParser.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()); } }
@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; } } }
/** * Processes the Digest challenge. * * @param header the challenge header * * @throws MalformedChallengeException is thrown if the authentication challenge * is malformed */ @Override public void processChallenge( final Header header) throws MalformedChallengeException { super.processChallenge(header); this.complete = true; if (getParameters().isEmpty()) { throw new MalformedChallengeException("Authentication challenge is empty"); } }
protected AuthScheme chooseAuthScheme(Map<String, String> challenges, String challengeHeaderKey) { HashSet<String> authSchemesLeftToTry = new HashSet<String>(challenges.keySet()); for (String authSchemeName: new String[]{"digest","basic"}) { if (authSchemesLeftToTry.remove(authSchemeName)) { AuthScheme authScheme = AUTH_SCHEME_REGISTRY.lookup(authSchemeName).create(null);; BasicHeader challenge = new BasicHeader(challengeHeaderKey, challenges.get(authSchemeName)); try { authScheme.processChallenge(challenge); } catch (MalformedChallengeException e) { logger.fine(e.getMessage() + " " + challenge); continue; } if (authScheme.isConnectionBased()) { logger.fine("Connection based " + authScheme); continue; } if (authScheme.getRealm() == null || authScheme.getRealm().length() <= 0) { logger.fine("Empty realm " + authScheme); continue; } return authScheme; } } for (String unsupportedSchemeName: authSchemesLeftToTry) { logger.fine("Unsupported http auth scheme: " + unsupportedSchemeName); } return null; }
throw new IllegalArgumentException("Header may not be null"); String authheader = header.getName(); if (authheader.equalsIgnoreCase(AUTH.WWW_AUTH)) { this.proxy = false; this.proxy = true; } else { throw new MalformedChallengeException("Unexpected header name: " + authheader); int pos; if (header instanceof FormattedHeader) { buffer = ((FormattedHeader) header).getBuffer(); pos = ((FormattedHeader) header).getValuePos(); } else { String s = header.getValue(); if (s == null) { throw new MalformedChallengeException("Header value is null"); while (pos < buffer.length() && HTTP.isWhitespace(buffer.charAt(pos))) { pos++; while (pos < buffer.length() && !HTTP.isWhitespace(buffer.charAt(pos))) { pos++; String s = buffer.substring(beginIndex, endIndex); if (!s.equalsIgnoreCase(getSchemeName())) { throw new MalformedChallengeException("Invalid scheme identifier: " + s);
hcChallengeHeaders = authStrategy.getChallenges(null, response, null); } catch (MalformedChallengeException e) { logger.fine("Failed challenge parse: " + e.getMessage()); hcChallengeHeaders = new HashMap<String, Header>(); challenges.put(challenge.getKey(), challenge.getValue().getValue());
@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()); } }
@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; } } }
/** * Processes the Digest challenge. * * @param header the challenge header * * @throws MalformedChallengeException is thrown if the authentication challenge * is malformed */ @Override public void processChallenge( final Header header) throws MalformedChallengeException { super.processChallenge(header); this.complete = true; if (getParameters().isEmpty()) { throw new MalformedChallengeException("Authentication challenge is empty"); } }
Log.w(TAG, "Malformed challenge: " + ex.getMessage());
int pos; if (header instanceof FormattedHeader) { buffer = ((FormattedHeader) header).getBuffer(); pos = ((FormattedHeader) header).getValuePos(); } else { String s = header.getValue(); if (s == null) { throw new MalformedChallengeException("Header value is null"); buffer = new CharArrayBuffer(s.length()); buffer.append(s); pos = 0; while (pos < buffer.length() && HTTP.isWhitespace(buffer.charAt(pos))) { pos++; while (pos < buffer.length() && !HTTP.isWhitespace(buffer.charAt(pos))) { pos++;
@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 = new HashMap<String, String>(elements.length); for (HeaderElement element : elements) { this.params.put(element.getName(), element.getValue()); } }
@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; } } }