Class StandaloneLoginFlow<T,U>

java.lang.Object
com.svenruppert.jsentinel.standalone.StandaloneLoginFlow<T,U>
Type Parameters:
T - the credentials type
U - the subject type

public final class StandaloneLoginFlow<T,U> extends Object
Drives the login lifecycle for standalone applications without any UI-toolkit assumption. A typical CLI / desktop main loop calls login(Object, String) once with the user-entered credentials and the displayed username (used for brute-force tracking + audit), then carries on with the request-handling loop.

Behaviour mirrors the Vaadin / REST flow:

  1. Ask LoginAttemptPolicy whether the username is currently throttled — return StandaloneLoginFlow.LoginResult.lockedOut(LoginAttemptDecision.LockedOut) on a hit so the caller can render a wait time.
  2. Delegate to the registered AuthenticationService.
  3. On success — load the subject, bind it into the active SubjectStore, record the success on the policy and emit a LoginSucceeded audit event.
  4. On failure — record the failure on the policy and emit a LoginFailed audit event.
  • Constructor Details

    • StandaloneLoginFlow

      public StandaloneLoginFlow()
      Uses the SPI-resolved AuthenticationService and the system UTC clock. The most common entry point.
    • StandaloneLoginFlow

      public StandaloneLoginFlow(com.svenruppert.jsentinel.authentication.AuthenticationService<T,U> authenticationService, Clock clock)
      Test seam. Pass an explicit AuthenticationService and clock so tests can avoid SPI registration churn.
  • Method Details

    • login

      public StandaloneLoginFlow.LoginResult<U> login(T credentials, String username)
      Runs one login attempt.
      Parameters:
      credentials - credentials accepted by the configured AuthenticationService
      username - displayed username, used for brute-force tracking and audit; may be null or empty for anonymous flows (no throttling applies)
      Returns:
      the outcome
    • logout

      public void logout()
      Removes the current subject from the SubjectStore. Does not emit an audit event — that is the LogoutService's responsibility, which standalone applications wire up explicitly when they need it.
    • bindToken

      public void bindToken(com.svenruppert.jsentinel.credential.propagation.TokenCredential credential)
      V00.74 — bind a TokenCredential for the current thread so @PropagateToken-annotated wrappers can forward it to downstream HTTP calls. Convenience for the standalone / CLI demo pattern (after a successful login, the caller has the token at hand and binds it here).

      Looks up the SPI-resolved TokenCredentialStore (see Konzept §6.3).

      Parameters:
      credential - the credential to bind; non-null