Class EmailChangeEmailOtpPlugin
java.lang.Object
io.meeds.social.security.plugin.EmailOtpPlugin
io.meeds.social.security.plugin.EmailChangeEmailOtpPlugin
- All Implemented Interfaces:
io.meeds.social.security.plugin.EmailChangeOtpPlugin, io.meeds.web.security.plugin.OtpPlugin
@Service
public class EmailChangeEmailOtpPlugin
extends EmailOtpPlugin
implements io.meeds.social.security.plugin.EmailChangeOtpPlugin
The code of an email change: sent to the new address, never to the address
of the account, and stored bound to that address
(
EmailChangeOtpPlugin.bindCode(String, String)), so it proves that
the user receives mail there and confirms a change to that address only.
Generation, TTL, length and send interval are those of
EmailOtpPlugin (the meeds.apiKey.otp.email.* settings), as
are its caches, under the purpose-bound key of this method. The send lock
is taken first, on every request, refused ones included, and holds per
user whatever the address; a wrong code keeps it. Wrong guesses are
bounded as the OTP service bounds them, per user over
meeds.apiKey.otp.maxTentatives.ttl
(validateOtp(String, String)). Once the change is
written, the former address is told of it
(sendChangeNotice(String, String)).-
Nested Class Summary
Nested classes/interfaces inherited from interface io.meeds.social.security.plugin.EmailChangeOtpPlugin
io.meeds.social.security.plugin.EmailChangeOtpPlugin.AddressCheck<R> -
Field Summary
Fields inherited from interface io.meeds.social.security.plugin.EmailChangeOtpPlugin
NAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerateOtpCode(String userName) Refused: a code of this method goes to the new address only, which the generic send does not name<R> RgenerateOtpCode(String userName, String newEmail, io.meeds.social.security.plugin.EmailChangeOtpPlugin.AddressCheck<R> addressCheck) protected StringgetName()protected StringgetStoredCode(String otpCode, String recipientEmail) The value a sent code is stored as.voidsendChangeNotice(String userName, String formerEmail) Best effort: a mail server failure is logged and never undoes the change the user confirmed with both codesbooleanvalidateOtp(String userName, String otpCode) Bounds the wrong guesses at the user's code as the OTP service bounds the other methods: per user,meeds.apiKey.otp.maxTentatives.countof them, in a count that livesmeeds.apiKey.otp.maxTentatives.ttlminutes after the last one and that a valid code clears.Methods inherited from class EmailOtpPlugin
canUse, consumeOtp, getCacheKey, getCodeTtlMinutes, getOtpCache, getSendIntervalSeconds, releasesSendLockOnWrongCode, sendEmail, sendOtpCode, sendOtpCodeUnderLock, takeSendLockMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.meeds.web.security.plugin.OtpPlugin
canUse, consumeOtp, getCodeTtlMinutes, getSendIntervalSeconds
-
Constructor Details
-
EmailChangeEmailOtpPlugin
public EmailChangeEmailOtpPlugin()
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceio.meeds.web.security.plugin.OtpPlugin- Overrides:
getNamein classEmailOtpPlugin
-
generateOtpCode
Refused: a code of this method goes to the new address only, which the generic send does not name- Specified by:
generateOtpCodein interfaceio.meeds.web.security.plugin.OtpPlugin- Overrides:
generateOtpCodein classEmailOtpPlugin- Throws:
IllegalArgumentException- always
-
generateOtpCode
-
validateOtp
Bounds the wrong guesses at the user's code as the OTP service bounds the other methods: per user,meeds.apiKey.otp.maxTentatives.countof them, in a count that livesmeeds.apiKey.otp.maxTentatives.ttlminutes after the last one and that a valid code clears. At the limit the code is dropped, and every code is refused until the count expires: a new send does not start it again. The OTP service's own count does not bound this code: it is cleared by any valid code, and the email change checks the code of the current address in the same request. Guesses are counted one at a time on a server, so concurrent requests never count as one.- Specified by:
validateOtpin interfaceio.meeds.web.security.plugin.OtpPlugin- Overrides:
validateOtpin classEmailOtpPlugin
-
sendChangeNotice
-
getEmailBodyPath
-
getEmailSubjectKey
- Overrides:
getEmailSubjectKeyin classEmailOtpPlugin
-
getStoredCode
Description copied from class:EmailOtpPluginThe value a sent code is stored as. The code itself here: the email, API key, account deactivation and administrator session methods compare the typed code alone- Overrides:
getStoredCodein classEmailOtpPlugin- Parameters:
otpCode- the generated coderecipientEmail- the address the code is sent to, null for the address of the user's account- Returns:
- the value to store
-