org.apache.commons.httpclient.auth.MalformedChallengeException Java Examples
The following examples show how to use
org.apache.commons.httpclient.auth.MalformedChallengeException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CustomNTLM2Scheme.java From httpclientAuthHelper with Apache License 2.0 | 6 votes |
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; } }
Example #2
Source File: SpnegoAuthScheme.java From elasticsearch-hadoop with Apache License 2.0 | 6 votes |
/** * Authenticating requests with SPNEGO means that a request will execute before the client is sure that the * server is mutually authenticated. This means that, at best, if mutual auth is requested, the client cannot * trust that the server is giving accurate information, or in the case that the client has already sent data, * further communication with the server should not happen. * @param returnChallenge The Negotiate challenge from the response headers of a successful executed request * @throws AuthenticationException If the response header does not allow for mutual authentication to be established. */ public void ensureMutualAuth(String returnChallenge) throws AuthenticationException { try { processChallenge(returnChallenge); } catch (MalformedChallengeException mce) { throw new AuthenticationException("Received invalid response header for mutual authentication", mce); } try { String token = getNegotiateToken(); if (!spnegoNegotiator.established() || token != null) { throw new AuthenticationException("Could not complete SPNEGO Authentication, Mutual Authentication Failed"); } } catch (GSSException gsse) { throw new AuthenticationException("Could not complete SPNEGO Authentication", gsse); } }
Example #3
Source File: LenientBasicScheme.java From davmail with GNU General Public License v2.0 | 5 votes |
public void processChallenge(String challenge) throws MalformedChallengeException { if ("Basic".equalsIgnoreCase(challenge)) { super.processChallenge("Basic \"default\""); } else { super.processChallenge(challenge); } }
Example #4
Source File: SpnegoAuthScheme.java From elasticsearch-hadoop with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} * <p> * Called using the challenge text parsed from the header that is associated with this scheme's name. * May advance the authentication process across multiple calls. * </p> */ @Override public void processChallenge(String challenge) throws MalformedChallengeException { // Parse Challenge Data // Challenge is base64 string to be given to gss context if (StringUtils.hasText(challenge)) { // Remove leading auth scheme name and trim data this.challenge = challenge.substring(EsHadoopAuthPolicies.NEGOTIATE.length()).trim(); } }
Example #5
Source File: CustomNTLM2SchemeBase.java From httpclientAuthHelper with Apache License 2.0 | 4 votes |
/** * 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()); }
Example #6
Source File: CustomNTLM2SchemeBase.java From httpclientAuthHelper with Apache License 2.0 | 4 votes |
protected abstract void parseChallenge( CharArrayBuffer buffer, int beginIndex, int endIndex) throws MalformedChallengeException;
Example #7
Source File: Http3SignatureAuthScheme.java From httpsig-java with The Unlicense | 4 votes |
@Override public void processChallenge(String challenge) throws MalformedChallengeException { super.processChallenge(challenge); this.rotate = true; }
Example #8
Source File: JCIFS_NTLMScheme.java From RestServices with Apache License 2.0 | 2 votes |
/** * 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; } } }
Example #9
Source File: EsApiKeyAuthScheme.java From elasticsearch-hadoop with Apache License 2.0 | 2 votes |
/** * {@inheritDoc} * <p> * Called using the challenge text parsed from the header that is associated with this scheme's name. * </p> */ @Override public void processChallenge(String challenge) throws MalformedChallengeException { complete = true; }