Skip to content

Commit

Permalink
Merge pull request #1461 from ivassile/JBEAP-20425
Browse files Browse the repository at this point in the history
ELY-2036 Support DigestSaslServer.getNegotiatedProperty() for QOP and STRENGTH
  • Loading branch information
darranl committed Nov 25, 2020
2 parents 2bc80a0 + bf001e7 commit fc25854
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Expand Up @@ -388,6 +388,7 @@ protected void createCiphersAndKeys() throws SaslException {

wrapCipher = createCipher(true);
unwrapCipher = createCipher(false);

}

protected byte[] createIntegrityKey(boolean wrap){
Expand Down
Expand Up @@ -317,10 +317,24 @@ public String getAuthorizationID() {
@Override
public Object getNegotiatedProperty(final String propName) {
assertComplete();
if (Sasl.BOUND_SERVER_NAME.equals(propName)) {
return boundServerName;
switch (propName) {
case Sasl.BOUND_SERVER_NAME:
return boundServerName;
case Sasl.MAX_BUFFER:
return Integer.toString(receivingMaxBuffSize);
case Sasl.QOP:
return qop;
case Sasl.STRENGTH:
if ("3des".equals(cipher)|| "rc4".equals(cipher)) {
return "high";
} else if ("des".equals(cipher)|| "rc4-56".equals(cipher)) {
return "medium";
} else {
return "low";
}
default:
return null;
}
return null;
}

/* (non-Javadoc)
Expand Down
Expand Up @@ -29,6 +29,7 @@
import java.util.HashMap;
import java.util.Map;

import javax.security.sasl.Sasl;
import javax.security.sasl.SaslException;
import javax.security.sasl.SaslServer;

Expand Down Expand Up @@ -285,6 +286,8 @@ public void testQopAuthConf() throws Exception {
assertEquals("rspauth=a804fda66588e2d911bbacd1b1163bc1", new String(message3, "UTF-8"));
assertTrue(server.isComplete());
assertEquals("chris", server.getAuthorizationID());
assertEquals("auth-conf", server.getNegotiatedProperty(Sasl.QOP));
assertEquals("high", server.getNegotiatedProperty(Sasl.STRENGTH));

byte[] incoming1 = CodePointIterator.ofString("13f7644f8c783501177522c1a455cb1f000100000000").hexDecode().drain();
byte[] incoming1unwrapped = server.unwrap(incoming1, 0, incoming1.length);
Expand Down

0 comments on commit fc25854

Please sign in to comment.