Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Conflict Resolution (from 7.5.x to 7.6.x) #3165

Merged
merged 7 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ public static QualifiedSubject create(String tenant, String qualifiedSubject) {
}
}

public static QualifiedSubject createFromUnqualified(String tenant, String unqualifiedSubject) {
try {
if (unqualifiedSubject == null) {
return null;
}
String qualifiedSubject = DEFAULT_TENANT.equals(tenant)
? unqualifiedSubject
: tenant + TENANT_DELIMITER + unqualifiedSubject;
return new QualifiedSubject(tenant, qualifiedSubject);
} catch (IllegalArgumentException e) {
return null;
}
}

public static String contextFor(String tenant, String qualifiedSubject) {
QualifiedSubject qs = QualifiedSubject.create(tenant, qualifiedSubject);
return qs != null ? qs.getContext() : DEFAULT_CONTEXT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import io.confluent.kafka.schemaregistry.encryption.tink.DekFormat;
import io.confluent.dekregistry.client.rest.entities.KeyType;
import io.confluent.kafka.schemaregistry.utils.QualifiedSubject;
import java.util.Objects;

@JsonInclude(Include.NON_NULL)
Expand Down Expand Up @@ -119,7 +120,11 @@ public int compareTo(EncryptionKeyId o) {
} else if (that.getSubject() == null) {
return 1;
} else {
int subjectComparison = this.getSubject().compareTo(that.getSubject());
QualifiedSubject qs1 = QualifiedSubject.createFromUnqualified(
this.getTenant(), this.getSubject());
QualifiedSubject qs2 = QualifiedSubject.createFromUnqualified(
that.getTenant(), that.getSubject());
int subjectComparison = qs1.compareTo(qs2);
if (subjectComparison != 0) {
return subjectComparison < 0 ? -1 : 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

package io.confluent.dekregistry.storage;

import static io.confluent.kafka.schemaregistry.utils.QualifiedSubject.CONTEXT_DELIMITER;
import static io.confluent.kafka.schemaregistry.utils.QualifiedSubject.CONTEXT_PREFIX;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.collect.Multimaps;
Expand Down Expand Up @@ -98,6 +101,8 @@ public class DekRegistry implements Closeable {

private static final Logger log = LoggerFactory.getLogger(DekRegistry.class);

public static final String KEY = "dekRegistry";

public static final int LATEST_VERSION = DekRegistryClient.LATEST_VERSION;
public static final int MIN_VERSION = 1;
public static final byte[] EMPTY_AAD = new byte[0];
Expand Down Expand Up @@ -137,6 +142,7 @@ public DekRegistry(
) {
try {
this.schemaRegistry = (KafkaSchemaRegistry) schemaRegistry;
this.schemaRegistry.properties().put(KEY, this);
this.schemaRegistry.addUpdateRequestHandler(new EncryptionUpdateRequestHandler());
this.metricsManager = metricsManager;
this.config = new DekRegistryConfig(schemaRegistry.config().originalProperties());
Expand Down Expand Up @@ -355,10 +361,10 @@ protected List<KeyValue<EncryptionKeyId, EncryptionKey>> getDeks(
String maxKekName = kekName != null ? kekName : String.valueOf(Character.MAX_VALUE);
List<KeyValue<EncryptionKeyId, EncryptionKey>> result = new ArrayList<>();
DataEncryptionKeyId key1 = new DataEncryptionKeyId(
tenant, minKekName, String.valueOf(Character.MIN_VALUE),
tenant, minKekName, CONTEXT_PREFIX + CONTEXT_DELIMITER,
DekFormat.AES128_GCM, MIN_VERSION);
DataEncryptionKeyId key2 = new DataEncryptionKeyId(
tenant, maxKekName, String.valueOf(Character.MAX_VALUE),
tenant, maxKekName, CONTEXT_PREFIX + Character.MAX_VALUE + CONTEXT_DELIMITER,
DekFormat.AES256_SIV, Integer.MAX_VALUE);
try (KeyValueIterator<EncryptionKeyId, EncryptionKey> iter =
keys().range(key1, true, key2, false)) {
Expand Down