Class WellKnownMixin
/.well-known/* discovery endpoints.
Sibling of FaviconMixin, SeoMixin, and
VersionMixin. All four classes live in the
org.apache.juneau.rest.server.convention convention-endpoints mixin pack.
In v1 the mixin mounts a single literal path — /.well-known/security.txt per
RFC 9116. The class is structured so that
future entries (for example /.well-known/openid-configuration from a separate AuthN
mixin pack) can be added without touching this source: each future entry ships its own mixin
class with its own @Rest(paths) declaration.
Compose into a host resource via
@Rest(mixins=WellKnownMixin.class); the
/.well-known/security.txt URL becomes available alongside the host's own endpoints with
no further wiring.
Hardcoded mount path:
Unlike the sibling api-docs and ops mixins (see SwaggerMixin,
VersionMixin, etc.), the mount path here is not SVL-configurable
— /.well-known/security.txt is fixed by
RFC 8615 (Well-Known URIs) and
RFC 9116 (security.txt). Both RFCs are
explicit that the /.well-known/ prefix is the discovery convention and that the
filename suffix is the protocol-defined registry key — a runtime override here would
make the endpoint undiscoverable by spec-compliant clients.
Mixin-only deployment:
This resource is designed for composition via @Rest(mixins=...). The mount path is
pinned at the op level by @RestGet(path="/.well-known/security.txt") on
getSecurityTxt(org.apache.juneau.rest.server.RestResponse); a class-level @Rest(paths=...) declaration would be silently
ignored under the mixin pattern (see @Rest(paths) Javadoc).
Composition example:
Defaults & behavior:
- No default body. Per RFC 9116,
security.txt's mere presence is meaningful; shipping a placeholder body would be misleading. If the builder is not given a body viasecurityTxt(String), the endpoint returns404 Not Found(i.e. "we don't have one"). Loud documentation in topic page. - Content-Type.
text/plain; charset=UTF-8when a body is configured. - Excluded from generated Swagger / OpenAPI specs via
@OpSwagger(ignore=true).
See Also:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.apache.juneau.rest.server.servlet.RestMixin
RestMixin.DefaultBuilder<R extends RestMixin> -
Constructor Summary
ConstructorsModifierConstructorDescriptionNo-arg constructor — results in a 404 on/.well-known/security.txt.protectedWellKnownMixin(WellKnownMixin.Builder builder) Builder constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic WellKnownMixin.Buildercreate()Creates a new builder.void[GET /.well-known/security.txt] — emit the configured RFC 9116 body, or 404 when unset.Returns the configuredsecurity.txtbody (test/inspection helper).Methods inherited from class org.apache.juneau.rest.server.servlet.RestMixin
builder, getHostContext, getRestBuilder, setContext
-
Constructor Details
-
WellKnownMixin
public WellKnownMixin()No-arg constructor — results in a 404 on/.well-known/security.txt. -
WellKnownMixin
Builder constructor.Stashes the programmatic
RestBuilder(the builder itself, carrying any@Rest-level overrides such aspath) viasuper(builder)so those values take precedence over this mixin's own@Restannotation.- Parameters:
builder- The builder. Must not benull .
-
-
Method Details
-
create
Creates a new builder.- Returns:
- A new builder.
-
getSecurityTxt
[GET /.well-known/security.txt] — emit the configured RFC 9116 body, or 404 when unset.- Parameters:
res- The current REST response.- Throws:
IOException- If an I/O error occurs while writing the response.NotFound- If nosecurity.txtbody is configured.
-
getSecurityTxtBody
Returns the configuredsecurity.txtbody (test/inspection helper).- Returns:
- The body, or
null if unset.
-