Project

General

Profile

Download (3.87 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,
59
            String passwordRequestFormUrlTemplate)
60
            throws MailException, AddressException, AccountSelfManagementException;
61

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

    
92
    boolean userNameExists(String userName);
93

    
94
    boolean emailAddressExists(String emailAddress);
95

    
96
}
(6-6/10)