Class ContactMethods
java.lang.Object
page.codeberg.friedolyn.configuration.ContactMethods
- All Implemented Interfaces:
Copyable<ContactMethods>,Redactable
Stores the user's preferred means of communication for replying to contact requests as well as the necessary
information for each method.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAll means of communication that the developers offer to use for replying to contact requests. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NonNull Stringprivate Stringstatic final @NonNull Stringprivate StringThe user's ASCII-armored OpenPGP public key that can be used to encrypt messages to the user.private URLA URL pointing to the user's OpenPGP public key that can be used to encrypt messages to the user.private @NonNull ContactMethods.ContactMethodThe means of communication that the user wants the developers to use for replying to contact requests.A set of known secure e-mail provider domains.private StringAn e-mail address of the user at a secure e-mail provider.private StringThe user's Signal ID that can be used to initiate a conversation with the user.private StringThe user's SimpleX ID that can be used to initiate a conversation with the user.private char[]The password that shall be used forsymmetrically encrypted e-mails.private StringThe user's Threema ID that can be used to initiate a conversation with the user.A set of known Tuta domains.static final @NonNull StringWhen using Tuta to send an end-to-end encrypted e-mail to someone who uses a different e-mail provider, the recipient will receive a notification e-mail from Tuta with a link to their encrypted inbox which they decrypt with the previously agreed-upon password for symmetric encryption.private StringThe e-mail address of the user's Tuta account. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDeprecated.Only to be used by Jackson for deserialization.ContactMethods(@NonNull String friedolinUser) Constructs a new object with the given Friedolin user. -
Method Summary
Modifier and TypeMethodDescription@NonNull ContactMethodscopy()booleanChecks whether the fields of this object are equal to the fields of another object.booleanChecks whether the fields of this object are the default values, i.e.@NonNull ContactMethods.ContactMethodImportant: It is NOT guaranteed that the user's contact information corresponding to the preferred contact method is set.@NonNull Optional<char[]> private @NonNull StringConverts the user's OpenPGP public key to a string that can be used as an inline e-mail attachment.voidRemoves the currentOpenPGP public keyfrom this object.voidRemoves the currentURLpointing to the user's OpenPGP public key from this object.voidRemoves the currentsecure e-mail provider e-mail addressfrom this object.voidRemoves the currentSignal IDfrom this object.voidRemoves the currentSimpleX IDfrom this object.voidDeletes the currentsymmetric password.voidRemoves the currentThreema IDfrom this object.voidRemoves the currentTuta e-mail addressfrom this object.voidsetFriedolinUser(@NonNull String friedolinUser) Updates the user'sFriedolin user name.voidsetPgpPublicKey(@NonNull String pgpPublicKey) Updates the user's ASCII-armoredOpenPGP public keyused for encrypting messages to the user.voidsetPgpPublicKeyUrl(@NonNull URL pgpPublicKeyURL) Updates theURLpointing to the user's OpenPGP public key used for encrypting messages to the user.voidsetPreferredContactMethod(@NonNull ContactMethods.ContactMethod preferredContactMethod) Updates the user'spreferred contact methodthat the developers should use to reply to contact requests.voidsetSecureProviderEmailAddress(@NonNull String secureProviderEmailAddress) Updates the user's e-mail address at a secure e-mail provider.voidsetSignalID(@NonNull String signalID) Updates the user'sSignal ID.voidsetSimplexID(@NonNull String simplexID) Updates the user'sSimpleX ID.voidsetSymmetricPassword(char[] symmetricPassword) Updates thepasswordused for symmetric encryption of e-mails.private voidsetSymmetricPassword(String symmetricPassword) Deprecated.Only to be used by Jackson for deserialization.voidsetThreemaID(@NonNull String threemaID) Updates the user'sThreema ID.voidsetTutaAddress(@NonNull String tutaAddress) Updates the user'sTuta e-mail address.@NonNull StringConverts the value of thepreferred contact methodto a string that can be used as an inline e-mail attachment.@NonNull FileWrites the result oftoEmailAttachment()to a file namedATTACHMENT_FILE_NAMEin the system's temporary directory.@NonNull StringtoString()@NonNull Stringstatic booleanvalidateEmailAddress(@NonNull String email) Checks that the given string is an e-mail address.static @NonNull FuzzyBooleanvalidateSecureProviderEmailAddress(@NonNull String secureProviderEmailAddress) Checks that the given string is a valid e-mail address of asecure e-mail provider.static booleanvalidateSignal(@NonNull String signalID) Checks that the given string is a validSignalID.static booleanvalidateSimplexID(@NonNull String simplexID) Checks that the given string is a validSimpleXID.static @NonNull Result<PasswordGenerator.PasswordStrength> validateSymmetricPassword(char[] symmetricPassword) Checks that the given password forsymmetrically encrypted e-mailsis not null, not empty and strong enough (i.e.static booleanvalidateThreema(@NonNull String threemaID) Checks that the given string is a validThreemaID.static @NonNull FuzzyBooleanvalidateTutaAddress(@NonNull String tutaAddress) Checks that the given string is a validTutae-mail address.
-
Field Details
-
TUTA_DOMAINS
-
TUTA_EXTERNAL_RECIPIENT_INBOX_URL
When using Tuta to send an end-to-end encrypted e-mail to someone who uses a different e-mail provider, the recipient will receive a notification e-mail from Tuta with a link to their encrypted inbox which they decrypt with the previously agreed-upon password for symmetric encryption.The URL of the external recipient's Tuta inbox always begins with this string. It is supposed to be used by
KeePassXCto store the password and automatically suggest it to the user when visiting the inbox.- See Also:
-
SECURE_EMAIL_PROVIDER_DOMAINS
A set of known secure e-mail provider domains.- All domains from
TUTA_DOMAINS - proton.me
- protonmail.com
- mailbox.org
- startmail.com
- posteo.com
- posteo.us
- posteo.net
- All domains from
-
FSU_MATRIX_DOMAIN
-
ATTACHMENT_FILE_NAME
- See Also:
-
preferredContactMethod
The means of communication that the user wants the developers to use for replying to contact requests. IMPORTANT: It is NOT guaranteed that the user's contact information corresponding to the preferred contact method is set. In other words, any contact information may benullat any time. -
symmetricPassword
@Nullable private char[] symmetricPasswordThe password that shall be used forsymmetrically encrypted e-mails. -
pgpPublicKey
The user's ASCII-armored OpenPGP public key that can be used to encrypt messages to the user.- See Also:
-
pgpPublicKeyURL
-
tutaAddress
-
secureProviderEmailAddress
An e-mail address of the user at a secure e-mail provider.- See Also:
-
friedolinUser
- See Also:
-
threemaID
-
signalID
-
simplexID
-
-
Constructor Details
-
ContactMethods
Deprecated.Only to be used by Jackson for deserialization. -
ContactMethods
Constructs a new object with the given Friedolin user.- Parameters:
friedolinUser- The user'sFriedolin user name- Throws:
IllegalArgumentException- SeesetFriedolinUser(String)
-
-
Method Details
-
validateSymmetricPassword
@NonNull public static @NonNull Result<PasswordGenerator.PasswordStrength> validateSymmetricPassword(char[] symmetricPassword) Checks that the given password forsymmetrically encrypted e-mailsis not null, not empty and strong enough (i.e.good,strongorvery strong).- Parameters:
symmetricPassword- The password to check- Returns:
trueif the password fulfills the requirements,falseotherwise
-
validateEmailAddress
Checks that the given string is an e-mail address.- Parameters:
email- The string to check- Returns:
trueif the string is an e-mail address,falseotherwise- See Also:
-
validateTutaAddress
@NonNull public static @NonNull FuzzyBoolean validateTutaAddress(@NonNull @NonNull String tutaAddress) Checks that the given string is a validTutae-mail address.- Parameters:
tutaAddress- The string to check- Returns:
-
TRUEif the string is an e-mail address witha known Tuta domain. -
MAYBEif the string is an e-mail address but not with a known Tuta domain. This may or may not indicate that the user has a paid Tuta subscription with a custom domain. FALSEif the string is not an e-mail address at all.
-
-
validateSecureProviderEmailAddress
@NonNull public static @NonNull FuzzyBoolean validateSecureProviderEmailAddress(@NonNull @NonNull String secureProviderEmailAddress) Checks that the given string is a valid e-mail address of asecure e-mail provider.- Parameters:
secureProviderEmailAddress- The string to check- Returns:
-
TRUEif the string is an e-mail address witha known secure-provider domain, -
MAYBEif the string is an e-mail address but not with a known secure-provider domain, FALSEif the string is not an e-mail address
-
-
validateThreema
Checks that the given string is a validThreemaID. A Threema ID is a string of 8 alphanumeric characters (case-insensitive). Optionally, it may be in the form of a Threema ID URL, i.e. start withthreema.id(possibly with the protocol and/orwww.).- Parameters:
threemaID- The string to check- Returns:
trueif the string is a valid Threema ID,falseotherwise
-
validateSignal
Checks that the given string is a validSignalID. A Signal ID is a phone number, a Signal URL or a Signal user name. A Signal URL is a string of 64 alphanumeric characters (case-sensitive) that starts withsignal.me/#eu/(possibly with the protocol and/orwww.). A Signal user name is a string of alphanumeric characters and underscores, followed by a dot and at least two digits.- Parameters:
signalID- The string to check- Returns:
trueif the string is a valid Signal ID,falseotherwise
-
validateSimplexID
Checks that the given string is a validSimpleXID. A SimpleX ID is a URL that starts withsimplex.chat/contact/(possibly with the protocol and/orwww.) and contains an.oniondomain.- Parameters:
simplexID- The string to check- Returns:
trueif the string is a valid Simplex ID,falseotherwise
-
getPreferredContactMethod
Important: It is NOT guaranteed that the user's contact information corresponding to the preferred contact method is set. In other words, any contact information may beemptyat any time.- Returns:
- The contact method that the user wants the developers to use for replying to contact requests.
Defaults to
PASSWORD_EMAIL.
-
getSymmetricPassword
- Returns:
- The
passwordused for symmetric encryption of e-mails. May be empty even ifpreferredContactMethodisPASSWORD_EMAIL. - See Also:
-
getPgpPublicKey
- Returns:
- The user's ASCII-armored
OpenPGP public keyused for encrypting messages to the user. May be empty even ifpreferredContactMethodisPGP. - See Also:
-
getPgpPublicKeyUrl
- Returns:
- A
URLpointing to the user's OpenPGP public key used for encrypting messages to the user. May be empty even ifpreferredContactMethodisPGP. - See Also:
-
getTutaAddress
- Returns:
- The user's
Tuta e-mail address. Might not be aknown Tuta domain, because Tuta allows custom domains in paid subscriptions. For more information on Tuta addresses, seevalidateTutaAddress(String). May be empty even ifpreferredContactMethodisTUTA. - See Also:
-
getSecureProviderEmailAddress
- Returns:
- The user's
e-mail addressat a secure e-mail provider. Note that some of the known providers allow custom domains, so the address returned may not end in aknown secure-provider domain. For more information on secure provider e-mail addresses, seevalidateSecureProviderEmailAddress(String). May be empty even ifpreferredContactMethodisSECURE_EMAIL_PROVIDER. - See Also:
-
getMatrixID
- Returns:
- The user's
Matrix IDmanaged by the university's Matrix chat server. Starts with the user'sFriedolin user nameand ends with thedomainof the university's Matrix chat server, such as@es13nsa:uni-jena.de. May be empty even ifpreferredContactMethodisMATRIX.
-
getThreemaID
- Returns:
- The user's
Threema ID. May be just the ID or athreema.idURL. For more information on how Threema IDs are formatted, seevalidateThreema(String). May be empty even ifpreferredContactMethodisTHREEMA. - See Also:
-
getSignalID
- Returns:
- The user's
Signal ID. May be a phone number, a Signal URL or a Signal user name. For more information on how Signal IDs are formatted, seevalidateSignal(String). May be empty even ifpreferredContactMethodisSIGNAL.
-
getSimplexID
- Returns:
- The user's
SimpleX ID. For more information on how SimpleX IDs are formatted, seevalidateSimplexID(String). May be empty even ifpreferredContactMethodisSIMPLEX. - See Also:
-
setPreferredContactMethod
public void setPreferredContactMethod(@NonNull @NonNull ContactMethods.ContactMethod preferredContactMethod) Updates the user'spreferred contact methodthat the developers should use to reply to contact requests. Please always make sure to set the corresponding contact information as well! (For example, if the preferred contact method isTUTA, please callsetTutaAddress(String)as well.)- Parameters:
preferredContactMethod- The new preferred contact method.
-
setSymmetricPassword
Updates thepasswordused for symmetric encryption of e-mails. The password must meet the requirements specified invalidateSymmetricPassword(char[]).- Parameters:
symmetricPassword- The new password.- Throws:
IllegalArgumentException- IfvalidateSymmetricPassword(char[])returnsfalse- See Also:
-
setPgpPublicKey
Updates the user's ASCII-armoredOpenPGP public keyused for encrypting messages to the user. The key must be a valid OpenPGP public key that can be used for encryption. UNDER NO CIRCUMSTANCES should the private key be used here!- Parameters:
pgpPublicKey- The new public key.- Throws:
IllegalArgumentException- IfPGP.validatePublicKey(String)returnsfalse- See Also:
-
setPgpPublicKeyUrl
Updates theURLpointing to the user's OpenPGP public key used for encrypting messages to the user. The URL must point to a valid OpenPGP public key that can be used for encryption.- Parameters:
pgpPublicKeyURL- The new public key URL.- See Also:
-
setTutaAddress
Updates the user'sTuta e-mail address. The address must be a valid e-mail address. If the user has a paid Tuta subscription with a custom domain, the e-mail domain is not required to be one ofTUTA_DOMAINS.- Parameters:
tutaAddress- The new Tuta e-mail address.- Throws:
IllegalArgumentException- If the address is not a valid e-mail address.- See Also:
-
setSecureProviderEmailAddress
public void setSecureProviderEmailAddress(@NonNull @NonNull String secureProviderEmailAddress) throws IllegalArgumentException Updates the user's e-mail address at a secure e-mail provider. The address must be a valid e-mail address. If the user uses a custom domain with a secure e-mail provider, the e-mail domain is not required to be one ofSECURE_EMAIL_PROVIDER_DOMAINS.- Parameters:
secureProviderEmailAddress- The new secure e-mail provider e-mail address.- Throws:
IllegalArgumentException- If the address is not a valid e-mail address.- See Also:
-
setThreemaID
Updates the user'sThreema ID. The ID must be a valid Threema ID. Optionally, it may be a Threema ID URL, i.e. start withthreema.id(possibly with the protocol and/orwww.). For more information on how Threema IDs are formatted, seevalidateThreema(String).- Parameters:
threemaID- The new Threema ID.- Throws:
IllegalArgumentException- If the ID is not a valid Threema ID.- See Also:
-
setSignalID
Updates the user'sSignal ID. The ID must be a valid Signal ID. The ID may be a phone number, a Signal URL or a Signal user name. For more information on how Signal IDs are formatted, seevalidateSignal(String).- Parameters:
signalID- The new Signal ID.- Throws:
IllegalArgumentException- If the ID is not a valid Signal ID.- See Also:
-
setSimplexID
Updates the user'sSimpleX ID. The ID must be a valid SimpleX ID. For more information on how SimpleX IDs are formatted, seevalidateSimplexID(String).- Parameters:
simplexID- The new SimpleX ID.- Throws:
IllegalArgumentException- If the ID is not a valid SimpleX ID.- See Also:
-
setFriedolinUser
public void setFriedolinUser(@NonNull @NonNull String friedolinUser) throws IllegalArgumentException Updates the user'sFriedolin user name. The user name must not be blank. This is needed to and will be used to construct the user'sMatrix ID.- Parameters:
friedolinUser- The new user name at the university's Friedolin system.- Throws:
IllegalArgumentException- If the user name is blank.
-
setSymmetricPassword
Deprecated.Only to be used by Jackson for deserialization. UsesetSymmetricPassword(char[])instead.Updates thepasswordused for symmetric encryption of e-mails.- Parameters:
symmetricPassword- The new symmetric password
-
resetSymmetricPassword
public void resetSymmetricPassword()Deletes the currentsymmetric password. -
resetPgpPublicKey
public void resetPgpPublicKey()Removes the currentOpenPGP public keyfrom this object. -
resetPgpPublicKeyURL
public void resetPgpPublicKeyURL()Removes the currentURLpointing to the user's OpenPGP public key from this object. -
resetTutaAddress
public void resetTutaAddress()Removes the currentTuta e-mail addressfrom this object. -
resetSecureProviderEmailAddress
public void resetSecureProviderEmailAddress()Removes the currentsecure e-mail provider e-mail addressfrom this object. -
resetThreemaID
public void resetThreemaID()Removes the currentThreema IDfrom this object. -
resetSignalID
public void resetSignalID()Removes the currentSignal IDfrom this object. -
resetSimplexID
public void resetSimplexID()Removes the currentSimpleX IDfrom this object. -
pgpToEmailAttachment
Converts the user's OpenPGP public key to a string that can be used as an inline e-mail attachment.- Returns:
- If both
pgpPublicKeyandpgpPublicKeyURLarenull, returns"[UNSET]". - If only
pgpPublicKeyis set, returns the ASCII-armored public key. - If only
pgpPublicKeyURLis set, returns the URL as a string. - If both are set, returns the URL followed by the ASCII-armored public key.
- If both
-
toEmailAttachment
Converts the value of thepreferred contact methodto a string that can be used as an inline e-mail attachment.- Returns:
-
symmetricPasswordifpreferredContactMethodis set toPASSWORD_EMAIL -
the result of
pgpToEmailAttachment()ifpreferredContactMethodis set toPGP -
tutaAddressifpreferredContactMethodis set toTUTA -
secureProviderEmailAddressifpreferredContactMethodis set toSECURE_EMAIL_PROVIDER -
getMatrixID()ifpreferredContactMethodis set toMATRIX -
threemaIDifpreferredContactMethodis set toTHREEMA -
signalIDifpreferredContactMethodis set toSIGNAL -
simplexIDifpreferredContactMethodis set toSIMPLEX -
"Unencrypted e-mail :("ifpreferredContactMethodis set toUNENCRYPTED_EMAIL
-
-
toEmailAttachmentFile
Writes the result oftoEmailAttachment()to a file namedATTACHMENT_FILE_NAMEin the system's temporary directory.- Returns:
- The contact information as a temporary file.
- Throws:
IOException- If the temporary file could not be found or could not be written to.
-
toString
- Specified by:
toStringin interfaceRedactable- Overrides:
toStringin classObject- Returns:
- A string representation of this object including all fields.
- See Also:
-
toStringRedacted
- Specified by:
toStringRedactedin interfaceRedactable- Returns:
- A string representation of this object including all fields. If the
debug level} is NOT set to
invalid reference
Main#getDebugLevel()DEBUG, thesymmetricPasswordwill be redacted. If it is set toWARNorERROR, then all fields except thepreferred contact methodwill be redacted. - See Also:
-
copy
- Specified by:
copyin interfaceCopyable<ContactMethods>- Returns:
- A deep copy of this object, i.e. a new object with a different reference but with the same field values.
-
equals
-
equalsDefault
public boolean equalsDefault()Checks whether the fields of this object are the default values, i.e. whether this object is equal to a newly created one. Does NOT take into account theFriedolin user name.- Returns:
trueif the fields are the default values,falseotherwise
-