Class SecuredBrowserlessApplicationContext<C>
- Type Parameters:
C- the credentials type accepted bynewUser(Object), as defined by the configuredSecurityContextHandler
- All Implemented Interfaces:
AutoCloseable
Extends BrowserlessApplicationContext with a configured, non-null
SecurityContextHandler and credential-typed newUser(...)
overloads for installing per-user security state. Build instances via a
BrowserlessApplicationContext.Builder configured with
BrowserlessApplicationContext.Builder.withSecurityContextHandler(SecurityContextHandler),
which transitions to SecuredBrowserlessApplicationContext.Builder and produces this typed context.
All thread-affinity and lifecycle guarantees of the base
BrowserlessApplicationContext apply unchanged.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder forSecuredBrowserlessApplicationContext. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new user context with the given credentials.Creates a new user context for the given username and roles.Methods inherited from class com.vaadin.browserless.BrowserlessApplicationContext
close, create, create, create, createSecured, newUser
-
Method Details
-
newUser
Creates a new user context with the given credentials.The security context for this user is first cleared, then the credentials are passed to
SecurityContextHandler.setupAuthentication()— including whencredentialsisnull, so that the handler can install its anonymous-equivalent state. The resulting security state is captured as this user's initial snapshot and is automatically restored whenever one of this user's windows is activated.- Parameters:
credentials- framework-specific credentials, ornullfor an anonymous user- Returns:
- the new user context
- Throws:
IllegalStateException- if this context has been closed
-
newUser
Creates a new user context for the given username and roles.Delegates to
SecurityContextHandler.createCredentials(String, String...)on the configured handler, then tonewUser(Object). Spring and Quarkus handlers ship with overrides that mirror the conventions of@WithMockUser/ Quarkus security identity construction; custom handlers must overridecreateCredentialsto opt into this helper.- Parameters:
username- the usernameroles- the roles for the user; may be empty- Returns:
- the new user context
- Throws:
IllegalStateException- if this context has been closedUnsupportedOperationException- if the configured handler doesn't overrideSecurityContextHandler.createCredentials(String, String...)
-