Class AuthenticationRequest

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public final class AuthenticationRequest extends GObject

Represents an authentication request.

Whenever a client attempts to load a page protected by HTTP authentication, credentials will need to be provided to authorize access. To allow the client to decide how it wishes to handle authentication, WebKit will fire a WebKitWebView::authenticate signal with a WebKitAuthenticationRequest object to provide client side authentication support. Credentials are exposed through the WebKitCredential object.

In case the client application does not wish to handle this signal WebKit will provide a default handler. To handle authentication asynchronously, simply increase the reference count of the WebKitAuthenticationRequest object.

  • Constructor Details

    • AuthenticationRequest

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

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

    • getType

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

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

      protected AuthenticationRequest 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
    • authenticate

      public void authenticate(@Nullable Credential credential)

      Authenticate the WebKitAuthenticationRequest.

      Authenticate the WebKitAuthenticationRequest using the WebKitCredential supplied. To continue without credentials, pass null as credential.

      Parameters:
      credential - A WebKitCredential, or null
      Since:
      2.2
    • canSaveCredentials

      public boolean canSaveCredentials()

      Determine whether this WebKitAuthenticationRequest should allow the storage of credentials.

      Determine whether the authentication method associated with this WebKitAuthenticationRequest should allow the storage of credentials. This will return false if WebKit doesn't support credential storing, if private browsing is enabled, or if persistent credential storage has been disabled in WebKitWebsiteDataManager, unless credentials saving has been explicitly enabled with webkit_authentication_request_set_can_save_credentials().

      Returns:
      true if WebKit can store credentials or false otherwise.
      Since:
      2.2
    • cancel

      public void cancel()

      Cancel the authentication challenge.

      This will also cancel the page loading and result in a WebKitWebView::load-failed signal with a WebKitNetworkError of type NetworkError.CANCELLED being emitted.

      Since:
      2.2
    • getCertificatePinFlags

      public Set<TlsPasswordFlags> getCertificatePinFlags()
      Get the GTlsPasswordFlags of the AuthenticationScheme.CLIENT_CERTIFICATE_PIN_REQUESTED authentication challenge.
      Returns:
      a GTlsPasswordFlags
      Since:
      2.34
    • getHost

      public String getHost()
      Get the host that this authentication challenge is applicable to.
      Returns:
      The host of request.
      Since:
      2.2
    • getPort

      public int getPort()
      Get the port that this authentication challenge is applicable to.
      Returns:
      The port of request.
      Since:
      2.2
    • getProposedCredential

      public Credential getProposedCredential()

      Get the WebKitCredential of the proposed authentication challenge.

      Get the WebKitCredential of the proposed authentication challenge that was stored from a previous session. The client can use this directly for authentication or construct their own WebKitCredential.

      Returns:
      A WebKitCredential encapsulating credential details or null if there is no stored credential.
      Since:
      2.2
    • getRealm

      public String getRealm()
      Get the realm that this authentication challenge is applicable to.
      Returns:
      The realm of request.
      Since:
      2.2
    • getScheme

      public AuthenticationScheme getScheme()
      Get the authentication scheme of the authentication challenge.
      Returns:
      The WebKitAuthenticationScheme of request.
      Since:
      2.2
    • getSecurityOrigin

      public SecurityOrigin getSecurityOrigin()
      Get the WebKitSecurityOrigin that this authentication challenge is applicable to.
      Returns:
      a newly created WebKitSecurityOrigin.
      Since:
      2.30
    • isForProxy

      public boolean isForProxy()

      Determine whether the authentication challenge is associated with a proxy server.

      Determine whether the authentication challenge is associated with a proxy server rather than an "origin" server.

      Returns:
      true if authentication is for a proxy or false otherwise.
      Since:
      2.2
    • isRetry

      public boolean isRetry()
      Determine whether this this is a first attempt or a retry for this authentication challenge.
      Returns:
      true if authentication attempt is a retry or false otherwise.
      Since:
      2.2
    • setCanSaveCredentials

      public void setCanSaveCredentials(boolean enabled)

      Set whether the authentication method associated with this AuthenticationRequest should allow the storage of credentials.

      Set whether the authentication method associated with this AuthenticationRequest should allow the storage of credentials. This should be used by applications handling their own credentials storage to indicate that it should be supported even when internal credential storage is disabled or unsupported. Note that storing of credentials will not be allowed on ephemeral sessions in any case.

      Parameters:
      enabled - value to set
      Since:
      2.30
    • setProposedCredential

      public void setProposedCredential(Credential credential)

      Set the WebKitCredential of the proposed authentication challenge.

      Set the WebKitCredential of the proposed authentication challenge that was stored from a previous session. This should only be used by applications handling their own credential storage. (When using the default WebKit credential storage, webkit_authentication_request_get_proposed_credential() already contains previously-stored credentials.) Passing a null credential will clear the proposed credential.

      Parameters:
      credential - a WebKitCredential, or null
      Since:
      2.30
    • onAuthenticated

      This signal is emitted when the user authentication request succeeded. Applications handling their own credential storage should connect to this signal to save the credentials.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.30
      See Also:
    • emitAuthenticated

      public void emitAuthenticated(@Nullable Credential credential)
    • onCancelled

      This signal is emitted when the user authentication request is cancelled. It allows the application to dismiss its authentication dialog in case of page load failure for example.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.2
      See Also:
    • emitCancelled

      public void emitCancelled()
      Emits the "cancelled" signal. See onCancelled(AuthenticationRequest.CancelledCallback).
    • builder

      A AuthenticationRequest.Builder object constructs a AuthenticationRequest with the specified properties. Use the various set...() methods to set properties, and finish construction with AuthenticationRequest.Builder.build().
      Returns:
      the builder object