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 enum
All means of communication that the developers offer to use for replying to contact requests. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final @NonNull String
private String
static final @NonNull String
private String
The user's ASCII-armored OpenPGP public key that can be used to encrypt messages to the user.private URL
A URL pointing to the user's OpenPGP public key that can be used to encrypt messages to the user.private @NonNull ContactMethods.ContactMethod
The 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 String
An e-mail address of the user at a secure e-mail provider.private String
The user's Signal ID that can be used to initiate a conversation with the user.private String
The 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 String
The user's Threema ID that can be used to initiate a conversation with the user.A set of known Tuta domains.static final @NonNull String
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.private String
The e-mail address of the user's Tuta account. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Deprecated.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 ContactMethods
copy()
boolean
Checks whether the fields of this object are equal to the fields of another object.boolean
Checks whether the fields of this object are the default values, i.e.@NonNull ContactMethods.ContactMethod
Important: It is NOT guaranteed that the user's contact information corresponding to the preferred contact method is set.@NonNull Optional
<char[]> private @NonNull String
Converts the user's OpenPGP public key to a string that can be used as an inline e-mail attachment.void
Removes the currentOpenPGP public key
from this object.void
Removes the currentURL
pointing to the user's OpenPGP public key from this object.void
Removes the currentsecure e-mail provider e-mail address
from this object.void
Removes the currentSignal ID
from this object.void
Removes the currentSimpleX ID
from this object.void
Deletes the currentsymmetric password
.void
Removes the currentThreema ID
from this object.void
Removes the currentTuta e-mail address
from this object.void
setFriedolinUser
(@NonNull String friedolinUser) Updates the user'sFriedolin user name
.void
setPgpPublicKey
(@NonNull String pgpPublicKey) Updates the user's ASCII-armoredOpenPGP public key
used for encrypting messages to the user.void
setPgpPublicKeyUrl
(@NonNull URL pgpPublicKeyURL) Updates theURL
pointing to the user's OpenPGP public key used for encrypting messages to the user.void
setPreferredContactMethod
(@NonNull ContactMethods.ContactMethod preferredContactMethod) Updates the user'spreferred contact method
that the developers should use to reply to contact requests.void
setSecureProviderEmailAddress
(@NonNull String secureProviderEmailAddress) Updates the user's e-mail address at a secure e-mail provider.void
setSignalID
(@NonNull String signalID) Updates the user'sSignal ID
.void
setSimplexID
(@NonNull String simplexID) Updates the user'sSimpleX ID
.void
setSymmetricPassword
(char[] symmetricPassword) Updates thepassword
used for symmetric encryption of e-mails.private void
setSymmetricPassword
(String symmetricPassword) Deprecated.Only to be used by Jackson for deserialization.void
setThreemaID
(@NonNull String threemaID) Updates the user'sThreema ID
.void
setTutaAddress
(@NonNull String tutaAddress) Updates the user'sTuta e-mail address
.@NonNull String
Converts the value of thepreferred contact method
to a string that can be used as an inline e-mail attachment.@NonNull File
Writes the result oftoEmailAttachment()
to a file namedATTACHMENT_FILE_NAME
in the system's temporary directory.@NonNull String
toString()
@NonNull String
static boolean
validateEmailAddress
(@NonNull String email) Checks that the given string is an e-mail address.static @NonNull FuzzyBoolean
validateSecureProviderEmailAddress
(@NonNull String secureProviderEmailAddress) Checks that the given string is a valid e-mail address of asecure e-mail provider
.static boolean
validateSignal
(@NonNull String signalID) Checks that the given string is a validSignal
ID.static boolean
validateSimplexID
(@NonNull String simplexID) Checks that the given string is a validSimpleX
ID.static @NonNull Result
<PasswordGenerator.PasswordStrength> validateSymmetricPassword
(char[] symmetricPassword) Checks that the given password forsymmetrically encrypted e-mails
is not null, not empty and strong enough (i.e.static boolean
validateThreema
(@NonNull String threemaID) Checks that the given string is a validThreema
ID.static @NonNull FuzzyBoolean
validateTutaAddress
(@NonNull String tutaAddress) Checks that the given string is a validTuta
e-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
KeePassXC
to 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 benull
at 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-mails
is not null, not empty and strong enough (i.e.good
,strong
orvery strong
).- Parameters:
symmetricPassword
- The password to check- Returns:
true
if the password fulfills the requirements,false
otherwise
-
validateEmailAddress
Checks that the given string is an e-mail address.- Parameters:
email
- The string to check- Returns:
true
if the string is an e-mail address,false
otherwise- See Also:
-
validateTutaAddress
@NonNull public static @NonNull FuzzyBoolean validateTutaAddress(@NonNull @NonNull String tutaAddress) Checks that the given string is a validTuta
e-mail address.- Parameters:
tutaAddress
- The string to check- Returns:
-
TRUE
if the string is an e-mail address witha known Tuta domain
. -
MAYBE
if 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. FALSE
if 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:
-
TRUE
if the string is an e-mail address witha known secure-provider domain
, -
MAYBE
if the string is an e-mail address but not with a known secure-provider domain, FALSE
if the string is not an e-mail address
-
-
validateThreema
Checks that the given string is a validThreema
ID. 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:
true
if the string is a valid Threema ID,false
otherwise
-
validateSignal
Checks that the given string is a validSignal
ID. 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:
true
if the string is a valid Signal ID,false
otherwise
-
validateSimplexID
Checks that the given string is a validSimpleX
ID. A SimpleX ID is a URL that starts withsimplex.chat/contact/
(possibly with the protocol and/orwww.
) and contains an.onion
domain.- Parameters:
simplexID
- The string to check- Returns:
true
if the string is a valid Simplex ID,false
otherwise
-
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 beempty
at 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
password
used for symmetric encryption of e-mails. May be empty even ifpreferredContactMethod
isPASSWORD_EMAIL
. - See Also:
-
getPgpPublicKey
- Returns:
- The user's ASCII-armored
OpenPGP public key
used for encrypting messages to the user. May be empty even ifpreferredContactMethod
isPGP
. - See Also:
-
getPgpPublicKeyUrl
- Returns:
- A
URL
pointing to the user's OpenPGP public key used for encrypting messages to the user. May be empty even ifpreferredContactMethod
isPGP
. - 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 ifpreferredContactMethod
isTUTA
. - See Also:
-
getSecureProviderEmailAddress
- Returns:
- The user's
e-mail address
at 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 ifpreferredContactMethod
isSECURE_EMAIL_PROVIDER
. - See Also:
-
getMatrixID
- Returns:
- The user's
Matrix ID
managed by the university's Matrix chat server. Starts with the user'sFriedolin user name
and ends with thedomain
of the university's Matrix chat server, such as@es13nsa:uni-jena.de
. May be empty even ifpreferredContactMethod
isMATRIX
.
-
getThreemaID
- Returns:
- The user's
Threema ID
. May be just the ID or athreema.id
URL. For more information on how Threema IDs are formatted, seevalidateThreema(String)
. May be empty even ifpreferredContactMethod
isTHREEMA
. - 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 ifpreferredContactMethod
isSIGNAL
.
-
getSimplexID
- Returns:
- The user's
SimpleX ID
. For more information on how SimpleX IDs are formatted, seevalidateSimplexID(String)
. May be empty even ifpreferredContactMethod
isSIMPLEX
. - See Also:
-
setPreferredContactMethod
public void setPreferredContactMethod(@NonNull @NonNull ContactMethods.ContactMethod preferredContactMethod) Updates the user'spreferred contact method
that 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 thepassword
used 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 key
used 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 theURL
pointing 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 thepassword
used 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 key
from this object. -
resetPgpPublicKeyURL
public void resetPgpPublicKeyURL()Removes the currentURL
pointing to the user's OpenPGP public key from this object. -
resetTutaAddress
public void resetTutaAddress()Removes the currentTuta e-mail address
from this object. -
resetSecureProviderEmailAddress
public void resetSecureProviderEmailAddress()Removes the currentsecure e-mail provider e-mail address
from this object. -
resetThreemaID
public void resetThreemaID()Removes the currentThreema ID
from this object. -
resetSignalID
public void resetSignalID()Removes the currentSignal ID
from this object. -
resetSimplexID
public void resetSimplexID()Removes the currentSimpleX ID
from 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
pgpPublicKey
andpgpPublicKeyURL
arenull
, returns"[UNSET]"
. - If only
pgpPublicKey
is set, returns the ASCII-armored public key. - If only
pgpPublicKeyURL
is 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 method
to a string that can be used as an inline e-mail attachment.- Returns:
-
symmetricPassword
ifpreferredContactMethod
is set toPASSWORD_EMAIL
-
the result of
pgpToEmailAttachment()
ifpreferredContactMethod
is set toPGP
-
tutaAddress
ifpreferredContactMethod
is set toTUTA
-
secureProviderEmailAddress
ifpreferredContactMethod
is set toSECURE_EMAIL_PROVIDER
-
getMatrixID()
ifpreferredContactMethod
is set toMATRIX
-
threemaID
ifpreferredContactMethod
is set toTHREEMA
-
signalID
ifpreferredContactMethod
is set toSIGNAL
-
simplexID
ifpreferredContactMethod
is set toSIMPLEX
-
"Unencrypted e-mail :("
ifpreferredContactMethod
is set toUNENCRYPTED_EMAIL
-
-
toEmailAttachmentFile
Writes the result oftoEmailAttachment()
to a file namedATTACHMENT_FILE_NAME
in 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:
toString
in interfaceRedactable
- Overrides:
toString
in classObject
- Returns:
- A string representation of this object including all fields.
- See Also:
-
toStringRedacted
- Specified by:
toStringRedacted
in interfaceRedactable
- Returns:
- A string representation of this object including all fields. If the
invalid reference
Main#getDebugLevel()
DEBUG
, thesymmetricPassword
will be redacted. If it is set toWARN
orERROR
, then all fields except thepreferred contact method
will be redacted. - See Also:
-
copy
- Specified by:
copy
in 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:
true
if the fields are the default values,false
otherwise
-