Spring Boot
The Spring Boot starters add Datum's server side to your own application:
- The form definition, served by id.
- Submissions, validated by the same program the page runs.
- The form and builder assets.
- PDF render, fill, sign and verify.
- An RFC 3161 timestamp server.
- Passkey-signed submissions.
Every route is off until you switch it on, and who may call it is your Spring Security configuration, not a Datum policy. The Spring Boot starters are tested on Linux. The server hosts page compares the hosts.
First run
This section takes the form from Getting started to a Spring Boot application that receives its submission. Follow it from top to bottom. It needs nothing from the rest of the page.
You need:
- JDK 17 or newer, and a Spring Boot 4 application: this one uses Spring MVC, and WebFlux works as well.
- Node 22, npm and git, to build the browser files. The artifacts are not on Maven Central yet, so the build installs them from a clone of the repository into your local Maven repository. The build downloads the sandbox runtime once.
Build the browser files. Run the commands of Files you host in a clone of the repository. The Maven build in the next step reads
packages/and needsdatum/ dist nodeon the path.Install the host, from the root of the clone:
shcd integrations/jvm ./mvnw -B -Pdev-native -pl spring/datum-spring-boot-starter-submissions -am clean install -DskipTests -DskipITsThis takes about three minutes. Nearly all of it is compiling the sandbox runtime, and
-Pdev-nativecompiles it for this machine's platform only: without it the build compiles six platforms and takes 12 to 16 minutes, and a jar built with it runs native here and slowly elsewhere, so keep it for local use.-Dskipalone still runs the integration tests, soTests -Dskipgoes with it.ITs -pland-ambuild the submissions starter and what it needs. The artifacts land in~/.m2at version0..1. 0-SNAPSHOT Make a folder for the application beside the clone, named
intakehere, and put thispom.in it. The BOM sets the version of every Datum artifact, and the starter adds the submissions route. The starters bring no web stack, so the pom adds one itself:xml xml<project xmlns="http://maven.apache.org/POM/4.0.0"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>4.2.0</version> </parent> <groupId>example</groupId> <artifactId>intake</artifactId> <version>1.0.0</version> <dependencyManagement> <dependencies> <dependency> <groupId>com.argusvane</groupId> <artifactId>datum-bom</artifactId> <version>0.1.0-SNAPSHOT</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.argusvane</groupId> <artifactId>datum-spring-boot-starter-submissions</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webmvc</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>Put the form where the host reads it. Save the form the page uses (
forms/in Getting started, idcontact. json contact, version1.) as0. 0 src/. That is the default ofmain/ resources/ datum/ forms/ contact. json datum.,forms. locations classpath:/datum/. The file'sforms/*.json idis its key.Write the application,
src/:main/ java/ example/ Application. java javapackage example; import com.argusvane.datum.submissions.spi.SubmissionHandler; import com.argusvane.datum.submissions.spi.SubmissionReceipt; import java.util.UUID; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } @Bean SubmissionHandler handler() { return accepted -> { System.out.println("received " + accepted.formKey() + " " + accepted.values()); return new SubmissionReceipt(UUID.randomUUID().toString(), accepted.digest().substring(0, 8).toUpperCase(), null); }; } }The handler is the one thing the starter leaves to you: it stores the accepted submission and answers its receipt, and the
referenceis what the form's confirmation shows. Here it prints the answers. A real handler stores them once under a unique key onaccepted.andform Key() accepted., because a retried attempt may reach it twice. Without a handler bean the default logs the form and a digest, stores nothing and warns at start.submission Key() Switch the route on, in
src/. Every route is off until its switch is on, and the submissions switch is all this story needs. The port is 8081 because the static server of Getting started holds 8080:main/ resources/ application. yml yamlserver: port: 8081 datum: web: api: endpoints: submissions: trueBuild and run, in the
intakefolder:sh../datum/integrations/jvm/mvnw -q package java --enable-native-access=ALL-UNNAMED -jar target/intake-1.0.0.jarThe flag is for JDK 24 and newer, where the JVM prints
WARNING: A restricted method ... has been calledat the sandbox's first native call unless native access is enabled; the application runs either way. On JDK 17 to 23 the flag changes nothing. An executable jar can carryEnable-Native-Access: ALL-UNNAMEDin its manifest instead, which Spring Boot's repackaging keeps.The start takes a few seconds. Among three WARN lines that say the throttle, the form snapshots and the receipts are kept in this process's memory, the log holds these lines, trimmed here:
INFO datum.web : Datum routes enabled (1): POST /api/submissions (datum.web.api.endpoints.submissions) INFO c.a.d.sandbox.runtime.DatumSandbox : Datum runtime UP: engine endive 1.2.0 (panama), sandbox ABI 4.1.0 ... INFO example.Application : Started Application in 5.9 secondsWith the switch off the log says
no Datum route is enabled, and a post to the route answers the framework's 404.Send a submission. In a second terminal, post the body a page sends: the envelope as
document, and the key of the submit attempt.shcurl -s -X POST localhost:8081/api/submissions -H 'content-type: application/json' -d '{ "document": { "versionContext": { "form": { "id": "contact", "version": "1.0.0" } }, "submission": { "locale": "en", "values": { "fullName": "Ada Lovelace", "email": "ada@example.com", "topic": "question", "message": "Hello" } } }, "submissionKey": "first-run-1" }'The reply is 200, and the server prints
received contact {...}:json{"id":"1bbf7a18-7cec-416d-ab24-4f97ccb4a4fc","reference":"81396661","status":"accepted","digest":"813966615705ced43fc2ab4c6d752fd703fbf171f7af0157651bab2a321f56b6","handled":false}Send the same command again and
handledistrue: the same key gets the first receipt, and the handler is not called again. A body with nosubmissionis a 400Key bad_.document Send answers the form refuses. Change
fulltoName ""and the key tofirst-run-2. The sandbox judges the answers against the form's own copy and the reply is 422, which a page puts on the field withset:Errors json{"errors":[{"field":"fullName","code":"required"}]}Open the page through the application. The page from Send it to a server posts this body to this route: both are this host's defaults. A browser lets a page read a reply only from its own origin, so serve the site folder of Getting started from the application. Add it to
application., then build and run again:yml yamlspring: web: resources: static-locations: file:../my-site/Open
localhost:8081in a browser, fill the form in and press Send. The form shows "Your form was submitted" with the reference the handler answered, and the server prints the answers.
Two things to keep in mind from here:
- The
idandversionin the page's form must be the ones the host holds, so the page and the host read the same file. - A page that stays on another origin needs CORS configured in your application: the host adds no CORS headers.
Starters
Add the starter a story needs the way the first run adds the submissions one, with the BOM importing the versions.
| Starter | Use it for |
|---|---|
datum-spring-boot-starter-submissions | The form is on your page and the server validates what it submits |
datum-spring-boot-starter-ui | The same, and the server also serves the form and builder assets and the page glue |
datum-spring-boot-starter-pdf | PDF render, fill, sign and verify |
datum-spring-boot-starter-timestamp | An RFC 3161 timestamp server, standalone |
datum-spring-boot-starter-webauthn | Passkey ceremonies and signed-submission verification |
Switching routes on
A starter on the class path maps nothing. Each route group has a property, and a route that is off answers the framework's own 404.
datum:
web:
api:
endpoints:
submissions: true
validate: true
definition: trueThe log lists what is on at start, under the logger datum..
Paths sit under datum. (default /api), except these:
- The assets:
datum., defaultweb. assets. path /datum/.assets - The timestamp server:
datum., defaulttsa. path /tsa. - The passkey routes:
datum., defaultwebauthn. path /api/.webauthn
| Property | Maps |
|---|---|
datum. | POST /submissions |
datum. | POST /submissions/ |
datum. | GET /forms/, GET /forms/ |
datum. | GET /data-sources/ |
datum. | POST /submissions/, the dry run |
datum. | POST /inspect |
datum., .fill, .sign, .verify | POST /pdf, /pdf/, /pdf/, /pdf/ |
datum. | GET /server/ |
datum. | The bundles and datum-host. under /datum/ |
datum. | POST /forms, PUT /forms/, PUT /forms/, and the builder files |
datum. | POST /tsa, GET /tsa/, GET /tsa/ |
datum. | /api/, with datum., rp-name and origins |
The check route
POST /submissions/ checks a journey or one page of it.
- Body.
{ document, scope, page.Id? } scopeis required and isjourneyorpage, andpagegoes withId pageonly. Anything else is a 400. - Verdict. A 200
{ accepted, errors, notes? }.errorsholds only what blocks, and warnings and info go innotes, which is left out when empty.
A run that fails is not a verdict, so it is never a 422. Both routes answer it with a 503 and the run's code:
wasm.execution_ error outcome_too_ large definition., when the form itself nests too deeptoo Deep
The other 503s are server., server. and validator_. Only server. carries Retry-After, because retrying the others does not help. The PDF routes and POST /inspect answer a failed run the same way. A 422 always means the answers were judged and refused. The full shapes are on the wire.
Error bodies
An error body is { errors: [ { field?, code, message? } ] }. field is there only when the error names a component, so a form-level error carries none. message is the sandbox's own wording for a finding, sent as it came, on a check's 200 and on a submission's 422. A message that a hook gave belongs to the finding that hook raised, and it never replaces the sandbox's.
Common properties
Every property, with its default and bounds, is on Spring Boot properties. The ones met most often:
datum., defaultforms. locations classpath:/datum/.forms/*.json datum., defaultweb. api. max-body-size 1.MB datum., for RFC 9457 errors.web. api. problem-details datum., defaultruntime. validation. time-limit 5s, andmemory, default32.MB datum..host. time-zone datum., defaultweb. throttle. limit 60per1mfor one key, anddatum., defaultweb. throttle. address-limit 600, for one address before the body is read.
A value that cannot work stops the start and names the property. datum. removes the beans and the runtime too.
Beans you bind
Each of these is optional and replaces its default. The routes, bodies and codes they take part in are on the wire.
| Bean | What it does |
|---|---|
Submission | Stores the accepted submission and returns the receipt |
Form | Where forms live; the default is read-only over datum. |
Definition, Translation, Data | The versions a submission is judged against, by hash; the host's translation catalogue for a form; option lists a form loads |
Submission, Submission | One limit across instances; answering a retried attempt with its first receipt |
Pdf, Pdf, Pdf | The PDF seal key, fonts and template bytes |
Timestamper, Pdf | Where the PDF seal gets its timestamps; which anchors, revocation checking and validation time decide that a signer is trusted |
Tsa, Tsa, Tsa | The timestamp server's signing key, its serial numbers and the clients allowed to ask |
Passkey, Passkey, Passkey, Passkey | Stored passkeys, the replay guard, who a request is, and the limit on challenges and registrations |
Error | Turns an exception Datum does not know into an answer; asked in bean order before the built-in mapping |
Host | The values the form's host. names read, worked out from the request; see the host context |
Datum | A note the host says once at start |
Sandbox, Pdf | Wrap the sandbox or the PDF program the runtime built, for instrumentation |
The stores of the timestamp server and passkeys refuse to start in memory unless datum. or datum. acknowledges one instance. Server hosts lists everything that has to be shared when there is more than one.
With a Data and spring-jdbc the stores are SQL.
- Scripts. H2, PostgreSQL and MySQL scripts ship under
META-INF/and work with Flyway or Liquibase.datum/ db/ migration/ {vendor} - Schema.
datum.isjdbc. initialize-schema embeddedby default, which makes the tables only in an in-memory database. Setneverin production. - Several data sources. Mark the one Datum uses
@Datum.Data Source - Signing keys. They come from a Spring Boot SSL bundle named in
datum.orpdf. signing. ssl-bundle datum..tsa. signer. ssl-bundle
Hooks, in order
Every capability runs a request through the same kinds of hook. *Customizer beans run before the engine or the store is asked and may adjust a draft or refuse. *Validator beans run after the engine answered and may add errors or warnings. One handler does the effect, and Spring events follow it and never veto.
A submission goes through these in order:
Submission(anti-spam, quotas, per-form access).Pre Check Host,Options Customizer SandboxandRules Provider Sandbox.Context Contributor - Your
Host.Context Provider - The sandbox.
Submission.Signature Check Submission.Validator - Your handler.
Customizers each see what the one before left, and the first refusal stops the rest. Validators all run, so every error is reported at once. Beans with equal @Order keep no promised order, so declare @Order where position matters.
Each capability has its own hooks, all of the same two kinds:
| Capability | Customizers (before) | Validators (after) |
|---|---|---|
| Submissions | Submission, Host, Sandbox, Sandbox, Submission | Submission |
| Forms | Definition, on the public copy on its way to a filler | none |
| Builder | Builder, before the kernel checks a save | Builder, after |
Pdf, which adjusts env, options, host, attachments and fonts | Pdf, which judges the PDF before it leaves and, when the server seals, before the seal | |
| Timestamp server | Timestamp: refuse a client, choose a policy among the accepted ones, state another accuracy | none |
| Passkeys | Registration, at the challenge and at the registration; Signature, which can only tighten a form's signature check | Registration, after the ceremony verified a passkey and before it is stored |
A pre-check refuses by returning Pre with a code and a message, answered 403 unless it says otherwise. Any other hook refuses with a Hook: forbidden answers 403, conflict 409 and invalid 422, with an errors body of field, code and message.
Events
Listen to an event with @Event; a failing listener is logged and never changes the answer. The events are:
Submission,Validated Event Submission,Rejected Event Submission,Throttled Event Submission,Redelivered Event Journey,Checked Event SubmissionSignature Verified Event FormDefinition Saved Event Pdf,Rendered Event PdfVerified Event Timestamp,Issued Event TimestampRefused Event Passkey,Registered Event PasskeyRevoked Event Sandbox,Ready Event SandboxRun Interrupted Event
The host context
A rule can read a fact about the visit, such as host.. The page's own host is only for display: a client can set it to anything, and a submission does not carry it. The server works the values out itself. Declare one Host bean that reads the request, for example the signed-in person:
@Bean
HostContextProvider hostContext() {
return request -> {
if (!(request.submission().principal() instanceof Authentication auth)) {
return Optional.empty();
}
boolean admin = auth.getAuthorities().stream().anyMatch(a -> a.getAuthority().equals("ROLE_ADMIN"));
return Optional.of(Map.of("role", admin ? "admin" : "user"));
};
}It is asked once for each submission, journey check, dry run and PDF. request. also has the headers and the client address, and request. says which form it is. Nothing in the request body is ever read for it.
What the provider returns decides how host. rules are judged:
- Empty. There is no context. Rules that read
host.are left unjudged, as before: a field shown only to some people is not required. - A map, even an empty one. It is a context: every such rule is judged, and a name it does not hold has no value.
- A throw, or something that is not plain JSON data within 64 levels. The request is refused with 503
server., nothing runs and the cause is logged.unavailable
A retry of a submission already accepted keeps its first answer. Two Host beans stop the application at start.
Securing the routes
With spring-boot-starter-security on the class path, Datum (servlet) and Datum (WebFlux) give your filter chain one matcher per capability: forms, builder, builder, data, submissions(), validate(), dry, inspect(), pdf(), pdf, passkeys(), tsa(), assets() and all().
@Bean
SecurityFilterChain chain(HttpSecurity http, DatumRequestMatchers datum, DatumSecurityResponses responses) throws Exception {
return http
.authorizeHttpRequests(requests -> requests
.requestMatchers(datum.builderWrites(), datum.builderReads(), datum.dryRun(), datum.inspect()).hasRole("EDITOR")
.requestMatchers(datum.formsRead(), datum.submissions(), datum.validate(), datum.assets()).permitAll()
.anyRequest().authenticated())
.httpBasic(Customizer.withDefaults())
.exceptionHandling(exceptions -> exceptions
.defaultAuthenticationEntryPointFor(responses.authenticationEntryPoint("Basic realm=\"forms\""), datum.all())
.defaultAccessDeniedHandlerFor(responses.accessDeniedHandler(), datum.all()))
.build();
}Datum (Datum on WebFlux) answers a refusal on Datum's routes as JSON, 403 access. or 401 unauthorized.
- One form for one person. Where the form is in the body of a request, a matcher cannot see it, so refuse it in a
Submission, which receives the form key and the principal.Pre Check - No security chain. Every route that is on is open, and the start logs a warning when the builder writes, the passkey routes or the timestamp server would be.
Behind a proxy set server. so the throttle sees the client address. responses. has the cookie CSRF setup the page glue reads.
The builder write endpoints
datum. on the UI starter serves the builder and three write routes: POST /api/, PUT /api/ and PUT /api/, plus the author's copy of a form at GET /api/.
- Checks. The sandbox kernel checks a save before it is stored, and a save made against an out-of-date version is refused with 409
form.. The request and reply bodies, headers and codes are on the wire.outdated - Security. Secure
builderandWrites() builder, because the author's copy of a form includes its server-secret rules.Reads() - Repository. The default repository is read-only, so supply a
Formthat can save, or a save answers 501Definition Repository forms..read Only - Size. Limit the size of a definition with
datum..builder. max-definition-size
Serving the form from the host
datum. serves host., the page glue datum-host. and the bundles under the build id. Server hosts shows the page code and lists every Datum method.
Drafts
The starters do not serve draft routes. A server: draft store calls four routes you write yourself; they are described on Drafts.
Sealing PDFs
The server seals the PDFs it issues with its own key. The key comes from a Spring Boot SSL bundle.
spring:
ssl:
bundle:
jks:
pdf-seal:
keystore: { location: file:/etc/datum/seal.p12, password: "${SEAL_PASSWORD}", type: PKCS12 }
key: { alias: seal, password: "${SEAL_PASSWORD}" }
datum:
pdf:
signing:
ssl-bundle: pdf-seal
seal:
enabled: true
timestamp: true| Property | Does |
|---|---|
datum. | The bundle holding the seal key and its chain. seal. without a key is a start-up warning. |
datum., .layouts, .certify, .reason, .location, .visible | Turn the seal on, limit it to some layouts, and set what the signature says. |
datum. | Ask for a timestamp token over each seal. It needs a timestamp source; without one the start warns. |
datum., .retired-certificates | Anchors the verify route builds a chain to, and the certificates the seal key replaced. |
datum. | Seal the PDFs of posted, unstored answers with the real key. Off, a throwaway test certificate seals them. |
Where the seal gets its timestamps, a server you name or the host's own, is on Timestamp server. Every property is on Spring Boot properties.
Requiring a passkey signature
With the passkey starter and datum., a form can require the person to sign with a passkey. Set the site's rp-id and origins, a datum. of at least 32 bytes, and then per form:
datum:
webauthn:
enabled: true
rp-id: example.org
origins: [https://forms.example.org]
forms:
intake:
mode: requiredmode is off, optional or required; unavailable says whether a browser that cannot sign is refused or accepted unsigned. The other per-form keys (scope, placement, user-verification, statement, verify) and the site settings are on Spring Boot properties. The routes are on the wire, and the whole of it, page and server, is on Signing a form with a passkey.
Observability
Expose what you need, for example management..
- Health. The
datumhealth component has one member per check, withruntimethe one a readiness group should use. - Actuator.
/actuator/reports the runtime and the settings it runs with and, ondatum POST, rechecks it without a restart. - Meters. They include
datum.,runs datum.andsubmissions datum..throttled - Observations. With an
ObservationDatum reportsRegistry datum.,submission datum.,sandbox. run datum.,pdf. run datum.andpdf datum., and no answer, byte or digest is ever a tag.tsa. issue - OpenAPI. With springdoc every enabled route is documented, one group per capability, such as
datum-forms,datum-submissionsanddatum-pdf.
Testing
Add datum-spring-boot-starter-test in test scope. @Auto gives a test context with a fake runtime in place of the sandbox, and fixture forms with test. Datum and Datum are the request helpers.
To check a running deployment against the wire contract, run datum-host-check from the conformance suite, which needs no JDK. The same checks ship as JUnit contracts in the datum-host-tck module, which reads the same datum. settings.
datum-host-check --endpoint https://forms.example --capabilities submissions,submissions-test,forms,assetsEvery property is on Spring Boot properties, and every route on The wire.