Skip to content

Commit

Permalink
MINOR expose dek registry apis for use by schema linking (#2809)
Browse files Browse the repository at this point in the history
* MINOR expose dek registry apis for use by schema linking

* Add helper method
  • Loading branch information
rayokota authored Oct 27, 2023
1 parent 8635bfe commit 8233b04
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public int hashCode() {
super.hashCode(), kekName, subject, algorithm, version, encryptedKeyMaterial);
}

@Override
public DataEncryptionKeyId toKey(String tenant) {
return new DataEncryptionKeyId(tenant, kekName, subject, algorithm, version);
}

public Dek toDekEntity() {
return new Dek(
kekName, subject, version, algorithm, encryptedKeyMaterial, keyMaterial, timestamp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ private Kek forwardCreateKekRequestToLeader(CreateKekRequest request,
}
}

private KeyEncryptionKey createKek(CreateKekRequest request)
public KeyEncryptionKey createKek(CreateKekRequest request)
throws SchemaRegistryException {
// Ensure cache is up-to-date
keys.sync();
Expand Down Expand Up @@ -527,7 +527,7 @@ private Dek forwardCreateDekRequestToLeader(String kekName,
}
}

private DataEncryptionKey createDek(String kekName, CreateDekRequest request)
public DataEncryptionKey createDek(String kekName, CreateDekRequest request)
throws SchemaRegistryException {
// Ensure cache is up-to-date
keys.sync();
Expand Down Expand Up @@ -650,7 +650,7 @@ private Kek forwardPutKekRequestToLeader(String name,
}
}

private KeyEncryptionKey putKek(String name, UpdateKekRequest request)
public KeyEncryptionKey putKek(String name, UpdateKekRequest request)
throws SchemaRegistryException {
// Ensure cache is up-to-date
keys.sync();
Expand Down Expand Up @@ -718,7 +718,7 @@ private void forwardDeleteKekRequestToLeader(String name, boolean permanentDelet
}
}

private void deleteKek(String name, boolean permanentDelete) throws SchemaRegistryException {
public void deleteKek(String name, boolean permanentDelete) throws SchemaRegistryException {
// Ensure cache is up-to-date
keys.sync();

Expand Down Expand Up @@ -794,7 +794,7 @@ private void forwardDeleteDekRequestToLeader(String name, String subject, DekFor
}
}

private void deleteDek(String name, String subject, DekFormat algorithm, boolean permanentDelete)
public void deleteDek(String name, String subject, DekFormat algorithm, boolean permanentDelete)
throws SchemaRegistryException {
// Ensure cache is up-to-date
keys.sync();
Expand Down Expand Up @@ -877,7 +877,7 @@ private void forwardDeleteDekVersionRequestToLeader(String name, String subject,
}
}

private void deleteDekVersion(String name, String subject, int version,
public void deleteDekVersion(String name, String subject, int version,
DekFormat algorithm, boolean permanentDelete)
throws SchemaRegistryException {
// Ensure cache is up-to-date
Expand Down Expand Up @@ -948,7 +948,7 @@ private void forwardUndeleteKekRequestToLeader(String name, Map<String, String>
}
}

private void undeleteKek(String name) throws SchemaRegistryException {
public void undeleteKek(String name) throws SchemaRegistryException {
// Ensure cache is up-to-date
keys.sync();

Expand Down Expand Up @@ -1012,7 +1012,7 @@ private void forwardUndeleteDekRequestToLeader(String name, String subject, DekF
}
}

private void undeleteDek(String name, String subject, DekFormat algorithm)
public void undeleteDek(String name, String subject, DekFormat algorithm)
throws SchemaRegistryException {
// Ensure cache is up-to-date
keys.sync();
Expand Down Expand Up @@ -1089,7 +1089,7 @@ private void forwardUndeleteDekVersionRequestToLeader(String name, String subjec
}
}

private void undeleteDekVersion(String name, String subject, int version,
public void undeleteDekVersion(String name, String subject, int version,
DekFormat algorithm) throws SchemaRegistryException {
// Ensure cache is up-to-date
keys.sync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,6 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(type, deleted);
}

public abstract EncryptionKeyId toKey(String tenant);
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ public int hashCode() {
return Objects.hash(super.hashCode(), name, kmsType, kmsKeyId, kmsProps, doc, shared);
}

@Override
public KeyEncryptionKeyId toKey(String tenant) {
return new KeyEncryptionKeyId(tenant, name);
}

public Kek toKekEntity() {
return new Kek(name, kmsType, kmsKeyId, kmsProps, doc, shared, timestamp,
deleted ? true : null);
Expand Down

0 comments on commit 8233b04

Please sign in to comment.