From e08794f783ecb9bba0b25b39f587956e5a606bb2 Mon Sep 17 00:00:00 2001 From: Chia-Chuan Yu Date: Fri, 13 Dec 2024 19:43:23 +0800 Subject: [PATCH] Removed unneeded methods --- .../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 c79d6f5aa274..07cd635dab4f 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.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 @@ */ @InterfaceAudience.Private @InterfaceStability.Unstable -public class OzoneSecretKey implements Writable { +public class OzoneSecretKey { private int keyId; private long expiryDate; @@ -107,28 +99,6 @@ public void setExpiryDate(long expiryDate) { 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 boolean equals(Object obj) { 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); - } - }