Class ContactReplyMethodDialogController
- All Implemented Interfaces:
javafx.fxml.Initializable
,Preparable<Configuration>
Call getResult()
after the dialog has been closed to get the user's input.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate javafx.scene.layout.BorderPane
private javafx.scene.control.CheckBox
private @NonNull ContactMethods
The user's contact information.private javafx.scene.text.Text
private javafx.scene.control.TextField
private PasswordGenerator
Used to create random passphrases for symmetric encryption.private javafx.scene.text.Text
private javafx.scene.text.Text
private String
The content of the PGP key file that the user has chosen.private javafx.scene.control.RadioButton
private javafx.scene.control.RadioButton
private javafx.scene.control.RadioButton
private javafx.scene.control.RadioButton
private javafx.scene.control.RadioButton
private javafx.scene.control.RadioButton
private javafx.scene.control.RadioButton
private javafx.scene.control.RadioButton
private javafx.scene.control.RadioButton
private ResourceBundle
private boolean
Whether the user's message was sent successfully.private javafx.scene.control.TabPane
private javafx.scene.control.Tab
private javafx.scene.control.Tab
private javafx.scene.control.Tab
private javafx.scene.control.Tab
private javafx.scene.control.Tab
private javafx.scene.control.TextArea
private javafx.scene.control.TextField
private javafx.scene.control.TextField
private javafx.scene.control.TextField
private javafx.scene.control.TextField
private javafx.scene.control.TextField
private javafx.scene.control.TextField
private javafx.scene.layout.VBox
private javafx.scene.layout.VBox
private javafx.scene.layout.VBox
private javafx.scene.layout.VBox
private javafx.scene.layout.VBox
private javafx.scene.layout.VBox
private javafx.scene.layout.VBox
private javafx.scene.layout.VBox
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Displays a file chooser dialog that allows the user to choose a PGP key file.void
close()
Exits the contact reply dialog.void
confirm()
Validates the user's contact information (if the user's contact information is invalid, an error message is displayed in a popup) and closes the dialog if the user's contact information is valid, with the contact information stored in thecontactMethods
object.@NonNull Optional
<ContactMethods> @NonNull FuzzyBoolean
Non-blocking method to check whether the user's message was sent successfully.void
initialize
(URL location, ResourceBundle resourceBundle) Initializes the contact reply dialog.boolean
Generates a new passphrase by callingPasswordGenerator.generatePassphrase()
and updates thepassword field
and thepassword strength indicator
accordingly.void
Opens the university's Matrix web interface in the default browser.void
Updates thepassword strength indicator
based on the user's input in thepassword field
.void
prepare
(@NonNull Configuration configuration) Prepares the contact reply dialog for operation by creating a newContactMethods
object with the user name from the givenconfiguration
.void
Updates thepassword strength indicator
based on the givenstrength
.(package private) boolean
validate()
Checks that the user has entered valid contact information.private @NonNull ContactReplyMethodDialogController.ValidationResult
Validates that the password entered by the user for symmetric encryption is strong enough, i.e.private @NonNull ContactReplyMethodDialogController.ValidationResult
Checks that the user has entered a valid PGP public key that can be used to encrypt messages.private @NonNull ContactReplyMethodDialogController.ValidationResult
If "secure e-mail provider" is selected as the preferred contact method:private @NonNull ContactReplyMethodDialogController.ValidationResult
Checks that the user has entered a valid Signal ID.private @NonNull ContactReplyMethodDialogController.ValidationResult
Checks that the user has entered a valid SimpleX ID.private @NonNull ContactReplyMethodDialogController.ValidationResult
Checks that the user has entered a valid Threema ID.private @NonNull ContactReplyMethodDialogController.ValidationResult
If Tuta is selected as the preferred contact method:
-
Field Details
-
result
private boolean resultWhether the user's message was sent successfully. -
contactMethods
The user's contact information. This is guaranteed to be non-null by theprepare(Configuration)
method. -
passwordGenerator
Used to create random passphrases for symmetric encryption. This field is set tonull
by default. -
pgpKeyFileContent
The content of the PGP key file that the user has chosen. This field is set tonull
by default and is only set if the user has chosen a PGP key file. This field is used to store the content of the PGP key file temporarily until the user submits the dialog.Why is this necessary?
-
For all other input method, the user's input is automatically temporarily stored in the respective
element of the graphical user interface (GUI). For example, the user's Tuta email address is stored in
the
textFieldTuta
. - The "Choose file" dialog, on the other hand, is not automatically invoked by the GUI, but by a manually defined on-click event attached to the "Choose file" button. This means that we are responsible for displaying the file chooser dialog and thus also for correctly treating the file returned by the dialog.
- Why don't we just store the PGP file content in the
-
For all other input method, the user's input is automatically temporarily stored in the respective
element of the graphical user interface (GUI). For example, the user's Tuta email address is stored in
the
-
resourceBundle
-
borderPaneContactReply
private javafx.scene.layout.BorderPane borderPaneContactReply -
tabPaneMain
private javafx.scene.control.TabPane tabPaneMain -
tabViaEmail
private javafx.scene.control.Tab tabViaEmail -
tabViaMessenger
private javafx.scene.control.Tab tabViaMessenger -
radioPassword
private javafx.scene.control.RadioButton radioPassword -
radioTuta
private javafx.scene.control.RadioButton radioTuta -
radioPGP
private javafx.scene.control.RadioButton radioPGP -
radioSecureProvider
private javafx.scene.control.RadioButton radioSecureProvider -
radioUnencrypted
private javafx.scene.control.RadioButton radioUnencrypted -
vBoxPassword
private javafx.scene.layout.VBox vBoxPassword -
vBoxTuta
private javafx.scene.layout.VBox vBoxTuta -
vBoxPGP
private javafx.scene.layout.VBox vBoxPGP -
vBoxSecureProvider
private javafx.scene.layout.VBox vBoxSecureProvider -
textFieldTuta
private javafx.scene.control.TextField textFieldTuta -
textFieldSecureProvider
private javafx.scene.control.TextField textFieldSecureProvider -
radioMatrix
private javafx.scene.control.RadioButton radioMatrix -
radioThreema
private javafx.scene.control.RadioButton radioThreema -
radioSignal
private javafx.scene.control.RadioButton radioSignal -
radioSimpleX
private javafx.scene.control.RadioButton radioSimpleX -
vBoxMatrix
private javafx.scene.layout.VBox vBoxMatrix -
vBoxThreema
private javafx.scene.layout.VBox vBoxThreema -
vBoxSignal
private javafx.scene.layout.VBox vBoxSignal -
vBoxSimpleX
private javafx.scene.layout.VBox vBoxSimpleX -
textFieldThreema
private javafx.scene.control.TextField textFieldThreema -
textFieldSignal
private javafx.scene.control.TextField textFieldSignal -
textFieldSimpleX
private javafx.scene.control.TextField textFieldSimpleX -
passwordField
private javafx.scene.control.TextField passwordField -
passwordStrength
private javafx.scene.text.Text passwordStrength -
checkBoxStorePasswordInKeePassXC
private javafx.scene.control.CheckBox checkBoxStorePasswordInKeePassXC -
labelStorePasswordInKeePassXC
private javafx.scene.text.Text labelStorePasswordInKeePassXC -
tabPgpUrl
private javafx.scene.control.Tab tabPgpUrl -
textFieldPgpUrl
private javafx.scene.control.TextField textFieldPgpUrl -
tabPgpPaste
private javafx.scene.control.Tab tabPgpPaste -
textAreaPgpPaste
private javafx.scene.control.TextArea textAreaPgpPaste -
tabPgpFile
private javafx.scene.control.Tab tabPgpFile -
pgpFileName
private javafx.scene.text.Text pgpFileName
-
-
Constructor Details
-
ContactReplyMethodDialogController
public ContactReplyMethodDialogController()
-
-
Method Details
-
getResult
- Specified by:
getResult
in classDialogController<Configuration,
ContactMethods> - Returns:
- The
contactMethods
object that contains the contact information that the user has entered in the dialog.
-
getSuccess
Non-blocking method to check whether the user's message was sent successfully. This method should be called after the dialog has been closed, becauseresult
is only set totrue
after the user has submitted the dialog, i.e. after the dialog has been closed.- Overrides:
getSuccess
in classController<Configuration>
- Returns:
- Whether the user's message was sent successfully.
-
prepare
Prepares the contact reply dialog for operation by creating a newContactMethods
object with the user name from the givenconfiguration
.Important:This method must be called immediately after
initialize(URL, ResourceBundle)
, because theContactReplyMethodDialogController
depends on thecontactMethods
created by this method.- Specified by:
prepare
in interfacePreparable<Configuration>
- Overrides:
prepare
in classController<Configuration>
- Parameters:
configuration
- Theuser name
will be used to pre-fill the contact methods.- Throws:
IllegalArgumentException
- IfConfiguration.getUser()
returns an emptyOptional
.- See Also:
-
initialize
Initializes the contact reply dialog. It is mandatory to callprepare(page.codeberg.friedolyn.configuration.Configuration)
immediately after calling this method, because theContactReplyMethodDialogController
depends on thecontactMethods
created by theprepare(page.codeberg.friedolyn.configuration.Configuration)
method.- Parameters:
location
- The location used to resolve relative paths for the root object, ornull
if the location is not known.resourceBundle
- The resources used to localize the root object, ornull
if the root object was not localized.
-
newPassword
public boolean newPassword()Generates a new passphrase by callingPasswordGenerator.generatePassphrase()
and updates thepassword field
and thepassword strength indicator
accordingly.- Returns:
true
if the new password was generated successfully,false
otherwise.
-
passwordTypeAction
public void passwordTypeAction()Updates thepassword strength indicator
based on the user's input in thepassword field
. -
updatePasswordStrength
Updates thepassword strength indicator
based on the givenstrength
.- Parameters:
strength
- The new password strength.
-
choosePgpKeyFile
public void choosePgpKeyFile()Displays a file chooser dialog that allows the user to choose a PGP key file. The content of the chosen file is then validated and stored in thepgpKeyFileContent
field. If the file is invalid, an error message is displayed in a popup. -
confirm
public void confirm()Validates the user's contact information (if the user's contact information is invalid, an error message is displayed in a popup) and closes the dialog if the user's contact information is valid, with the contact information stored in thecontactMethods
object.- Specified by:
confirm
in classDialogController<Configuration,
ContactMethods>
-
validatePassword
Validates that the password entered by the user for symmetric encryption is strong enough, i.e. the input of thepassword field
is at leastgood
. If the password is valid, it is stored in thecontactMethods
as the user'ssymmetric password
. If symmetric encryption is selected as the preferred contact method, an error message is displayed in a popup in case the password is not strong enough.- Returns:
true
if the password is strong enough,false
otherwise.
-
validateTuta
If Tuta is selected as the preferred contact method:
Validates that the user has entered an e-mail address. If the e-mail address is invalid, an error message is displayed in a popup. Additionally, it is checked that it's a valid Tuta email address, i.e. that it ends with one of the following domains:- tuta.com
- tuta.io
- tutanota.com
- tutamail.com
- tutanota.de
- keemail.me
If the Tuta e-mail address is considered valid, it is stored in the
contactMethods
as the user'sTuta e-mail address
.If Tuta is not selected as the preferred contact method:
It will be validated that the e-mail address is actually an e-mail address, but it will not be checked whether it is a Tuta e-mail address. No confirmation or error popups will be displayed, but the e-mail address will be stored in thecontactMethods
as the user'sTuta e-mail address
.- Returns:
true
if the user has entered a valid e-mail address that, according to the user, belongs to their Tuta account,false
otherwise.
-
validatePGP
Checks that the user has entered a valid PGP public key that can be used to encrypt messages. If the PGP public key is valid, it is stored in thecontactMethods
as the user'sPGP public key
.If the user has selected PGP as their preferred contact method, an error message is displayed in a popup if the public key is invalid.
- Returns:
true
if the user has entered a valid PGP public key,false
otherwise.
-
validateSecureProvider
@NonNull private @NonNull ContactReplyMethodDialogController.ValidationResult validateSecureProvider()If "secure e-mail provider" is selected as the preferred contact method:
Checks that the user has entered a valid email address. If the email address is invalid, an error message is displayed in a popup. Additionally, it is checked that it's a valid secure provider email address, i.e. that it ends with one of the following domains:- any Tuta domain (see
validateTuta()
) - proton.me
- protonmail.com
- mailbox.org
- startmail.com
- posteo.com
- posteo.us
- posteo.net
If the secure provider email address is considered valid, it is stored in the
contactMethods
as the user'ssecure provider email address
.If "secure e-mail provider" is not selected as the preferred contact method:
It will be validated that the email address is actually an email address, but it will not be checked whether it is a secure provider email address. No confirmation or error popups will be displayed, but the email address will be stored in thecontactMethods
as the user'sContactMethods.setSecureProviderEmailAddress(String)
secure provider email address} if it is valid.- Returns:
true
if the user has entered a valid e-mail address that, according to the user, belongs to their secure e-mail inbox,false
otherwise.
- any Tuta domain (see
-
validateThreema
Checks that the user has entered a valid Threema ID. If the Threema ID is valid, it is stored in thecontactMethods
as the user'sThreema ID
.If the user has selected Threema as their preferred contact method, an error message is displayed in a popup if the Threema ID is invalid.
A valid Threema ID consists of exactly 8 alphanumeric characters. Optionally, the user can also enter a Threema ID in the form of a Threema ID link, e.g.
https://threema.id/H3BK2FVH
(with or without the protocol).- Returns:
true
if the user has entered a valid Threema ID,false
otherwise.
-
validateSignal
Checks that the user has entered a valid Signal ID. If the Signal ID is valid, it is stored in thecontactMethods
as the user'sSignal ID
.If the user has selected Signal as their preferred contact method, an error message is displayed in a popup if the Signal ID is invalid.
A valid Signal ID consists of either a Signal ID link, e.g.
https://signal.me/#eu/iOiKCM7MZ9xxlA8SqLasWKsayETmvg8PakayRRXHhpL3bzpLVrdGFJingk/6mGV1
(with or without the protocol andwww.
) or a phone number with at least 6 digits and at most 20 digits, optionally with spaces, hyphens, parentheses and plus signs.- Returns:
true
if the user has entered a valid Signal ID,false
otherwise.
-
validateSimpleX
Checks that the user has entered a valid SimpleX ID.If the SimpleX ID is valid, it is stored in the
contactMethods
as the user'sSimpleX ID
.If the user has selected SimpleX as their preferred contact method, an error message is displayed in a popup if the SimpleX ID is invalid.
A valid SimpleX ID consists of a SimpleX ID link, e.g.
https://simplex.chat/contact/#/?v=1-2&smp=smp%3A%2F%2F0YuTwO05YJWS8rkjn9eLJDjQhFKvIYd8d4xG8X1blIU%3D%40smp8.simplex.im%2FsSCNS1itthj8oKaSzgrKV0xKgrbNPlFG%23%2F%3Fv%3D1-2%26dh%3DMCowBQYDK2VuAyEAlldSlwhJ1JyafXkpPnD1J65805WkVNemSpzEpYJnoCo%253D%26srv%3Dbeccx4yfxxbvyhqypaavemqurytl6hozr47wfc7uuecacjqdvwpw2xid.onion
(with or without the protocol andwww.
).- Returns:
true
if the user has entered a valid SimpleX ID,false
otherwise.
-
validate
boolean validate()Checks that the user has entered valid contact information. If the user has not selected a contact method, an error message is displayed in a popup. Otherwise, the contact information is stored in thecontactMethods
.More specifically, ALL valid contact information entered by the user is stored in the
contactMethods
, not just the preferred contact method.- Returns:
true
if the user has entered valid contact information,false
otherwise.
-
openMatrixWeb
public void openMatrixWeb()Opens the university's Matrix web interface in the default browser. -
close
public void close()Exits the contact reply dialog.- Specified by:
close
in classController<Configuration>
-