@Override public void evaluateRequest(final HttpServerRequest request) throws HttpAuthenticationException { List<String> authorizationValues = request.getRequestHeaderValues(AUTHORIZATION); if (authorizationValues != null) { for (String current : authorizationValues) { if (current.startsWith(CHALLENGE_PREFIX)) { byte[] rawHeader = current.substring(CHALLENGE_PREFIX.length()).getBytes(UTF_8); try { HashMap<String, byte[]> responseTokens = parseResponse(rawHeader, UTF_8, false, httpDigest); validateResponse(responseTokens, request); return; } catch (AuthenticationMechanismException e) { httpDigest.trace("Failed to parse or validate the response", e); request.badRequest(e.toHttpAuthenticationException(), response -> prepareResponse(selectRealm(), response, false)); return; } } } } request.noAuthenticationInProgress(response -> prepareResponse(selectRealm(), response, false)); }
int i = skipWhiteSpace(challenge, 0); i = skipWhiteSpace(challenge, i + 1); else if (isWhiteSpace(b)) { i = skipWhiteSpace(challenge, i + 1); else if (isWhiteSpace(b) || b == ',') { realmNumber = addToParsedChallenge(response, key, value, realmNumber); key = new StringBuilder(); value = new ByteStringBuilder(); i = skipWhiteSpace(challenge, i); if (i < challenge.length && challenge[i] == ',') { expectSeparator = false; addToParsedChallenge(response, key, value, realmNumber);
); if (password != null) { passwordChars = getTwoWayPasswordChars(password, passwordFactoryProviders, log); return userRealmPasswordDigest(messageDigest, username, realm, passwordChars);
@Override boolean verify(char[] guess) throws InvalidKeyException { try { byte[] guessDigest = userRealmPasswordDigest(getMessageDigest(algorithm), username, realm, guess); return Arrays.equals(digest, guessDigest); } catch (NoSuchAlgorithmException e) { throw log.invalidKeyNoSuchMessageDigestAlgorithm(algorithm); } }
private static int skipWhiteSpace(byte[] buffer, int startPoint) { int i = startPoint; while (i < buffer.length && isWhiteSpace(buffer[i])) { i++; } return i; }
DigestPasswordImpl(final String algorithm, final char[] password, final DigestPasswordAlgorithmSpec spec) throws InvalidKeySpecException { this.algorithm = algorithm; this.username = spec.getUsername(); this.realm = spec.getRealm(); try { this.digest = userRealmPasswordDigest(getMessageDigest(algorithm), spec.getUsername(), spec.getRealm(), password); } catch (NoSuchAlgorithmException e) { throw log.invalidKeySpecNoSuchMessageDigestAlgorithm(algorithm); } }
private static int skipWhiteSpace(byte[] buffer, int startPoint) { int i = startPoint; while (i < buffer.length && isWhiteSpace(buffer[i])) { i++; } return i; }
int i = skipWhiteSpace(challenge, 0); i = skipWhiteSpace(challenge, i + 1); else if (isWhiteSpace(b)) { i = skipWhiteSpace(challenge, i + 1); else if (isWhiteSpace(b) || b == ',') { realmNumber = addToParsedChallenge(response, key, value, realmNumber); key = new StringBuilder(); value = new ByteStringBuilder(); i = skipWhiteSpace(challenge, i); if (i < challenge.length && challenge[i] == ',') { expectSeparator = false; addToParsedChallenge(response, key, value, realmNumber);
@Override protected byte[] evaluateMessage(int state, final byte[] message) throws SaslException { HashMap<String, byte[]> parsedChallenge; try { parsedChallenge = parseResponse(message, charset, true, saslDigest); } catch (AuthenticationMechanismException e) { throw e.toSaslException(); } while(true) { switch (state) { case STEP_TWO: noteChallengeData(parsedChallenge); setNegotiationState(STEP_FOUR); return createResponse(parsedChallenge); case STEP_FOUR: if (parsedChallenge.containsKey("nonce")) { saslDigest.trace("Server requested re-authentication"); state = STEP_TWO; continue; } checkResponseAuth(parsedChallenge); negotiationComplete(); return null; } throw Assert.impossibleSwitchCase(state); } } }
); if (password != null) { passwordChars = getTwoWayPasswordChars(password, passwordFactoryProviders, log); return userRealmPasswordDigest(messageDigest, username, realm, passwordChars);
throw log.mechNoPasswordGiven(); byte[] digest_urp = userRealmPasswordDigest(messageDigest, username, realm, passwordChars); Arrays.fill(passwordChars, (char) 0); return digest_urp;
private static int skipWhiteSpace(byte[] buffer, int startPoint) { int i = startPoint; while (i < buffer.length && isWhiteSpace(buffer[i])) { i++; } return i; }
int i = skipWhiteSpace(challenge, 0); i = skipWhiteSpace(challenge, i + 1); else if (isWhiteSpace(b)) { i = skipWhiteSpace(challenge, i + 1); else if (isWhiteSpace(b) || b == ',') { realmNumber = addToParsedChallenge(response, key, value, realmNumber); key = new StringBuilder(); value = new ByteStringBuilder(); i = skipWhiteSpace(challenge, i); if (i < challenge.length && challenge[i] == ',') { expectSeparator = false; addToParsedChallenge(response, key, value, realmNumber);
@Override protected byte[] evaluateMessage(int state, final byte[] message) throws SaslException { switch (state) { case STEP_ONE: if (message != null && message.length != 0) { throw saslDigest.mechInitialChallengeMustBeEmpty().toSaslException(); } setNegotiationState(STEP_THREE); return generateChallenge(); case STEP_THREE: if (message == null || message.length == 0) { throw saslDigest.mechClientRefusesToInitiateAuthentication().toSaslException(); } // parse digest response HashMap<String, byte[]> parsedDigestResponse; try { parsedDigestResponse = parseResponse(message, charset, false, saslDigest); } catch (AuthenticationMechanismException e) { throw e.toSaslException(); } noteDigestResponseData(parsedDigestResponse); // validate byte[] response = validateDigestResponse(parsedDigestResponse); negotiationComplete(); return response; } throw Assert.impossibleSwitchCase(state); }
); if (password != null) { passwordChars = getTwoWayPasswordChars(password, passwordFactoryProviders, log); return userRealmPasswordDigest(messageDigest, username, realm, passwordChars);
@Override boolean verify(char[] guess) throws InvalidKeyException { try { byte[] guessDigest = userRealmPasswordDigest(getMessageDigest(algorithm), username, realm, guess); return Arrays.equals(digest, guessDigest); } catch (NoSuchAlgorithmException e) { throw log.invalidKeyNoSuchMessageDigestAlgorithm(algorithm); } }
private static int skipWhiteSpace(byte[] buffer, int startPoint) { int i = startPoint; while (i < buffer.length && isWhiteSpace(buffer[i])) { i++; } return i; }
int i = skipWhiteSpace(challenge, 0); i = skipWhiteSpace(challenge, i + 1); else if (isWhiteSpace(b)) { i = skipWhiteSpace(challenge, i + 1); else if (isWhiteSpace(b) || b == ',') { realmNumber = addToParsedChallenge(response, key, value, realmNumber); key = new StringBuilder(); value = new ByteStringBuilder(); i = skipWhiteSpace(challenge, i); if (i < challenge.length && challenge[i] == ',') { expectSeparator = false; addToParsedChallenge(response, key, value, realmNumber);
@Override public void evaluateRequest(final HttpServerRequest request) throws HttpAuthenticationException { List<String> authorizationValues = request.getRequestHeaderValues(AUTHORIZATION); if (authorizationValues != null) { for (String current : authorizationValues) { if (current.startsWith(CHALLENGE_PREFIX)) { byte[] rawHeader = current.substring(CHALLENGE_PREFIX.length()).getBytes(UTF_8); try { HashMap<String, byte[]> responseTokens = parseResponse(rawHeader, UTF_8, false, httpDigest); validateResponse(responseTokens, request); return; } catch (AuthenticationMechanismException e) { httpDigest.trace("Failed to parse or validate the response", e); request.badRequest(e.toHttpAuthenticationException(), response -> prepareResponse(selectRealm(), response, false)); return; } } } } request.noAuthenticationInProgress(response -> prepareResponse(selectRealm(), response, false)); }
); if (password != null) { passwordChars = getTwoWayPasswordChars(password, passwordFactoryProviders, log); return userRealmPasswordDigest(messageDigest, username, realm, passwordChars);