Class Auth

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
Auth.Auth$Impl, AuthBasic, AuthDigest, AuthNegotiate, AuthNTLM

@Generated("org.javagi.JavaGI") public abstract class Auth extends GObject

The abstract base class for handling authentication.

Specific HTTP Authentication mechanisms are implemented by its subclasses, but applications never need to be aware of the specific subclasses being used.

Auth objects store the authentication data associated with a given bit of web space. They are created automatically by Session.

  • Constructor Details

    • Auth

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

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

    • getType

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

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

      protected Auth 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
    • new_

      public static @Nullable Auth new_(Type type, Message msg, String authHeader)

      Creates a new Auth of type type with the information from msg and authHeader.

      This is called by Session; you will normally not create auths yourself.

      Parameters:
      type - the type of auth to create (a subtype of Auth)
      msg - the SoupMessage the auth is being created for
      authHeader - the WWW-Authenticate/Proxy-Authenticate header
    • authenticate

      public void authenticate(String username, String password)

      Call this on an auth to authenticate it.

      Normally this will cause the auth's message to be requeued with the new authentication info.

      Parameters:
      username - the username provided by the user or client
      password - the password provided by the user or client
    • canAuthenticate

      public boolean canAuthenticate()
      Tests if this Auth is able to authenticate by providing credentials to the authenticate(String, String).
      Returns:
      true if this Auth is able to accept credentials.
    • cancel

      public void cancel()

      Call this on an auth to cancel it.

      You need to cancel an auth to complete an asynchronous authenticate operation when no credentials are provided (authenticate(String, String) is not called). The Auth will be cancelled on dispose if it hasn't been authenticated.

    • freeProtectionSpace

      public void freeProtectionSpace(SList<MemorySegment> space)
      Frees space.
      Parameters:
      space - the return value from getProtectionSpace(Uri)
    • getAuthority

      public String getAuthority()
      Returns the authority (host:port) that this Auth is associated with.
      Returns:
      the authority
    • getAuthorization

      public String getAuthorization(Message msg)

      Generates an appropriate "Authorization" header for msg.

      (The session will only call this if isAuthenticated() returned true.)

      Parameters:
      msg - the SoupMessage to be authorized
      Returns:
      the "Authorization" header, which must be freed.
    • getInfo

      public String getInfo()

      Gets an opaque identifier for auth.

      The identifier can be used as a hash key or the like. Auth objects from the same server with the same identifier refer to the same authentication domain (eg, the URLs associated with them take the same usernames and passwords).

      Returns:
      the identifier
    • getProtectionSpace

      public SList<String> getProtectionSpace(Uri sourceUri)

      Returns a list of paths on the server which this Auth extends over.

      (All subdirectories of these paths are also assumed to be part of auth's protection space, unless otherwise discovered not to be.)

      Parameters:
      sourceUri - the URI of the request that this Auth was generated in response to.
      Returns:
      the list of paths, which can be freed with freeProtectionSpace(SList).
    • getRealm

      public String getRealm()

      Returns auth's realm.

      This is an identifier that distinguishes separate authentication spaces on a given server, and may be some string that is meaningful to the user. (Although it is probably not localized.)

      Returns:
      the realm name
    • getSchemeName

      public String getSchemeName()
      soup_auth_get_scheme_name: (attributes org.gtk.Method.get_property=scheme-name) Returns auth's scheme name. (Eg, "Basic", "Digest", or "NTLM")
      Returns:
      the scheme name
    • isAuthenticated

      public boolean isAuthenticated()
      Tests if this Auth has been given a username and password.
      Returns:
      true if this Auth has been given a username and password
    • isCancelled

      public boolean isCancelled()
      Tests if this Auth has been cancelled
      Returns:
      true if this Auth has been cancelled
    • isForProxy

      public boolean isForProxy()
      Tests whether or not this Auth is associated with a proxy server rather than an "origin" server.
      Returns:
      true or false
    • isReady

      public boolean isReady(Message msg)

      Tests if this Auth is ready to make a request for msg with.

      For most auths, this is equivalent to isAuthenticated(), but for some auth types (eg, NTLM), the auth may be sendable (eg, as an authentication request) even before it is authenticated.

      Parameters:
      msg - a SoupMessage
      Returns:
      true if this Auth is ready to make a request with.
    • update

      public boolean update(Message msg, String authHeader)

      Updates this Auth with the information from msg and authHeader, possibly un-authenticating it.

      As with Auth(), this is normally only used by Session.

      Parameters:
      msg - the SoupMessage this Auth is being updated for
      authHeader - the WWW-Authenticate/Proxy-Authenticate header
      Returns:
      true if this Auth is still a valid (but potentially unauthenticated) Auth. false if something about authParams could not be parsed or incorporated into this Auth at all.
    • update

      protected boolean update(Message msg, HashTable<MemorySegment, MemorySegment> authHeader)

      Updates this Auth with the information from msg and authHeader, possibly un-authenticating it.

      As with Auth(), this is normally only used by Session.

      Parameters:
      msg - the SoupMessage this Auth is being updated for
      authHeader - the WWW-Authenticate/Proxy-Authenticate header
      Returns:
      true if this Auth is still a valid (but potentially unauthenticated) Auth. false if something about authParams could not be parsed or incorporated into this Auth at all.