diff --git a/cameleer-server-app/src/main/java/com/cameleer/server/app/controller/LicenseAdminController.java b/cameleer-server-app/src/main/java/com/cameleer/server/app/controller/LicenseAdminController.java index 039b7e80..3c5152c3 100644 --- a/cameleer-server-app/src/main/java/com/cameleer/server/app/controller/LicenseAdminController.java +++ b/cameleer-server-app/src/main/java/com/cameleer/server/app/controller/LicenseAdminController.java @@ -1,54 +1,71 @@ package com.cameleer.server.app.controller; +import com.cameleer.server.app.license.LicenseRepository; +import com.cameleer.server.app.license.LicenseService; import com.cameleer.server.core.license.LicenseGate; import com.cameleer.server.core.license.LicenseInfo; -import com.cameleer.server.core.license.LicenseValidator; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.*; +import org.springframework.security.core.Authentication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import java.util.LinkedHashMap; import java.util.Map; +/** + * License management for ADMIN users. All mutation goes through {@link LicenseService} so that + * install / replace flows are uniformly audited, persisted, and published to listeners (retention + * policy, license metrics, etc.). + * + *
GET returns {@code {state, invalidReason, envelope, lastValidatedAt?}}. The raw JWT-style + * token is deliberately omitted from the response — only the parsed {@link LicenseInfo} is + * exposed.
+ */ @RestController @RequestMapping("/api/v1/admin/license") @PreAuthorize("hasRole('ADMIN')") @Tag(name = "License Admin", description = "License management") public class LicenseAdminController { - private final LicenseGate licenseGate; - private final String licensePublicKey; - private final String tenantId; + private final LicenseService licenseService; + private final LicenseGate gate; + private final LicenseRepository repo; - public LicenseAdminController(LicenseGate licenseGate, - @Value("${cameleer.server.license.publickey:}") String licensePublicKey, - @Value("${cameleer.server.tenant.id:default}") String tenantId) { - this.licenseGate = licenseGate; - this.licensePublicKey = licensePublicKey; - this.tenantId = tenantId; + public LicenseAdminController(LicenseService svc, LicenseGate gate, LicenseRepository repo) { + this.licenseService = svc; + this.gate = gate; + this.repo = repo; } @GetMapping - @Operation(summary = "Get current license info") - public ResponseEntity