Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.

package com.codename1.backend.security

Authentication and authorization for the routes of a backend, in the shape of Spring Security: an application declares one or more SecurityFilterChain beans, each built from the HttpSecurity its method is handed, and every request the server does not answer on its own behalf is put to them.

A server with no such bean links none of this.

Types

class AbstractAuthenticationTokenThe parts every Authentication shares: its authorities, its details and the name read off its principal.
class AccessDeniedExceptionThe caller may not do what it asked.
interface AccessDeniedHandlerAnswers a signed-in caller that asked for something it may not have.
class AccessDeniedHandlerImplAnswers 403.
class AccountExpiredExceptionThe account has expired.
class AccountStatusExceptionThe account exists and may not be used as it stands: locked, disabled or expired.
class AnonymousAuthenticationFilterGives a request nobody signed in for an AnonymousAuthenticationToken, so the rules that follow always have an authentication to judge.
class AnonymousAuthenticationTokenWho a request is from when nobody signed in: a principal called anonymousUser holding ROLE_ANONYMOUS, so authorization rules always have someone to ask about.
class AnonymousConfigurerThe authentication of a request nobody signed in for; see AnonymousAuthenticationToken.
class AntPathRequestMatcherMatches a request’s path against an Ant-style pattern, and optionally its method.
class AnyRequestMatcherMatches every request.
class ApiKeyAuthenticationFilterAuthenticates a request from the API key it presents, in X-API-Key or as Authorization: Bearer <key>.
class ApiKeyConfigurerSign-in with an API key on each request.
class AuthenticatedAuthorizationManagerGrants access by whether the caller signed in at all.
interface AuthenticationWho a request is from: a credential presented for checking, or – once an AuthenticationManager has accepted it – the principal and what it may do.
interface AuthenticationCodecKeeps one kind of Authentication in the HTTP session, and makes it again on the next request.
interface AuthenticationEntryPointAnswers a request that has to authenticate first: with a challenge, or a redirect to where the user signs in.
class AuthenticationExceptionThe request could not be authenticated.
interface AuthenticationFailureHandlerAnswers a sign-in that was refused.
interface AuthenticationManagerDecides whether a presented Authentication is genuine.
interface AuthenticationManagerResolverChooses what authenticates a request, by the request: a server with several tenants, or tokens from several issuers.
interface AuthenticationProviderOne way of checking an Authentication: a ProviderManager asks each of its providers that supports the token’s class.
class AuthenticationServiceExceptionAuthentication could not be attempted at all: the user store failed, or the layer is misconfigured.
interface AuthenticationSuccessHandlerAnswers the request that signed a user in.
class AuthorityAuthorizationDecisionA decision that turned on what the caller is granted, with the authorities any one of which would have done.
class AuthorityAuthorizationManagerGrants access to an authenticated caller holding one of a set of authorities.
class AuthorizationDecisionGranted, or not.
class AuthorizationFilterPuts the request to the chain’s authorization rules, and throws AccessDeniedException when they refuse it.
interface AuthorizationManagerDecides whether an authentication may reach something: for a request rule, a RequestAuthorizationContext.
class AuthorizationServerConfigurerMakes the server an OAuth2 authorization server and OpenID Connect provider.
class AuthorizeHttpRequestsConfigurerThe authorization rules of a chain: which requests need what.
class BadCredentialsExceptionThe credentials are wrong: an unknown user or a password that does not match.
class BasicAuthenticationEntryPointAnswers 401 with the challenge that makes a client send HTTP Basic credentials: WWW-Authenticate: Basic realm="Realm".
class BasicAuthenticationFilterAuthenticates a request from its Authorization: Basic header.
class BearerTokenAuthenticationFilterAuthenticates a request from its bearer token.
interface ClockWhere the parts of the layer that judge time – a token’s expiry, a rate limit’s window – read it from, so a test can move it.
class CookieCsrfTokenRepositoryKeeps the token in a cookie, XSRF-TOKEN, for a page whose script reads the cookie and sends its value back in the X-XSRF-TOKEN header – the convention Angular and axios follow.
class CredentialsExpiredExceptionThe password was right and has expired.
class CsrfConfigurerProtection against cross-site request forgery.
class CsrfExceptionA state-changing request did not prove it came from the application’s own pages.
class CsrfFilterRefuses a state-changing request that does not carry the chain’s CSRF token.
interface CsrfTokenThe token a page sends back with a state-changing request to show the request came from the application’s own pages.
interface CsrfTokenRepositoryWhere a chain keeps the CSRF token it expects a client to send back.
interface CustomizerConfigures one part of an HttpSecurity: the lambda handed to formLogin, csrf, authorizeHttpRequests and the rest.
class DaoAuthenticationProviderChecks a username and password against a UserDetailsService: loads the user, compares the password through a PasswordEncoder, and refuses an account that is locked, disabled or expired.
class DefaultCsrfTokenA CsrfToken that is its three values.
class DefaultLoginPageGeneratingFilterServes a plain login page at GET /login for a chain that uses form login and names no page of its own.
class DefaultSecurityFilterChainA SecurityFilterChain that is a matcher and a list of filters: what HttpSecurity.build returns.
class DisabledExceptionThe account is disabled.
class ExceptionHandlingConfigurerHow a chain answers a request that must sign in, and one that may not have what it asked for.
class ExceptionTranslationFilterTurns the security exceptions thrown by what follows it – the authorization rules, a controller, a service the controller calls – into answers.
interface FilterChainThe rest of the chain, as a SecurityFilter sees it: the filters after it and then the application’s routes.
class FormLoginConfigurerSign-in through an HTML form.
interface GrantedAuthorityOne thing an Authentication has been granted: a role, written ROLE_ADMIN, or any other authority the application checks by name.
interface HeaderWriterWrites a header onto every response a chain’s requests get:
class HeaderWriterFilterHolds the chain’s HeaderWriters.
class HeadersConfigurerThe security headers a chain puts on its responses.
class Http403ForbiddenEntryPointAnswers 403: what a chain with no way of signing in says to a request that would have to.
class HttpBasicConfigurerSign-in with HTTP Basic credentials on each request.
class HttpSecurityBuilds one SecurityFilterChain.
class HttpSessionCsrfTokenRepositoryKeeps the token in the HTTP session: the default.
class HttpSessionRequestCacheRemembers the address in the HTTP session, under SAVED_REQUEST.
class HttpSessionSecurityContextRepositoryKeeps who is signed in in the HTTP session, under SPRING_SECURITY_CONTEXT_KEY.
class HttpStatusEntryPointAnswers with a status and nothing else: new HttpStatusEntryPoint(401) for an API whose clients know how to authenticate without being told.
class HttpStatusReturningLogoutSuccessHandlerAfter sign-out, answers with a status and no page: for an API.
class InsufficientAuthenticationExceptionThe request is anonymous, or not authenticated strongly enough, for what it asked for.
class InvalidCsrfTokenExceptionThe request’s CSRF token is not the one the server issued.
class LockedExceptionThe account is locked.
class LoginUrlAuthenticationEntryPointSends a request that has to sign in to the login page, with a 302.
class LogoutConfigurerSign-out: POST /logout ends the session, forgets who was signed in and redirects to /login?logout.
class LogoutFilterSigns the user out when a request asks for it – POST /logout unless configured otherwise – and answers with the chain’s LogoutSuccessHandler.
interface LogoutHandlerSomething to undo when a user signs out: a session, a cookie, a stored token.
interface LogoutSuccessHandlerAnswers the request that signed a user out.
class MfaConfigurerA second factor at sign-in.
class MissingCsrfTokenExceptionThe request carried a CSRF token and the server holds none to compare it with – the session it belonged to is gone – or carried none at all.
class NullRequestCacheRemembers nothing.
class NullSecurityContextRepositoryKeeps nothing: every request authenticates itself.
class OAuth2AuthorizationEndpointFilterAnswers the endpoints of an authorization server a user must be signed in for: the authorization endpoint and the device verification page.
class OAuth2AuthorizationRequestRedirectFilterStarts a sign-in at an identity provider: keeps the request this browser is sent away with, and redirects it to the provider.
class OAuth2AuthorizationServerFilterAnswers the endpoints of an authorization server that a client calls as itself: the token, revocation, device authorization, JWK Set, user info and metadata endpoints.
class OAuth2LoginAuthenticationFilterEnds a sign-in at an identity provider: takes the provider’s answer at /login/oauth2/code/{registrationId}, holds it to the request this browser was sent away with, exchanges the code, verifies the ID token and signs the user in.
class OAuth2LoginConfigurerSign-in through another identity provider, with OAuth2 or OpenID Connect.
class OAuth2ResourceServerConfigurerSign-in with a bearer token on each request: the routes under the chain are an OAuth 2.0 resource server, and the token is a JWT.
class ProviderManagerAn AuthenticationManager that asks a list of AuthenticationProviders in order and takes the first answer.
class ProviderNotFoundExceptionNo AuthenticationProvider of a ProviderManager checks tokens of the class it was handed.
class RateLimitConfigurerThe rate limits of a chain; filled in by HttpSecurity.rateLimit.
class RateLimitFilterAnswers 429 to a request that is over one of the chain’s rate limits; see HttpSecurity.rateLimit.
class RememberMeAuthenticationFilterRecognizes a returning user by their remember-me cookie, on a request nobody has signed in for.
class RememberMeAuthenticationTokenWho a request is from when the user was recognized by a remember-me cookie rather than signing in during this session.
class RememberMeConfigurerRemember-me: a cookie that signs a returning user in.
class RequestAuthorizationContextWhat a request rule is asked about: the request, and the variables its pattern bound.
interface RequestCacheRemembers where an anonymous request was going, so that signing in can send the user there instead of to a fixed page.
class RequestCacheConfigurerWhether a chain remembers where an anonymous request was going; see RequestCache.
interface RequestMatcherDecides whether a rule applies to a request: which chain guards it, which authorization rule covers it, which requests CSRF protection leaves alone.
class RequestMatchersCombines matchers: all of them, any of them, or not one.
class SavedRequestAwareAuthenticationSuccessHandlerAfter sign-in, sends the user to the page that asked them to sign in, or to a default when they came to the login page on their own.
class SecondFactorAuthenticationFilterAsks a user who has a second factor for it, between their password being accepted and their being signed in.
interface SecondFactorPolicyStands between a user passing their first factor and being signed in.
class SecurityConfigurerOne configurable part of an HttpSecurity: form login, CSRF protection, the authorization rules.
interface SecurityContextWhat the security layer knows about the thread’s current request: who it is from.
class SecurityContextConfigurerWhere a chain keeps who is signed in between requests.
class SecurityContextHolderWho the calling thread’s request is from.
class SecurityContextHolderFilterLoads who is signed in from the chain’s SecurityContextRepository into SecurityContextHolder before anything else looks.
class SecurityContextImplA SecurityContext that holds its authentication and nothing else.
interface SecurityContextRepositoryWhere a chain keeps who is signed in between one request and the next.
class SecurityExchangeWhat a chain keeps about the request the calling thread is serving, beyond the request itself: attributes filters hand one another, and headers for the response that is yet to come back.
interface SecurityFilterOne step of a SecurityFilterChain.
interface SecurityFilterChainThe filters that guard some of a server’s requests.
class SecuritySchemaThe tables the security layer’s database-backed stores keep, as a migration set of the layer’s own.
class ServiceBusyExceptionThe server is doing as much of something expensive as it was told it may, and this request would have been one more: it is turned away at once, rather than queued behind work that is already late.
enum SessionCreationPolicyWhether a chain may use the HTTP session.
class SessionManagementConfigurerWhether a chain uses the HTTP session, and what happens to it at sign-in.
class SessionSignInHow a chain signs a user in to a session, once some mechanism has established who they are.
class SimpleGrantedAuthorityAn authority that is its name and nothing else.
class SimpleUrlAuthenticationFailureHandlerAfter a refused sign-in, sends the user to a page – the login page with ?error, usually – or, with no page set, answers 401.
class SimpleUrlLogoutSuccessHandlerAfter sign-out, sends the user to a page.
class UsernamePasswordAuthenticationFilterSigns a user in from the login form: a POST to the login processing URL carrying username and password.
class UsernamePasswordAuthenticationTokenA username and password: as a client presented them, or – with authorities – as an AuthenticationProvider accepted them.
class WebAuthnAuthenticationFilterSigns a user in with a passkey: hands out the options of a sign-in at POST /webauthn/authenticate/options, and takes the authenticator’s answer at POST /login/webauthn.
class WebAuthnConfigurerPasskeys: a user who is signed in registers one, and from then on signs in with it.
class WebAuthnRegistrationFilterLets a signed-in user register a passkey, and remove one of theirs: