mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-26 01:09:13 -05:00
handle invalid base64 is SASl SCRAM response
This commit is contained in:
parent
e2d3bef739
commit
76889b9c58
@ -185,13 +185,17 @@ public class ScramSha1 extends SaslMechanism {
|
|||||||
state = State.RESPONSE_SENT;
|
state = State.RESPONSE_SENT;
|
||||||
return Base64.encodeToString(clientFinalMessage.getBytes(), Base64.NO_WRAP);
|
return Base64.encodeToString(clientFinalMessage.getBytes(), Base64.NO_WRAP);
|
||||||
case RESPONSE_SENT:
|
case RESPONSE_SENT:
|
||||||
|
try {
|
||||||
final String clientCalculatedServerFinalMessage = "v=" +
|
final String clientCalculatedServerFinalMessage = "v=" +
|
||||||
Base64.encodeToString(serverSignature, Base64.NO_WRAP);
|
Base64.encodeToString(serverSignature, Base64.NO_WRAP);
|
||||||
if (challenge == null || !clientCalculatedServerFinalMessage.equals(new String(Base64.decode(challenge, Base64.DEFAULT)))) {
|
if (!clientCalculatedServerFinalMessage.equals(new String(Base64.decode(challenge, Base64.DEFAULT)))) {
|
||||||
throw new AuthenticationException("Server final message does not match calculated final message");
|
throw new Exception();
|
||||||
}
|
};
|
||||||
state = State.VALID_SERVER_RESPONSE;
|
state = State.VALID_SERVER_RESPONSE;
|
||||||
return "";
|
return "";
|
||||||
|
} catch(Exception e) {
|
||||||
|
throw new AuthenticationException("Server final message does not match calculated final message");
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw new InvalidStateException(state);
|
throw new InvalidStateException(state);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user