Skip to content

Commit a47770d

Browse files
szetszwoHexiaoqiao
authored andcommitted
Revert "HDFS-17575. SaslDataTransferClient should use SaslParticipant to create messages. (apache#6933)"
This reverts commit 7638b47.
1 parent d90d422 commit a47770d

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363
import org.apache.hadoop.security.token.SecretManager;
6464
import org.apache.hadoop.security.token.Token;
6565
import org.apache.hadoop.util.Lists;
66-
import org.apache.hadoop.util.StringUtils;
6766
import org.slf4j.Logger;
6867
import org.slf4j.LoggerFactory;
6968

@@ -85,8 +84,6 @@ public class SaslDataTransferClient {
8584
private static final Logger LOG = LoggerFactory.getLogger(
8685
SaslDataTransferClient.class);
8786

88-
private static final byte[] EMPTY_BYTE_ARRAY = {};
89-
9087
private final Configuration conf;
9188
private final AtomicBoolean fallbackToSimpleAuth;
9289
private final SaslPropertiesResolver saslPropsResolver;
@@ -522,29 +519,25 @@ private IOStreamPair doSaslHandshake(InetAddress addr,
522519
// In which case there will be no encrypted secret sent from NN.
523520
BlockTokenIdentifier blockTokenIdentifier =
524521
accessToken.decodeIdentifier();
525-
final byte[] first = sasl.evaluateChallengeOrResponse(EMPTY_BYTE_ARRAY);
526-
if (LOG.isDebugEnabled()) {
527-
LOG.info("first: {}", first == null ? null : first.length == 0 ? "<empty>"
528-
: StringUtils.byteToHexString(first));
529-
}
530522
if (blockTokenIdentifier != null) {
531523
byte[] handshakeSecret =
532524
accessToken.decodeIdentifier().getHandshakeMsg();
533525
if (handshakeSecret == null || handshakeSecret.length == 0) {
534526
LOG.debug("Handshake secret is null, "
535527
+ "sending without handshake secret.");
536-
sendSaslMessage(out, first);
528+
sendSaslMessage(out, new byte[0]);
537529
} else {
538530
LOG.debug("Sending handshake secret.");
539531
BlockTokenIdentifier identifier = new BlockTokenIdentifier();
540532
identifier.readFields(new DataInputStream(
541533
new ByteArrayInputStream(accessToken.getIdentifier())));
542534
String bpid = identifier.getBlockPoolId();
543-
sendSaslMessageHandshakeSecret(out, first, handshakeSecret, bpid);
535+
sendSaslMessageHandshakeSecret(out, new byte[0],
536+
handshakeSecret, bpid);
544537
}
545538
} else {
546539
LOG.debug("Block token id is null, sending without handshake secret.");
547-
sendSaslMessage(out, first);
540+
sendSaslMessage(out, new byte[0]);
548541
}
549542

550543
// step 1
@@ -572,7 +565,6 @@ private IOStreamPair doSaslHandshake(InetAddress addr,
572565
cipherOptions.add(option);
573566
}
574567
}
575-
LOG.debug("{}: cipherOptions={}", sasl, cipherOptions);
576568
sendSaslMessageAndNegotiationCipherOptions(out, localResponse,
577569
cipherOptions);
578570

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.io.DataInputStream;
2121
import java.io.DataOutputStream;
2222
import java.util.Map;
23-
import java.util.Objects;
2423
import javax.security.auth.callback.CallbackHandler;
2524
import javax.security.sasl.Sasl;
2625
import javax.security.sasl.SaslClient;
@@ -111,7 +110,7 @@ public static SaslParticipant createClientSaslParticipant(String userName,
111110
* @param saslServer to wrap
112111
*/
113112
private SaslParticipant(SaslServer saslServer) {
114-
this.saslServer = Objects.requireNonNull(saslServer, "saslServer == null");
113+
this.saslServer = saslServer;
115114
this.saslClient = null;
116115
}
117116

@@ -122,7 +121,7 @@ private SaslParticipant(SaslServer saslServer) {
122121
*/
123122
private SaslParticipant(SaslClient saslClient) {
124123
this.saslServer = null;
125-
this.saslClient = Objects.requireNonNull(saslClient, "saslClient == null");
124+
this.saslClient = saslClient;
126125
}
127126

128127
/**
@@ -229,9 +228,4 @@ public IOStreamPair createStreamPair(DataOutputStream out,
229228
new SaslOutputStream(out, saslServer));
230229
}
231230
}
232-
233-
@Override
234-
public String toString() {
235-
return "Sasl" + (saslServer != null? "Server" : "Client");
236-
}
237231
}

0 commit comments

Comments
 (0)