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.BorderPaneprivate javafx.scene.control.CheckBoxprivate @NonNull ContactMethodsThe user's contact information.private javafx.scene.text.Textprivate javafx.scene.control.TextFieldprivate PasswordGeneratorUsed to create random passphrases for symmetric encryption.private javafx.scene.text.Textprivate javafx.scene.text.Textprivate StringThe content of the PGP key file that the user has chosen.private javafx.scene.control.RadioButtonprivate javafx.scene.control.RadioButtonprivate javafx.scene.control.RadioButtonprivate javafx.scene.control.RadioButtonprivate javafx.scene.control.RadioButtonprivate javafx.scene.control.RadioButtonprivate javafx.scene.control.RadioButtonprivate javafx.scene.control.RadioButtonprivate javafx.scene.control.RadioButtonprivate ResourceBundleprivate booleanWhether the user's message was sent successfully.private javafx.scene.control.TabPaneprivate javafx.scene.control.Tabprivate javafx.scene.control.Tabprivate javafx.scene.control.Tabprivate javafx.scene.control.Tabprivate javafx.scene.control.Tabprivate javafx.scene.control.TextAreaprivate javafx.scene.control.TextFieldprivate javafx.scene.control.TextFieldprivate javafx.scene.control.TextFieldprivate javafx.scene.control.TextFieldprivate javafx.scene.control.TextFieldprivate javafx.scene.control.TextFieldprivate javafx.scene.layout.VBoxprivate javafx.scene.layout.VBoxprivate javafx.scene.layout.VBoxprivate javafx.scene.layout.VBoxprivate javafx.scene.layout.VBoxprivate javafx.scene.layout.VBoxprivate javafx.scene.layout.VBoxprivate javafx.scene.layout.VBox -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDisplays a file chooser dialog that allows the user to choose a PGP key file.voidclose()Exits the contact reply dialog.voidconfirm()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 thecontactMethodsobject.@NonNull Optional<ContactMethods> @NonNull FuzzyBooleanNon-blocking method to check whether the user's message was sent successfully.voidinitialize(URL location, ResourceBundle resourceBundle) Initializes the contact reply dialog.booleanGenerates a new passphrase by callingPasswordGenerator.generatePassphrase()and updates thepassword fieldand thepassword strength indicatoraccordingly.voidOpens the university's Matrix web interface in the default browser.voidUpdates thepassword strength indicatorbased on the user's input in thepassword field.voidprepare(@NonNull Configuration configuration) Prepares the contact reply dialog for operation by creating a newContactMethodsobject with the user name from the givenconfiguration.voidUpdates thepassword strength indicatorbased on the givenstrength.(package private) booleanvalidate()Checks that the user has entered valid contact information.private @NonNull ContactReplyMethodDialogController.ValidationResultValidates that the password entered by the user for symmetric encryption is strong enough, i.e.private @NonNull ContactReplyMethodDialogController.ValidationResultChecks that the user has entered a valid PGP public key that can be used to encrypt messages.private @NonNull ContactReplyMethodDialogController.ValidationResultIf "secure e-mail provider" is selected as the preferred contact method:private @NonNull ContactReplyMethodDialogController.ValidationResultChecks that the user has entered a valid Signal ID.private @NonNull ContactReplyMethodDialogController.ValidationResultChecks that the user has entered a valid SimpleX ID.private @NonNull ContactReplyMethodDialogController.ValidationResultChecks that the user has entered a valid Threema ID.private @NonNull ContactReplyMethodDialogController.ValidationResultIf 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 tonullby default. -
pgpKeyFileContent
The content of the PGP key file that the user has chosen. This field is set tonullby 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:
getResultin classDialogController<Configuration,ContactMethods> - Returns:
- The
contactMethodsobject 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, becauseresultis only set totrueafter the user has submitted the dialog, i.e. after the dialog has been closed.- Overrides:
getSuccessin classController<Configuration>- Returns:
- Whether the user's message was sent successfully.
-
prepare
Prepares the contact reply dialog for operation by creating a newContactMethodsobject with the user name from the givenconfiguration.Important:This method must be called immediately after
initialize(URL, ResourceBundle), because theContactReplyMethodDialogControllerdepends on thecontactMethodscreated by this method.- Specified by:
preparein interfacePreparable<Configuration>- Overrides:
preparein classController<Configuration>- Parameters:
configuration- Theuser namewill 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 theContactReplyMethodDialogControllerdepends on thecontactMethodscreated by theprepare(page.codeberg.friedolyn.configuration.Configuration)method.- Parameters:
location- The location used to resolve relative paths for the root object, ornullif the location is not known.resourceBundle- The resources used to localize the root object, ornullif the root object was not localized.
-
newPassword
public boolean newPassword()Generates a new passphrase by callingPasswordGenerator.generatePassphrase()and updates thepassword fieldand thepassword strength indicatoraccordingly.- Returns:
trueif the new password was generated successfully,falseotherwise.
-
passwordTypeAction
public void passwordTypeAction()Updates thepassword strength indicatorbased on the user's input in thepassword field. -
updatePasswordStrength
Updates thepassword strength indicatorbased 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 thepgpKeyFileContentfield. 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 thecontactMethodsobject.- Specified by:
confirmin classDialogController<Configuration,ContactMethods>
-
validatePassword
Validates that the password entered by the user for symmetric encryption is strong enough, i.e. the input of thepassword fieldis at leastgood. If the password is valid, it is stored in thecontactMethodsas 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:
trueif the password is strong enough,falseotherwise.
-
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
contactMethodsas 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 thecontactMethodsas the user'sTuta e-mail address.- Returns:
trueif the user has entered a valid e-mail address that, according to the user, belongs to their Tuta account,falseotherwise.
-
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 thecontactMethodsas 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:
trueif the user has entered a valid PGP public key,falseotherwise.
-
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
contactMethodsas 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 thecontactMethodsas the user'sContactMethods.setSecureProviderEmailAddress(String)secure provider email address} if it is valid.- Returns:
trueif the user has entered a valid e-mail address that, according to the user, belongs to their secure e-mail inbox,falseotherwise.
- 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 thecontactMethodsas 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:
trueif the user has entered a valid Threema ID,falseotherwise.
-
validateSignal
Checks that the user has entered a valid Signal ID. If the Signal ID is valid, it is stored in thecontactMethodsas 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:
trueif the user has entered a valid Signal ID,falseotherwise.
-
validateSimpleX
Checks that the user has entered a valid SimpleX ID.If the SimpleX ID is valid, it is stored in the
contactMethodsas 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:
trueif the user has entered a valid SimpleX ID,falseotherwise.
-
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:
trueif the user has entered valid contact information,falseotherwise.
-
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:
closein classController<Configuration>
-