/** * Extracts a map of challenges ordered by authentication scheme name * * @param headers the array of authorization challenges * @return a map of authorization challenges * * @throws MalformedChallengeException if any of challenge strings * is malformed * * @since 3.0 */ public static Map parseChallenges(final Header[] headers) throws MalformedChallengeException { if (headers == null) { throw new IllegalArgumentException("Array of challenges may not be null"); } String challenge = null; Map challengemap = new HashMap(headers.length); for (int i = 0; i < headers.length; i++) { challenge = headers[i].getValue(); String s = AuthChallengeParser.extractScheme(challenge); challengemap.put(s, challenge); } return challengemap; } }
/** * 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; } } }
for (int i = 0; i < challenges.length; i++) { challenge = challenges[i].getValue(); String s = AuthChallengeParser.extractScheme(challenge); challengemap.put(s, challenge);
/** * 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 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 " + getSchemeName() + " challenge: " + challenge); } this.params = AuthChallengeParser.extractParams(challenge); }
/** * Extracts a map of challenges ordered by authentication scheme name * * @param headers the array of authorization challenges * @return a map of authorization challenges * * @throws MalformedChallengeException if any of challenge strings * is malformed * * @since 3.0 */ public static Map parseChallenges(final Header[] headers) throws MalformedChallengeException { if (headers == null) { throw new IllegalArgumentException("Array of challenges may not be null"); } String challenge = null; Map challengemap = new HashMap(headers.length); for (int i = 0; i < headers.length; i++) { challenge = headers[i].getValue(); String s = AuthChallengeParser.extractScheme(challenge); challengemap.put(s, challenge); } return challengemap; } }
/** * Extracts a map of challenges ordered by authentication scheme name * * @param headers the array of authorization challenges * @return a map of authorization challenges * * @throws MalformedChallengeException if any of challenge strings * is malformed * * @since 3.0 */ public static Map parseChallenges(final Header[] headers) throws MalformedChallengeException { if (headers == null) { throw new IllegalArgumentException("Array of challenges may not be null"); } String challenge = null; Map challengemap = new HashMap(headers.length); for (int i = 0; i < headers.length; i++) { challenge = headers[i].getValue(); String s = AuthChallengeParser.extractScheme(challenge); challengemap.put(s, challenge); } return challengemap; } }
/** * Extracts a map of challenges ordered by authentication scheme name * * @param headers the array of authorization challenges * @return a map of authorization challenges * * @throws MalformedChallengeException if any of challenge strings * is malformed * * @since 3.0 */ public static Map parseChallenges(final Header[] headers) throws MalformedChallengeException { if (headers == null) { throw new IllegalArgumentException("Array of challenges may not be null"); } String challenge = null; Map challengemap = new HashMap(headers.length); for (int i = 0; i < headers.length; i++) { challenge = headers[i].getValue(); String s = AuthChallengeParser.extractScheme(challenge); challengemap.put(s, challenge); } return challengemap; } }
/** * Extracts a map of challenges ordered by authentication scheme name * * @param headers the array of authorization challenges * @return a map of authorization challenges * * @throws MalformedChallengeException if any of challenge strings * is malformed * * @since 3.0 */ public static Map parseChallenges(final Header[] headers) throws MalformedChallengeException { if (headers == null) { throw new IllegalArgumentException("Array of challenges may not be null"); } String challenge = null; Map challengemap = new HashMap(headers.length); for (int i = 0; i < headers.length; i++) { challenge = headers[i].getValue(); String s = AuthChallengeParser.extractScheme(challenge); challengemap.put(s, challenge); } return challengemap; } }
/** * Processes the NTLM challenge. * * @param challenge the challenge string * @throws MalformedChallengeException is thrown if the authentication challenge is malformed */ 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()); receivedNtlmChallenge = s.trim(); authenticationState = AUTHENTICATION_STATE.TYPE2_MSG_RECEIVED; } else { receivedNtlmChallenge = null; authenticationState = authenticationState == AUTHENTICATION_STATE.UNINITIATED ? AUTHENTICATION_STATE.INITIATED : AUTHENTICATION_STATE.FAILED; } }
/** * 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; } } }
/** * 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; } } }
/** * 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; } } }
/** * 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; } } }
/** * Processes the Negotiate challenge. * * @param challenge the challenge string * @throws MalformedChallengeException is thrown if the authentication challenge is malformed */ public void processChallenge(final String challenge) throws MalformedChallengeException { String authScheme = AuthChallengeParser.extractScheme(challenge); if (!authScheme.equalsIgnoreCase(getSchemeName())) { throw new MalformedChallengeException("Invalid Negotiate challenge: " + challenge); } int spaceIndex = challenge.indexOf(' '); if (spaceIndex != -1) { // step 2: received server challenge serverToken = Base64.decodeBase64(EncodingUtil.getBytes( challenge.substring(spaceIndex, challenge.length()).trim(), "ASCII")); this.state = TYPE2_MSG_RECEIVED; } else { this.serverToken = null; if (this.state == UNINITIATED) { this.state = INITIATED; } else { this.state = FAILED; } } }
@Override public void processChallenge(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) { 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; this.challenge = challenge.substring(i, challenge.length()).trim(); } } }
/** * 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; }
/** * 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 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 " + getSchemeName() + " challenge: " + challenge); } this.params = AuthChallengeParser.extractParams(challenge); }
/** * 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 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 " + getSchemeName() + " challenge: " + challenge); } this.params = AuthChallengeParser.extractParams(challenge); }
/** * 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 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 " + getSchemeName() + " challenge: " + challenge); } this.params = AuthChallengeParser.extractParams(challenge); }
/** * 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 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 " + getSchemeName() + " challenge: " + challenge); } this.params = AuthChallengeParser.extractParams(challenge); }