Project

General

Profile

Download (2.84 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2021 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.api.service.security;
10

    
11
import org.springframework.mail.MailException;
12
import org.springframework.util.concurrent.ListenableFuture;
13

    
14
/**
15
 * @author a.kohlbecker
16
 * @since Nov 8, 2021
17
 */
18
public interface IPasswordResetService extends IRateLimitedService {
19

    
20

    
21
    /**
22
     * Create a request token and send it to the user via email.
23
     *
24
     * Must conform to the recommendations of <a href=
25
     * "https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html">
26
     * https://cheatsheetseries.owasp.org/cheatsheets/Forgot_Password_Cheat_Sheet.html</a>
27
     *
28
     * <ul>
29
     * <li>Hides internal processing time differences by sending the email
30
     * asynchronously</li>
31
     * <li>Access to the method is rate limited, see {@link #RATE_LIMIT}</li>
32
     * </ul>
33
     *
34
     * @param userNameOrEmail
35
     *            The user name or email address of the user requesting for a
36
     *            password reset.
37
     * @param passwordRequestFormUrlTemplate
38
     *            A template string for {@code String.format()} for the URL to
39
     *            the request form in which the user can enter the new password.
40
     *            The template string must contain one string placeholder
41
     *            {@code %s} for the request token string.
42
     * @return A <code>Future</code> for a <code>Boolean</code> flag. The
43
     *         boolean value will be <code>false</code> in case the max access
44
     *         rate for this method has been exceeded and a time out has
45
     *         occurred. Internal error states that may
46
     *         expose sensitive information are intentionally hidden this way
47
     *         (see above link to the Forgot_Password_Cheat_Sheet).
48
     * @throws MailException
49
     *             in case sending the email has failed
50
     */
51
    ListenableFuture<Boolean> emailResetToken(String userNameOrEmail, String passwordRequestFormUrlTemplate) throws MailException;
52

    
53
    /**
54
    *
55
    * @param token
56
    *            the token string
57
    * @param newPassword
58
    *            The new password to set
59
    * @return A <code>Future</code> for a <code>Boolean</code> flag. The
60
    *         boolean value will be <code>false</code> in case the max access
61
    *         rate for this method has been exceeded and a time out has
62
    *         occurred.
63
    * @throws AccountSelfManagementException
64
    *             in case an invalid token has been used
65
    * @throws MailException
66
    *             in case sending the email has failed
67
    */
68
    ListenableFuture<Boolean> resetPassword(String token, String newPassword) throws AccountSelfManagementException;
69

    
70

    
71
}
(7-7/10)