|
19 | 19 |
|
20 | 20 | import java.io.IOException; |
21 | 21 | import java.security.KeyException; |
22 | | -import java.util.ArrayList; |
23 | 22 | import java.util.List; |
24 | | -import org.apache.commons.lang3.NotImplementedException; |
25 | 23 | import org.apache.hadoop.hbase.client.Connection; |
26 | 24 | import org.apache.hadoop.hbase.io.crypto.ManagedKeyData; |
27 | | -import org.apache.hadoop.hbase.io.crypto.ManagedKeyState; |
28 | 25 | import org.apache.yetus.audience.InterfaceAudience; |
29 | 26 |
|
30 | | -import org.apache.hbase.thirdparty.com.google.protobuf.ByteString; |
31 | | -import org.apache.hbase.thirdparty.com.google.protobuf.ServiceException; |
32 | | - |
33 | | -import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil; |
34 | | -import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.BooleanMsg; |
35 | | -import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.EmptyMsg; |
36 | | -import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.GetManagedKeysResponse; |
37 | | -import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ManagedKeyEntryRequest; |
38 | | -import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ManagedKeyRequest; |
39 | | -import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.ManagedKeyResponse; |
40 | | -import org.apache.hadoop.hbase.shaded.protobuf.generated.ManagedKeysProtos; |
41 | | - |
42 | | -@InterfaceAudience.Public |
| 27 | +/** |
| 28 | + * STUB IMPLEMENTATION - Feature not yet complete. This class will be fully implemented in |
| 29 | + * HBASE-29368 feature PR. |
| 30 | + */ |
43 | 31 | @InterfaceAudience.Private |
44 | 32 | public class KeymetaAdminClient implements KeymetaAdmin { |
45 | | - private ManagedKeysProtos.ManagedKeysService.BlockingInterface stub; |
46 | 33 |
|
47 | 34 | public KeymetaAdminClient(Connection conn) throws IOException { |
48 | | - this.stub = |
49 | | - ManagedKeysProtos.ManagedKeysService.newBlockingStub(conn.getAdmin().coprocessorService()); |
| 35 | + // Stub constructor |
50 | 36 | } |
51 | 37 |
|
52 | 38 | @Override |
53 | 39 | public ManagedKeyData enableKeyManagement(byte[] keyCust, String keyNamespace) |
54 | | - throws IOException { |
55 | | - try { |
56 | | - ManagedKeyResponse response = stub.enableKeyManagement(null, ManagedKeyRequest.newBuilder() |
57 | | - .setKeyCust(ByteString.copyFrom(keyCust)).setKeyNamespace(keyNamespace).build()); |
58 | | - return generateKeyData(response); |
59 | | - } catch (ServiceException e) { |
60 | | - throw ProtobufUtil.handleRemoteException(e); |
61 | | - } |
| 40 | + throws IOException, KeyException { |
| 41 | + throw new UnsupportedOperationException("KeymetaAdmin feature not yet implemented"); |
62 | 42 | } |
63 | 43 |
|
64 | 44 | @Override |
65 | 45 | public List<ManagedKeyData> getManagedKeys(byte[] keyCust, String keyNamespace) |
66 | 46 | throws IOException, KeyException { |
67 | | - try { |
68 | | - GetManagedKeysResponse statusResponse = |
69 | | - stub.getManagedKeys(null, ManagedKeyRequest.newBuilder() |
70 | | - .setKeyCust(ByteString.copyFrom(keyCust)).setKeyNamespace(keyNamespace).build()); |
71 | | - return generateKeyDataList(statusResponse); |
72 | | - } catch (ServiceException e) { |
73 | | - throw ProtobufUtil.handleRemoteException(e); |
74 | | - } |
| 47 | + throw new UnsupportedOperationException("KeymetaAdmin feature not yet implemented"); |
75 | 48 | } |
76 | 49 |
|
77 | 50 | @Override |
78 | 51 | public boolean rotateSTK() throws IOException { |
79 | | - try { |
80 | | - BooleanMsg response = stub.rotateSTK(null, EmptyMsg.getDefaultInstance()); |
81 | | - return response.getBoolMsg(); |
82 | | - } catch (ServiceException e) { |
83 | | - throw ProtobufUtil.handleRemoteException(e); |
84 | | - } |
| 52 | + throw new UnsupportedOperationException("KeymetaAdmin feature not yet implemented"); |
85 | 53 | } |
86 | 54 |
|
87 | 55 | @Override |
88 | 56 | public void ejectManagedKeyDataCacheEntry(byte[] keyCustodian, String keyNamespace, |
89 | 57 | String keyMetadata) throws IOException { |
90 | | - throw new NotImplementedException( |
91 | | - "ejectManagedKeyDataCacheEntry not supported in KeymetaAdminClient"); |
| 58 | + throw new UnsupportedOperationException("KeymetaAdmin feature not yet implemented"); |
92 | 59 | } |
93 | 60 |
|
94 | 61 | @Override |
95 | 62 | public void clearManagedKeyDataCache() throws IOException { |
96 | | - throw new NotImplementedException( |
97 | | - "clearManagedKeyDataCache not supported in KeymetaAdminClient"); |
| 63 | + throw new UnsupportedOperationException("KeymetaAdmin feature not yet implemented"); |
98 | 64 | } |
99 | 65 |
|
100 | 66 | @Override |
101 | 67 | public ManagedKeyData disableKeyManagement(byte[] keyCust, String keyNamespace) |
102 | 68 | throws IOException, KeyException { |
103 | | - try { |
104 | | - ManagedKeyResponse response = stub.disableKeyManagement(null, ManagedKeyRequest.newBuilder() |
105 | | - .setKeyCust(ByteString.copyFrom(keyCust)).setKeyNamespace(keyNamespace).build()); |
106 | | - return generateKeyData(response); |
107 | | - } catch (ServiceException e) { |
108 | | - throw ProtobufUtil.handleRemoteException(e); |
109 | | - } |
| 69 | + throw new UnsupportedOperationException("KeymetaAdmin feature not yet implemented"); |
110 | 70 | } |
111 | 71 |
|
112 | 72 | @Override |
113 | 73 | public ManagedKeyData disableManagedKey(byte[] keyCust, String keyNamespace, |
114 | 74 | byte[] keyMetadataHash) throws IOException, KeyException { |
115 | | - try { |
116 | | - ManagedKeyResponse response = stub.disableManagedKey(null, |
117 | | - ManagedKeyEntryRequest.newBuilder() |
118 | | - .setKeyCustNs(ManagedKeyRequest.newBuilder().setKeyCust(ByteString.copyFrom(keyCust)) |
119 | | - .setKeyNamespace(keyNamespace).build()) |
120 | | - .setKeyMetadataHash(ByteString.copyFrom(keyMetadataHash)).build()); |
121 | | - return generateKeyData(response); |
122 | | - } catch (ServiceException e) { |
123 | | - throw ProtobufUtil.handleRemoteException(e); |
124 | | - } |
| 75 | + throw new UnsupportedOperationException("KeymetaAdmin feature not yet implemented"); |
125 | 76 | } |
126 | 77 |
|
127 | 78 | @Override |
128 | 79 | public ManagedKeyData rotateManagedKey(byte[] keyCust, String keyNamespace) |
129 | 80 | throws IOException, KeyException { |
130 | | - try { |
131 | | - ManagedKeyResponse response = stub.rotateManagedKey(null, ManagedKeyRequest.newBuilder() |
132 | | - .setKeyCust(ByteString.copyFrom(keyCust)).setKeyNamespace(keyNamespace).build()); |
133 | | - return generateKeyData(response); |
134 | | - } catch (ServiceException e) { |
135 | | - throw ProtobufUtil.handleRemoteException(e); |
136 | | - } |
| 81 | + throw new UnsupportedOperationException("KeymetaAdmin feature not yet implemented"); |
137 | 82 | } |
138 | 83 |
|
139 | 84 | @Override |
140 | 85 | public void refreshManagedKeys(byte[] keyCust, String keyNamespace) |
141 | 86 | throws IOException, KeyException { |
142 | | - try { |
143 | | - stub.refreshManagedKeys(null, ManagedKeyRequest.newBuilder() |
144 | | - .setKeyCust(ByteString.copyFrom(keyCust)).setKeyNamespace(keyNamespace).build()); |
145 | | - } catch (ServiceException e) { |
146 | | - throw ProtobufUtil.handleRemoteException(e); |
147 | | - } |
148 | | - } |
149 | | - |
150 | | - private static List<ManagedKeyData> generateKeyDataList(GetManagedKeysResponse stateResponse) { |
151 | | - List<ManagedKeyData> keyStates = new ArrayList<>(); |
152 | | - for (ManagedKeyResponse state : stateResponse.getStateList()) { |
153 | | - keyStates.add(generateKeyData(state)); |
154 | | - } |
155 | | - return keyStates; |
156 | | - } |
157 | | - |
158 | | - private static ManagedKeyData generateKeyData(ManagedKeyResponse response) { |
159 | | - // Use hash-only constructor for client-side ManagedKeyData |
160 | | - byte[] keyMetadataHash = |
161 | | - response.hasKeyMetadataHash() ? response.getKeyMetadataHash().toByteArray() : null; |
162 | | - if (keyMetadataHash == null) { |
163 | | - return new ManagedKeyData(response.getKeyCust().toByteArray(), response.getKeyNamespace(), |
164 | | - ManagedKeyState.forValue((byte) response.getKeyState().getNumber())); |
165 | | - } else { |
166 | | - return new ManagedKeyData(response.getKeyCust().toByteArray(), response.getKeyNamespace(), |
167 | | - ManagedKeyState.forValue((byte) response.getKeyState().getNumber()), keyMetadataHash, |
168 | | - response.getRefreshTimestamp()); |
169 | | - } |
| 87 | + throw new UnsupportedOperationException("KeymetaAdmin feature not yet implemented"); |
170 | 88 | } |
171 | 89 | } |
0 commit comments