1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 00:59:39 +02:00

Add SCRAM-SHA1 support

Thanks to Stefan Karlsson for helping with the implementation.

Also add SASLMechanism.checkIfSuccessfulOrThrow(), to increase the
security by verifying the mechanisms state at the end of SASL
authentication.

SASLMechanism now has a SASLPrep StringTransformer.

Refactor SHA1 functions out of StringUtils into SHA1 utility class.

Add MAC utility class.

Make DummyConnection getSentpacket() methods use generics to make unit
testing SCRAM-SHA1 easier.

Fixes SMACK-398
This commit is contained in:
Florian Schmaus 2014-10-21 11:59:11 +02:00
parent 6a2bc0c02d
commit 403ecff2b2
18 changed files with 704 additions and 80 deletions

View file

@ -82,6 +82,14 @@ public class SASLDigestMD5Mechanism extends SASLMechanism {
return new SASLDigestMD5Mechanism();
}
@Override
public void checkIfSuccessfulOrThrow() throws SmackException {
if (verifyServerResponse && state != State.VALID_SERVER_RESPONSE) {
throw new SmackException(NAME + " no valid server response");
}
}
@Override
protected byte[] evaluateChallenge(byte[] challenge) throws SmackException {
if (challenge.length == 0) {

View file

@ -61,4 +61,9 @@ public class SASLExternalMechanism extends SASLMechanism {
return new SASLExternalMechanism();
}
@Override
public void checkIfSuccessfulOrThrow() throws SmackException {
// No check performed
}
}

View file

@ -54,4 +54,9 @@ public class SASLPlainMechanism extends SASLMechanism {
public SASLPlainMechanism newInstance() {
return new SASLPlainMechanism();
}
@Override
public void checkIfSuccessfulOrThrow() throws SmackException {
// No check performed
}
}