Class AuthManager

All Implemented Interfaces:
SessionFeature, Proxy

@Generated("org.javagi.JavaGI") public final class AuthManager extends GObject implements SessionFeature

HTTP client-side authentication handler.

AuthManager is the SessionFeature that handles HTTP authentication for a Session.

A AuthManager is added to the session by default, and normally you don't need to worry about it at all. However, if you want to disable HTTP authentication, you can remove the feature from the session with Session.removeFeatureByType(Type) or disable it on individual requests with Message.disableFeature(Type).

You can use this with Session.removeFeatureByType(Type) or Message.disableFeature(Type).

(Although this type has only been publicly visible since libsoup 2.42, it has always existed in the background, and you can use g_type_from_name ("SoupAuthManager") to get its GObject.Type in earlier releases.)

  • Constructor Details

    • AuthManager

      public AuthManager(MemorySegment address)
      Create a AuthManager instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • AuthManager

      public AuthManager()
      Create a new AuthManager.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the AuthManager class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected AuthManager asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • clearCachedCredentials

      public void clearCachedCredentials()
      Clear all credentials cached by manager.
    • useAuth

      public void useAuth(Uri uri, Auth auth)

      Records that auth is to be used under uri, as though a WWW-Authenticate header had been received at that URI.

      This can be used to "preload" manager's auth cache, to avoid an extra HTTP round trip in the case where you know ahead of time that a 401 response will be returned.

      This is only useful for authentication types where the initial Authorization header does not depend on any additional information from the server. (Eg, Basic or NTLM, but not Digest.)

      Parameters:
      uri - the GUri under which auth is to be used
      auth - the SoupAuth to use
    • builder

      public static AuthManager.Builder<? extends AuthManager.Builder> builder()
      A AuthManager.Builder object constructs a AuthManager with the specified properties. Use the various set...() methods to set properties, and finish construction with AuthManager.Builder.build().
      Returns:
      the builder object