Skip to content

Commit 9d93d08

Browse files
HDFS-16644. java.io.IOException Invalid token in javax.security.sasl.qop (#5962)
1 parent a849a4e commit 9d93d08

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/protocol/datatransfer/sasl/SaslDataTransferServer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import java.util.ArrayList;
3434
import java.util.List;
3535
import java.util.Map;
36+
import java.util.TreeMap;
3637

3738
import javax.security.auth.callback.Callback;
3839
import javax.security.auth.callback.CallbackHandler;
@@ -392,14 +393,16 @@ private IOStreamPair doSaslHandshake(Peer peer, OutputStream underlyingOut,
392393
SaslMessageWithHandshake message = readSaslMessageWithHandshakeSecret(in);
393394
byte[] secret = message.getSecret();
394395
String bpid = message.getBpid();
396+
Map<String, String> dynamicSaslProps = new TreeMap<>(saslProps);
395397
if (secret != null || bpid != null) {
396398
// sanity check, if one is null, the other must also not be null
397399
assert(secret != null && bpid != null);
398400
String qop = new String(secret, StandardCharsets.UTF_8);
399401
saslProps.put(Sasl.QOP, qop);
402+
dynamicSaslProps.put(Sasl.QOP, qop);
400403
}
401404
SaslParticipant sasl = SaslParticipant.createServerSaslParticipant(
402-
saslProps, callbackHandler);
405+
dynamicSaslProps, callbackHandler);
403406

404407
byte[] remoteResponse = message.getPayload();
405408
byte[] localResponse = sasl.evaluateChallengeOrResponse(remoteResponse);
@@ -412,7 +415,7 @@ private IOStreamPair doSaslHandshake(Peer peer, OutputStream underlyingOut,
412415
localResponse = sasl.evaluateChallengeOrResponse(remoteResponse);
413416

414417
// SASL handshake is complete
415-
checkSaslComplete(sasl, saslProps);
418+
checkSaslComplete(sasl, dynamicSaslProps);
416419

417420
CipherOption cipherOption = null;
418421
negotiatedQOP = sasl.getNegotiatedQop();

0 commit comments

Comments
 (0)