uk.ac.starlink.auth

## Interface ContextFactory

-     public interface ContextFactory

  Contains configuration for creating AuthContext objects from user credentials.
  Since:
    15 Jun 2020
  See Also:
    `AuthScheme.createContextFactory(uk.ac.starlink.auth.Challenge, java.net.URL)`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `AuthContext` | `createContext(UserInterface ui)` Attempts to create an authentication context, by enquiring for input from the UI as appropriate.
    `AuthContext` | `createUnauthContext()` Creates a context representing unauthenticated (anonymous) access.

- - ### Method Detail

    - #### createContext

          AuthContext createContext(UserInterface ui)

      Attempts to create an authentication context, by enquiring for input from the UI as appropriate. Should return an apparently viable, though not guaranteed valid, context (`AuthContext.hasCredentials()` will return true), or null if the user declined to authenticate.

      If appropriate, the implementation of this method should offer the user retry attempts following failed or inadequate credential entry in accordance with the supplied UserInterface. Note however that retries must not be attempted if `UserInterface.canRetry()` returns false or following a null return from `UserInterface.readUserPassword(java.lang.String[])`.

      Parameters:
        `ui` - user interface that can be used to query the user for credentials
      Returns:
        authentication context, or null if the user declined to authenticate

    - #### createUnauthContext

          AuthContext createUnauthContext()

      Creates a context representing unauthenticated (anonymous) access. The resulting context, for which `AuthContext.hasCredentials()` will return false, may or may not be capable of connecting, but it can represent the choice of a user not to authenticate for a given challenge.
      Returns:
        anonymous authentication context