Project

General

Profile

Download (3.74 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 javax.mail.internet.AddressException;
12

    
13
import org.springframework.mail.MailException;
14
import org.springframework.util.concurrent.ListenableFuture;
15

    
16
import eu.etaxonomy.cdm.api.security.AccountCreationRequest;
17

    
18
/**
19
 * @author a.kohlbecker
20
 * @since Nov 18, 2021
21
 */
22
public interface IAccountRegistrationService extends IRateLimitedService {
23

    
24
    public static final int RATE_LIMTER_TIMEOUT_SECONDS = 2;
25

    
26
    public static final double PERMITS_PER_SECOND = 0.3;
27

    
28
    /**
29
     * Create a {@link AccountCreationRequest} token and send it to the user via
30
     * email.
31
     *
32
     * <ul>
33
     * <li>Hides internal processing time differences by sending the email
34
     * asynchronously</li>
35
     * <li>Access to the method is rate limited, see {@link #RATE_LIMIT}</li>
36
     * </ul>
37
     *
38
     * @param emailAddress
39
     *            The email address to send the account creation request to
40
     * @param accountCreationRequestFormUrlTemplate
41
     *            A template string for {@code String.format()} for the URL to
42
     *            the form in which the user can create a new user account. The
43
     *            template string must contain one string placeholder {@code %s}
44
     *            for the request token string.
45
     * @return A <code>Future</code> for a <code>Boolean</code> flag. The
46
     *         boolean value will be <code>false</code> in case the max access
47
     *         rate for this method has been exceeded and a time out has
48
     *         occurred. Internal error states that may expose sensitive
49
     *         information are intentionally hidden this way (see above link to
50
     *         the Forgot_Password_Cheat_Sheet).
51
     * @throws MailException
52
     *             in case sending the email has failed
53
     * @throws AddressException
54
     *             in case the <code>emailAddress</code> in not valid
55
     * @throws AccountSelfManagementException
56
     *             in case the user name is already being used.
57
     */
58
    ListenableFuture<Boolean> emailAccountRegistrationRequest(String emailAddress, String userName, String password,
59
            String passwordRequestFormUrlTemplate)
60
            throws MailException, AddressException, AccountSelfManagementException;
61

    
62
    /**
63
     *
64
     * @param token
65
     *            the token string
66
     * @param givenName
67
     *            The new password to set - <b>required</b>
68
     * @param familyName
69
     *            The family name - optional, can be left empty
70
     * @param prefix
71
     *            The family name - optional, can be left empty
72
     * @return A <code>Future</code> for a <code>Boolean</code> flag. The
73
     *         boolean value will be <code>false</code> in case the max access
74
     *         rate for this method has been exceeded and a time out has
75
     *         occurred.
76
     * @throws AccountSelfManagementException
77
     *             in case an invalid token has been used
78
     * @throws MailException
79
     *             in case sending the email has failed
80
     * @throws AddressException
81
     *             in case the <code>emailAddress</code> stored in the
82
     *             {@link AccountCreationRequest} identified by the
83
     *             <code>token</code> not valid
84
     */
85
    ListenableFuture<Boolean> createUserAccount(String token, String givenName, String familyName, String prefix)
86
            throws MailException, AccountSelfManagementException, AddressException;
87

    
88
    boolean userNameExists(String userName);
89

    
90
    boolean emailAddressExists(String emailAddress);
91

    
92
}
(6-6/10)