Class TlsConnection.Builder<B extends TlsConnection.Builder<B>>
- Type Parameters:
B- the type of the Builder that is returned
- All Implemented Interfaces:
BuilderInterface
- Enclosing class:
TlsConnection
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Finish building theTlsConnectionobject.Emitted during the TLS handshake after the peer certificate has been received.setAdvertisedProtocols(String[] advertisedProtocols) The list of application-layer protocols that the connection advertises that it is willing to speak.setBaseIoStream(IOStream baseIoStream) TheGIOStreamthat the connection wraps.setCertificate(TlsCertificate certificate) The connection's certificate; see g_tls_connection_set_certificate().setDatabase(TlsDatabase database) The certificate database to use when verifying this TLS connection.setInteraction(TlsInteraction interaction) AGTlsInteractionobject to be used when the connection or certificate database need to interact with the user.setRehandshakeMode(TlsRehandshakeMode rehandshakeMode) Deprecated.The rehandshake mode is ignored.setRequireCloseNotify(boolean requireCloseNotify) Whether or not proper TLS close notification is required.setUseSystemCertdb(boolean useSystemCertdb) Deprecated.Use GTlsConnection:database insteadMethods inherited from class org.gnome.gobject.GObject.Builder
onNotifyMethods inherited from class org.javagi.gobject.Builder
addBuilderProperty, connect, connect, connectSignals, getArena, getNames, getValues
-
Constructor Details
-
Builder
protected Builder()Default constructor for aBuilderobject.
-
-
Method Details
-
build
Finish building theTlsConnectionobject. This will callGObject.withProperties(org.gnome.glib.Type, java.lang.String[], org.gnome.gobject.Value[])to create a new GObject instance, which is then cast toTlsConnection.- Overrides:
buildin classIOStream.Builder<B extends TlsConnection.Builder<B>>- Returns:
- a new instance of
TlsConnectionwith the properties that were set in the Builder object.
-
setAdvertisedProtocols
The list of application-layer protocols that the connection advertises that it is willing to speak. See g_tls_connection_set_advertised_protocols().- Parameters:
advertisedProtocols- the value for theadvertised-protocolsproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.60
-
setBaseIoStream
TheGIOStreamthat the connection wraps. The connection holds a reference to this stream, and may run operations on the stream from other threads throughout its lifetime. Consequently, after theGIOStreamhas been constructed, application code may only run its own operations on this stream when noGIOStreamoperations are running.- Parameters:
baseIoStream- the value for thebase-io-streamproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.28
-
setCertificate
The connection's certificate; see g_tls_connection_set_certificate().- Parameters:
certificate- the value for thecertificateproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.28
-
setDatabase
The certificate database to use when verifying this TLS connection. If no certificate database is set, then the default database will be used. See g_tls_backend_get_default_database().When using a non-default database,
GTlsConnectionmust fall back to using theGTlsDatabaseto perform certificate verification using g_tls_database_verify_chain(), which means certificate verification will not be able to make use of TLS session context. This may be less secure. For example, if you create your ownGTlsDatabasethat just wraps the defaultGTlsDatabase, you might expect that you have not changed anything, but this is not true because you may have altered the behavior ofGTlsConnectionby causing it to use g_tls_database_verify_chain(). See the documentation of g_tls_database_verify_chain() for more details on specific security checks that may not be performed. Accordingly, setting a non-default database is discouraged except for specialty applications with unusual security requirements.- Parameters:
database- the value for thedatabaseproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.30
-
setInteraction
AGTlsInteractionobject to be used when the connection or certificate database need to interact with the user. This will be used to prompt the user for passwords where necessary.- Parameters:
interaction- the value for theinteractionproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.30
-
setRehandshakeMode
Deprecated.The rehandshake mode is ignored.The rehandshaking mode. See g_tls_connection_set_rehandshake_mode().- Parameters:
rehandshakeMode- the value for therehandshake-modeproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.28
-
setRequireCloseNotify
Whether or not proper TLS close notification is required. See g_tls_connection_set_require_close_notify().- Parameters:
requireCloseNotify- the value for therequire-close-notifyproperty- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.28
-
setUseSystemCertdb
Deprecated.Use GTlsConnection:database insteadWhether or not the system certificate database will be used to verify peer certificates. See g_tls_connection_set_use_system_certdb().- Parameters:
useSystemCertdb- the value for theuse-system-certdbproperty- Returns:
- the
Builderinstance is returned, to allow method chaining
-
onAcceptCertificate
Emitted during the TLS handshake after the peer certificate has been received. You can examinepeerCert'scertification path by calling g_tls_certificate_get_issuer() on it.For a client-side connection,
peerCertis the server's certificate, and the signal will only be emitted if the certificate was not acceptable according toconn'sGTlsClientConnection:validation_flags. If you would like the certificate to be accepted despiteerrors,returntruefrom the signal handler. Otherwise, if no handler accepts the certificate, the handshake will fail withTlsError.BAD_CERTIFICATE.GLib guarantees that if certificate verification fails, this signal will be emitted with at least one error will be set in
errors,but it does not guarantee that all possible errors will be set. Accordingly, you may not safely decide to ignore any particular type of error. For example, it would be incorrect to ignoreTlsCertificateFlags.EXPIREDif you want to allow expired certificates, because this could potentially be the only error flag set even if other problems exist with the certificate.For a server-side connection,
peerCertis the certificate presented by the client, if this was requested via the server'sGTlsServerConnection:authentication_mode. On the server side, the signal is always emitted when the client presents a certificate, and the certificate will only be accepted if a handler returnstrue.Note that if this signal is emitted as part of asynchronous I/O in the main thread, then you should not attempt to interact with the user before returning from the signal handler. If you want to let the user decide whether or not to accept the certificate, you would have to return
falsefrom the signal handler on the first attempt, and then after the connection attempt returns aTlsError.BAD_CERTIFICATE, you can interact with the user, and if the user decides to accept the certificate, remember that fact, create a new connection, and returntruefrom the signal handler the next time.If you are doing I/O in another thread, you do not need to worry about this, and can simply block in the signal handler until the UI thread returns an answer.
- Parameters:
handler- the signal handler- Returns:
- the
Builderinstance is returned, to allow method chaining - Since:
- 2.28
- See Also:
-