refactor(license): remove dead Feature enum and isEnabled scaffolding
Spec §9 — feature flags are out of scope for license enforcement. Drops Feature.java, LicenseGate.isEnabled, LicenseInfo.hasFeature, and the corresponding test cases. LicenseValidator now silently ignores any features array on the wire (no error). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
package com.cameleer.server.core.license;
|
||||
|
||||
public enum Feature {
|
||||
topology,
|
||||
lineage,
|
||||
correlation,
|
||||
debugger,
|
||||
replay
|
||||
}
|
||||
@@ -13,12 +13,8 @@ public class LicenseGate {
|
||||
|
||||
public void load(LicenseInfo license) {
|
||||
current.set(license);
|
||||
log.info("License loaded: tier={}, features={}, expires={}",
|
||||
license.tier(), license.features(), license.expiresAt());
|
||||
}
|
||||
|
||||
public boolean isEnabled(Feature feature) {
|
||||
return current.get().hasFeature(feature);
|
||||
log.info("License loaded: tier={}, limits={}, expires={}",
|
||||
license.tier(), license.limits(), license.expiresAt());
|
||||
}
|
||||
|
||||
public String getTier() {
|
||||
|
||||
@@ -2,11 +2,9 @@ package com.cameleer.server.core.license;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public record LicenseInfo(
|
||||
String tier,
|
||||
Set<Feature> features,
|
||||
Map<String, Integer> limits,
|
||||
Instant issuedAt,
|
||||
Instant expiresAt
|
||||
@@ -15,16 +13,11 @@ public record LicenseInfo(
|
||||
return expiresAt != null && Instant.now().isAfter(expiresAt);
|
||||
}
|
||||
|
||||
public boolean hasFeature(Feature feature) {
|
||||
return features.contains(feature);
|
||||
}
|
||||
|
||||
public int getLimit(String key, int defaultValue) {
|
||||
return limits.getOrDefault(key, defaultValue);
|
||||
}
|
||||
|
||||
/** Open license — all features enabled, no limits. Used when no license is configured. */
|
||||
public static LicenseInfo open() {
|
||||
return new LicenseInfo("open", Set.of(Feature.values()), Map.of(), Instant.now(), null);
|
||||
return new LicenseInfo("open", Map.of(), Instant.now(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,17 +56,6 @@ public class LicenseValidator {
|
||||
|
||||
String tier = root.get("tier").asText();
|
||||
|
||||
Set<Feature> features = new HashSet<>();
|
||||
if (root.has("features")) {
|
||||
for (JsonNode f : root.get("features")) {
|
||||
try {
|
||||
features.add(Feature.valueOf(f.asText()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.warn("Unknown feature in license: {}", f.asText());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Integer> limits = new HashMap<>();
|
||||
if (root.has("limits")) {
|
||||
root.get("limits").fields().forEachRemaining(entry ->
|
||||
@@ -76,7 +65,7 @@ public class LicenseValidator {
|
||||
Instant issuedAt = root.has("iat") ? Instant.ofEpochSecond(root.get("iat").asLong()) : Instant.now();
|
||||
Instant expiresAt = root.has("exp") ? Instant.ofEpochSecond(root.get("exp").asLong()) : null;
|
||||
|
||||
LicenseInfo info = new LicenseInfo(tier, features, limits, issuedAt, expiresAt);
|
||||
LicenseInfo info = new LicenseInfo(tier, limits, issuedAt, expiresAt);
|
||||
|
||||
if (info.isExpired()) {
|
||||
throw new IllegalArgumentException("License expired at " + expiresAt);
|
||||
|
||||
Reference in New Issue
Block a user