Class TlsInteraction
- All Implemented Interfaces:
Proxy
GTlsInteraction provides a mechanism for the TLS connection and database
code to interact with the user. It can be used to ask the user for passwords.
To use a GTlsInteraction with a TLS connection use
TlsConnection.setInteraction(org.gnome.gio.TlsInteraction).
Callers should instantiate a derived class that implements the various interaction methods to show the required dialogs.
Callers should use the 'invoke' functions like
invokeAskPassword(org.gnome.gio.TlsPassword, org.gnome.gio.Cancellable) to run interaction methods.
These functions make sure that the interaction is invoked in the main loop
and not in the current thread, if the current thread is not running the
main loop.
Derived classes can choose to implement whichever interactions methods they’d
like to support by overriding those virtual methods in their class
initialization function. Any interactions not implemented will return
G_TLS_INTERACTION_UNHANDLED. If a derived class implements an async method,
it must also implement the corresponding finish method.
- Since:
- 2.30
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTlsInteraction.Builder<B extends TlsInteraction.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classThe class forGTlsInteraction.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new TlsInteraction.TlsInteraction(MemorySegment address) Create a TlsInteraction proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionaskPassword(TlsPassword password, @Nullable Cancellable cancellable) Run synchronous interaction to ask the user for a password.voidaskPasswordAsync(TlsPassword password, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Run asynchronous interaction to ask the user for a password.askPasswordFinish(AsyncResult result) Complete an ask password user interaction request.protected TlsInteractionasParent()Returns this instance as if it were its parent type.static TlsInteraction.Builder<? extends TlsInteraction.Builder> builder()ATlsInteraction.Builderobject constructs aTlsInteractionwith the specified properties.static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the TlsInteraction classinvokeAskPassword(TlsPassword password, @Nullable Cancellable cancellable) Invoke the interaction to ask the user for a password.invokeRequestCertificate(TlsConnection connection, TlsCertificateRequestFlags flags, @Nullable Cancellable cancellable) Invoke the interaction to ask the user to choose a certificate to use with the connection.requestCertificate(TlsConnection connection, TlsCertificateRequestFlags flags, @Nullable Cancellable cancellable) Run synchronous interaction to ask the user to choose a certificate to use with the connection.voidrequestCertificateAsync(TlsConnection connection, TlsCertificateRequestFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Run asynchronous interaction to ask the user for a certificate to use with the connection.requestCertificateFinish(AsyncResult result) Complete a request certificate user interaction request.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
TlsInteraction
Create a TlsInteraction proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
TlsInteraction
public TlsInteraction()Creates a new TlsInteraction.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
askPassword
public TlsInteractionResult askPassword(TlsPassword password, @Nullable Cancellable cancellable) throws GErrorException Run synchronous interaction to ask the user for a password. In general, g_tls_interaction_invoke_ask_password() should be used instead of this function.Derived subclasses usually implement a password prompt, although they may also choose to provide a password from elsewhere. The
passwordvalue will be filled in and thencallbackwill be called. Alternatively the user may abort this password request, which will usually abort the TLS connection.If the interaction is cancelled by the cancellation object, or by the user then
TlsInteractionResult.FAILEDwill be returned with an error that contains aIOErrorEnum.CANCELLEDerror code. Certain implementations may not support immediate cancellation.- Parameters:
password- aGTlsPasswordobjectcancellable- an optionalGCancellablecancellation object- Returns:
- The status of the ask password interaction.
- Throws:
GErrorException- seeGError- Since:
- 2.30
-
askPasswordAsync
public void askPasswordAsync(TlsPassword password, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Run asynchronous interaction to ask the user for a password. In general, g_tls_interaction_invoke_ask_password() should be used instead of this function.Derived subclasses usually implement a password prompt, although they may also choose to provide a password from elsewhere. The
passwordvalue will be filled in and thencallbackwill be called. Alternatively the user may abort this password request, which will usually abort the TLS connection.If the interaction is cancelled by the cancellation object, or by the user then
TlsInteractionResult.FAILEDwill be returned with an error that contains aIOErrorEnum.CANCELLEDerror code. Certain implementations may not support immediate cancellation.Certain implementations may not support immediate cancellation.
- Parameters:
password- aGTlsPasswordobjectcancellable- an optionalGCancellablecancellation objectcallback- will be called when the interaction completes- Since:
- 2.30
-
askPasswordFinish
Complete an ask password user interaction request. This should be once the g_tls_interaction_ask_password_async() completion callback is called.If
TlsInteractionResult.HANDLEDis returned, then theGTlsPasswordpassed to g_tls_interaction_ask_password() will have its password filled in.If the interaction is cancelled by the cancellation object, or by the user then
TlsInteractionResult.FAILEDwill be returned with an error that contains aIOErrorEnum.CANCELLEDerror code.- Parameters:
result- the result passed to the callback- Returns:
- The status of the ask password interaction.
- Throws:
GErrorException- seeGError- Since:
- 2.30
-
invokeAskPassword
public TlsInteractionResult invokeAskPassword(TlsPassword password, @Nullable Cancellable cancellable) throws GErrorException Invoke the interaction to ask the user for a password. It invokes this interaction in the main loop, specifically theGMainContextreturned by g_main_context_get_thread_default() when the interaction is created. This is called by called byGTlsConnectionorGTlsDatabaseto ask the user for a password.Derived subclasses usually implement a password prompt, although they may also choose to provide a password from elsewhere. The
passwordvalue will be filled in and thencallbackwill be called. Alternatively the user may abort this password request, which will usually abort the TLS connection.The implementation can either be a synchronous (eg: modal dialog) or an asynchronous one (eg: modeless dialog). This function will take care of calling which ever one correctly.
If the interaction is cancelled by the cancellation object, or by the user then
TlsInteractionResult.FAILEDwill be returned with an error that contains aIOErrorEnum.CANCELLEDerror code. Certain implementations may not support immediate cancellation.- Parameters:
password- aGTlsPasswordobjectcancellable- an optionalGCancellablecancellation object- Returns:
- The status of the ask password interaction.
- Throws:
GErrorException- seeGError- Since:
- 2.30
-
invokeRequestCertificate
public TlsInteractionResult invokeRequestCertificate(TlsConnection connection, TlsCertificateRequestFlags flags, @Nullable Cancellable cancellable) throws GErrorException Invoke the interaction to ask the user to choose a certificate to use with the connection. It invokes this interaction in the main loop, specifically theGMainContextreturned by g_main_context_get_thread_default() when the interaction is created. This is called by called byGTlsConnectionwhen the peer requests a certificate during the handshake.Derived subclasses usually implement a certificate selector, although they may also choose to provide a certificate from elsewhere. Alternatively the user may abort this certificate request, which may or may not abort the TLS connection.
The implementation can either be a synchronous (eg: modal dialog) or an asynchronous one (eg: modeless dialog). This function will take care of calling which ever one correctly.
If the interaction is cancelled by the cancellation object, or by the user then
TlsInteractionResult.FAILEDwill be returned with an error that contains aIOErrorEnum.CANCELLEDerror code. Certain implementations may not support immediate cancellation.- Parameters:
connection- aGTlsConnectionobjectflags- flags providing more information about the requestcancellable- an optionalGCancellablecancellation object- Returns:
- The status of the certificate request interaction.
- Throws:
GErrorException- seeGError- Since:
- 2.40
-
requestCertificate
public TlsInteractionResult requestCertificate(TlsConnection connection, TlsCertificateRequestFlags flags, @Nullable Cancellable cancellable) throws GErrorException Run synchronous interaction to ask the user to choose a certificate to use with the connection. In general, g_tls_interaction_invoke_request_certificate() should be used instead of this function.Derived subclasses usually implement a certificate selector, although they may also choose to provide a certificate from elsewhere. Alternatively the user may abort this certificate request, which will usually abort the TLS connection.
If
TlsInteractionResult.HANDLEDis returned, then theGTlsConnectionpassed to g_tls_interaction_request_certificate() will have had itsGTlsConnection:certificate filled in.If the interaction is cancelled by the cancellation object, or by the user then
TlsInteractionResult.FAILEDwill be returned with an error that contains aIOErrorEnum.CANCELLEDerror code. Certain implementations may not support immediate cancellation.- Parameters:
connection- aGTlsConnectionobjectflags- flags providing more information about the requestcancellable- an optionalGCancellablecancellation object- Returns:
- The status of the request certificate interaction.
- Throws:
GErrorException- seeGError- Since:
- 2.40
-
requestCertificateAsync
public void requestCertificateAsync(TlsConnection connection, TlsCertificateRequestFlags flags, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Run asynchronous interaction to ask the user for a certificate to use with the connection. In general, g_tls_interaction_invoke_request_certificate() should be used instead of this function.Derived subclasses usually implement a certificate selector, although they may also choose to provide a certificate from elsewhere.
callbackwill be called when the operation completes. Alternatively the user may abort this certificate request, which will usually abort the TLS connection.- Parameters:
connection- aGTlsConnectionobjectflags- flags providing more information about the requestcancellable- an optionalGCancellablecancellation objectcallback- will be called when the interaction completes- Since:
- 2.40
-
requestCertificateFinish
Complete a request certificate user interaction request. This should be once the g_tls_interaction_request_certificate_async() completion callback is called.If
TlsInteractionResult.HANDLEDis returned, then theGTlsConnectionpassed to g_tls_interaction_request_certificate_async() will have had itsGTlsConnection:certificate filled in.If the interaction is cancelled by the cancellation object, or by the user then
TlsInteractionResult.FAILEDwill be returned with an error that contains aIOErrorEnum.CANCELLEDerror code.- Parameters:
result- the result passed to the callback- Returns:
- The status of the request certificate interaction.
- Throws:
GErrorException- seeGError- Since:
- 2.40
-
builder
ATlsInteraction.Builderobject constructs aTlsInteractionwith the specified properties. Use the variousset...()methods to set properties, and finish construction withTlsInteraction.Builder.build().- Returns:
- the builder object
-