What you need
sealforge-anonymizer-spring-boot-starter | Spring Boot 3 (Spring MVC): sealforge.anonymizer.* settings, annotations on controllers, RestClient / RestTemplate interceptor |
sealforge-anonymizer | Java 17 without Spring: a jakarta.servlet filter (Tomcat, Jetty, Quarkus, Jakarta EE…), outgoing calls, the client of the server |
Both modules belong to the fr.sealforge group and need Java 17 or later. They come with the Enterprise Edition and with the online service, from the Maven repository supplied with your licence (a URL or a folder).
Set it up from the desktop app
In the app, open Settings → .NET and Java middleware, choose the folder of your project, then Scan: the app recognizes a Spring Boot 3 project (Maven pom.xml or Gradle build.gradle(.kts) with spring-boot-starter-web) and reads your controllers' actions from src/main/java, without building anything.
Preview the changes shows every file and the lines added; Apply writes them, after a copy of each file.
pom.xml / build.gradle | the starter's dependency and the Maven repository given |
application.yml / .properties | the sealforge.anonymizer.* settings |
| actions | @AnonymizeRequestBody / @AnonymizeResponseBody and their import |
~/.sealforge/secrets/ | the API key or the licence key, outside the repository, readable by you alone |
Or by hand: the dependency and two settings
<dependency>
<groupId>fr.sealforge</groupId>
<artifactId>sealforge-anonymizer-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency># application.yml
sealforge:
anonymizer:
server-url: https://anonymizer.corp.example
api-key: ${SEALFORGE_API_KEY}The starter configures itself: no configuration class to write. sealforge.anonymizer.enabled: false turns it off.
Annotate the actions to protect
@RestController
class Tickets {
@PostMapping("/tickets")
@AnonymizeRequestBody // the action, its logs and its database only see the pseudonymized ticket
Ticket create(@RequestBody Ticket ticket) { return store(ticket); }
@GetMapping("/export")
@AnonymizeResponseBody // the caller receives the data pseudonymized
List<Customer> export() { return customers(); }
}@AnonymizeBodies pseudonymizes both. The annotations go on an action or on a controller (all its actions). For functional routes, declare an EndpointBodies bean: new UrlPatternEndpoints().request("POST", "/tickets").response("GET", "/export/**").
Which body? The request, when the service itself must never hold the values. The response, when the service may hold them but not its caller. Both: a chat.
SseEmitter, StreamingResponseBody, DeferredResult) cannot be held: in block mode the caller gets a 503.Outgoing calls: an LLM
@Bean
RestClient llm(RestClient.Builder builder, SealforgeOutgoing sealforge) {
return builder.baseUrl("https://api.openai.com")
.requestInterceptor(sealforge.interceptor("openai"))
.build();
}The LLM only sees tokens; the answer comes back with the real values. The same interceptor goes on a RestTemplate; interceptor(provider, false) leaves the tokens in the answers.
Any other HTTP client uses SealforgeOutgoing.anonymization(…): prepare(body, contentType) gives the body to send, restore(answer, answerContentType) the answer with its values.
Strategies and categories
As in .NET: either explicit, or a named strategy saved on the server, never both.
sealforge:
anonymizer:
strategy: placeholder
categories:
FirstName: ""
LastName: ""
Email: hashsealforge:
anonymizer:
central-strategy: rh-standardCategories: FirstName, LastName, Company, Address, Login, Secret, PhoneNumber, BirthDate, SocialSecurityNumber, BankAccount, Email, CustomerId.
The online service
sealforge:
anonymizer:
target: online
server-url: https://anonymizer.sealforge.fr
license-key: ${SEALFORGE_LICENSE_KEY}
pseudonym-key: ${SEALFORGE_PSEUDONYM_KEY} # 16+
central-strategy: reversibleYour licence key goes with every call. pseudonym-key is your own key (16 characters or more), required by the reversible strategy: it alone opens the values again.
SealforgeAnonymizerCustomizer bean.Without Spring, and when something fails
var options = new SealforgeAnonymizerOptions();
options.setServerUrl("https://anonymizer.corp.example");
options.setApiKey(System.getenv("SEALFORGE_API_KEY"));
var anonymizer = SealforgeAnonymizer.create(options);
var endpoints = new UrlPatternEndpoints().request("POST", "/tickets").response("GET", "/customers/{id}");
servletContext.addFilter("sealforge", new SealforgeAnonymizationFilter(anonymizer, options, endpoints))
.addMappingForUrlPatterns(null, false, "/*");anonymizer.anonymizeJson(json) and anonymizeText(text) pseudonymize a body anywhere else (a message queue, a batch).
failure-mode: block (the default): server unreachable or licence refused, the request gets a 503 and nothing leaves in clear. pass-through sends the body as it is and logs it.