Skip to content

Commit cc0580c

Browse files
zhuzilong2013jojochuang
authored andcommitted
HDFS-16644. java.io.IOException Invalid token in javax.security.sasl.qop (#5962)
(cherry picked from commit 9d93d08)
1 parent c7d292e commit cc0580c

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
@@ -31,6 +31,7 @@
3131
import java.nio.charset.StandardCharsets;
3232
import java.util.List;
3333
import java.util.Map;
34+
import java.util.TreeMap;
3435

3536
import javax.security.auth.callback.Callback;
3637
import javax.security.auth.callback.CallbackHandler;
@@ -378,14 +379,16 @@ private IOStreamPair doSaslHandshake(Peer peer, OutputStream underlyingOut,
378379
SaslMessageWithHandshake message = readSaslMessageWithHandshakeSecret(in);
379380
byte[] secret = message.getSecret();
380381
String bpid = message.getBpid();
382+
Map<String, String> dynamicSaslProps = new TreeMap<>(saslProps);
381383
if (secret != null || bpid != null) {
382384
// sanity check, if one is null, the other must also not be null
383385
assert(secret != null && bpid != null);
384386
String qop = new String(secret, StandardCharsets.UTF_8);
385387
saslProps.put(Sasl.QOP, qop);
388+
dynamicSaslProps.put(Sasl.QOP, qop);
386389
}
387390
SaslParticipant sasl = SaslParticipant.createServerSaslParticipant(
388-
saslProps, callbackHandler);
391+
dynamicSaslProps, callbackHandler);
389392

390393
byte[] remoteResponse = message.getPayload();
391394
byte[] localResponse = sasl.evaluateChallengeOrResponse(remoteResponse);
@@ -398,7 +401,7 @@ private IOStreamPair doSaslHandshake(Peer peer, OutputStream underlyingOut,
398401
localResponse = sasl.evaluateChallengeOrResponse(remoteResponse);
399402

400403
// SASL handshake is complete
401-
checkSaslComplete(sasl, saslProps);
404+
checkSaslComplete(sasl, dynamicSaslProps);
402405

403406
CipherOption cipherOption = null;
404407
negotiatedQOP = sasl.getNegotiatedQop();

0 commit comments

Comments
 (0)