This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new dae388b7ee HDDS-11907. OzoneSecretKey does not need to implement
Writable (#7574)
dae388b7ee is described below
commit dae388b7eeb57dbe67e29286e15920cc5fff85ac
Author: Chia-Chuan Yu <[email protected]>
AuthorDate: Tue Dec 17 16:13:39 2024 +0800
HDDS-11907. OzoneSecretKey does not need to implement Writable (#7574)
---
.../hadoop/hdds/security/OzoneSecretKey.java | 53 +---------------------
1 file changed, 1 insertion(+), 52 deletions(-)
diff --git
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/OzoneSecretKey.java
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/OzoneSecretKey.java
index c79d6f5aa2..07cd635dab 100644
---
a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/OzoneSecretKey.java
+++
b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/OzoneSecretKey.java
@@ -17,12 +17,6 @@
package org.apache.hadoop.hdds.security;
import com.google.common.base.Preconditions;
-import com.google.protobuf.ByteString;
-import java.io.ByteArrayInputStream;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.DataOutput;
-import java.io.IOException;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
@@ -32,8 +26,6 @@ import org.apache.hadoop.hdds.annotation.InterfaceAudience;
import org.apache.hadoop.hdds.annotation.InterfaceStability;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.security.x509.keys.SecurityUtil;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.hdds.protocol.proto.HddsProtos.SecretKeyProto;
/**
* Wrapper class for Ozone/Hdds secret keys. Used in delegation tokens and
block
@@ -41,7 +33,7 @@ import
org.apache.hadoop.hdds.protocol.proto.HddsProtos.SecretKeyProto;
*/
@InterfaceAudience.Private
@InterfaceStability.Unstable
-public class OzoneSecretKey implements Writable {
+public class OzoneSecretKey {
private int keyId;
private long expiryDate;
@@ -107,28 +99,6 @@ public class OzoneSecretKey implements Writable {
this.expiryDate = expiryDate;
}
- @Override
- public void write(DataOutput out) throws IOException {
- SecretKeyProto token = SecretKeyProto.newBuilder()
- .setKeyId(getKeyId())
- .setExpiryDate(getExpiryDate())
- .setPrivateKeyBytes(ByteString.copyFrom(getEncodedPrivateKey()))
- .setPublicKeyBytes(ByteString.copyFrom(getEncodedPubliceKey()))
- .build();
- out.write(token.toByteArray());
- }
-
- @Override
- public void readFields(DataInput in) throws IOException {
- SecretKeyProto secretKey = SecretKeyProto.parseFrom((DataInputStream) in);
- expiryDate = secretKey.getExpiryDate();
- keyId = secretKey.getKeyId();
- privateKey = SecurityUtil.getPrivateKey(secretKey.getPrivateKeyBytes()
- .toByteArray(), securityConfig);
- publicKey = SecurityUtil.getPublicKey(secretKey.getPublicKeyBytes()
- .toByteArray(), securityConfig);
- }
-
@Override
public int hashCode() {
HashCodeBuilder hashCodeBuilder = new HashCodeBuilder(537, 963);
@@ -158,25 +128,4 @@ public class OzoneSecretKey implements Writable {
return false;
}
- /**
- * Reads protobuf encoded input stream to construct {@link OzoneSecretKey}.
- */
- static OzoneSecretKey readProtoBuf(DataInput in) throws IOException {
- Preconditions.checkNotNull(in);
- SecretKeyProto key = SecretKeyProto.parseFrom((DataInputStream) in);
- return new OzoneSecretKey(key.getKeyId(), key.getExpiryDate(),
- key.getPrivateKeyBytes().toByteArray(),
- key.getPublicKeyBytes().toByteArray());
- }
-
- /**
- * Reads protobuf encoded input stream to construct {@link OzoneSecretKey}.
- */
- static OzoneSecretKey readProtoBuf(byte[] identifier) throws IOException {
- Preconditions.checkNotNull(identifier);
- DataInputStream in = new DataInputStream(new ByteArrayInputStream(
- identifier));
- return readProtoBuf(in);
- }
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]