* @param challenge the challenge string
* @since 3.0
*/
public void processChallenge(final String challenge) throws MalformedChallengeException {
if (challenge == null) {
throw new MalformedChallengeException("Null challenge");
}
String[] tokens = challenge.trim().split("\\s+");
if (!tokens[0].equalsIgnoreCase(CHALLENGE)) {
LOGGER.log(Level.WARNING, "Received malformed challenge: \"{0}\"", challenge);
throw new MalformedChallengeException(challenge);
}
switch (tokens.length) {
case 1:
LOGGER.log(Level.INFO, "Received initial \"{0}\" challenge", CHALLENGE);
serverToken = new byte[0];
break;
case 2:
LOGGER.log(Level.INFO, "Received \"{0}\" challenge with token \"{1}\"", new String[]{CHALLENGE, tokens[1]});
serverToken = BASE64_CODEC.decode(tokens[1].getBytes());
break;
default:
LOGGER.log(Level.WARNING, "Received malformed challenge: \"{0}\"", challenge);
throw new MalformedChallengeException();
}
}