Class BasicAuthServerBuilder

java.lang.Object
com.helger.http.basicauth.BasicAuthServerBuilder

@NotThreadSafe public class BasicAuthServerBuilder extends Object
Builder for creating HTTP Basic Authentication server challenge header values.
Author:
Philip Helger
  • Constructor Details

    • BasicAuthServerBuilder

      public BasicAuthServerBuilder()
      Default constructor.
  • Method Details

    • getRealm

      public @Nullable String getRealm()
      Returns:
      The currently set realm. May be null if not yet set.
    • setRealm

      public @NonNull BasicAuthServerBuilder setRealm(@NonNull String sRealm)
      Set the realm to be used.
      Parameters:
      sRealm - The realm to be used. May not be null and should not be empty.
      Returns:
      this
    • isValid

      public boolean isValid()
      Returns:
      true if this builder has all required fields set (i.e. the realm is not null), false otherwise.
    • build

      @Nonempty public @NonNull @Nonempty String build()
      Build the HTTP Basic Authentication server challenge header value string.
      Returns:
      The formatted Basic auth header value. Neither null nor empty.
      Throws:
      IllegalStateException - if this builder is not valid (i.e. the realm has not been set).
    • toString

      public String toString()
      Overrides:
      toString in class Object