2 * Copyright (C) 2016 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.addressbook.beans.user;
19 import java.io.Serializable;
20 import java.util.List;
21 import org.mxchange.jcontacts.contact.Contact;
22 import org.mxchange.jcontacts.events.contact.add.AdminAddedContactEvent;
23 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
24 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
25 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
26 import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
27 import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
28 import org.mxchange.jusercore.exceptions.UserNotFoundException;
29 import org.mxchange.jusercore.model.user.User;
30 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
33 * An interface for user beans
35 * @author Roland Haeder<roland@mxchange.org>
37 public interface AddressbookUserWebSessionController extends Serializable {
40 * Minimum password length
42 public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
45 * Event observer for newly added users by adminstrator
47 * @param event Event being fired
49 void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
52 * Event observer for updated user data by administrator
54 * @param event Event being updated
56 void afterAdminUpdatedUserDataEvent (final AdminUpdatedUserDataEvent event);
59 * Listens to fired event when user updated personal data
61 * @param event Event being fired
63 void afterUserUpdatedPersonalData (final UpdatedUserPersonalDataEvent event);
66 * Event observer for new user registrations
68 * @param event User registration event
70 void afterRegistrationEvent (final UserRegisteredEvent event);
73 * Event observer for logged-in user
75 * @param event Event instance
77 void afterUserLogin (final UserLoggedInEvent event);
82 * @return A list of all public user profiles
84 List<User> allUsers ();
87 * All public user profiles
89 * @return A list of all public user profiles
91 List<User> allVisibleUsers ();
94 * Checks whether users are registered
96 * @return Whether users are registered
101 * Checks whether the given contact is a user
103 * @param contact Contact to check
105 * @return Whether the contact is a user
107 boolean isContactFound (final Contact contact);
110 * Observes events being fired when an administrator has added a new
113 * @param event Event being fired
115 void afterAdminAddedContact (final AdminAddedContactEvent event);
118 * Checks whether a public user account is registered. This means that at
119 * least one user profile has its flag "public user profile" enabled.
121 * @return Whether at least one user has a public profile
123 boolean isVisibleUserFound ();
126 * Checks whether given user instance's name is used
128 * @param user User instance's name to check
130 * @return Whether it is already used
132 boolean isUserNameRegistered (final User user);
135 * Tries to lookup user by given id number. If the user is not found or the
136 * account status is not CONFIRMED proper exceptions are thrown.
138 * @param userId User id
140 * @return User instance
142 * @throws UserNotFoundException If the user is not found
144 User lookupUserById (final Long userId) throws UserNotFoundException;
147 * Returns a list of all selectable contacts for user creation. Contacts
148 * from already existing users are excluded in this list.
150 * @return A list of all selectable contacts
152 List<Contact> selectableContacts ();
155 * Creates an instance from all properties
157 * @return A user instance
159 User createUserInstance ();
162 * Creates a user instance for login phase
164 * @return User instance
166 User createUserLogin ();
178 * @param userId User id
180 void setUserId (final Long userId);
183 * Getter for user name
187 String getUserName ();
190 * Setter for user name
192 * @param userName User name
194 void setUserName (final String userName);
197 * Getter for unencrypted user password
199 * @return Unencrypted user password
201 String getUserPassword ();
204 * Setter for unencrypted user password
206 * @param userPassword Unencrypted user password
208 void setUserPassword (final String userPassword);
211 * Getter for unencrypted user password repeated
213 * @return Unencrypted user password repeated
215 String getUserPasswordRepeat ();
218 * Setter for unencrypted user password repeated
220 * @param userPasswordRepeat Unencrypted user password repeated
222 void setUserPasswordRepeat (final String userPasswordRepeat);
225 * Getter for user profile mode
227 * @return User profile mode
229 ProfileMode getUserProfileMode ();
232 * Setter for user profile mode
234 * @param userProfileMode User profile mode
236 void setUserProfileMode (final ProfileMode userProfileMode);
239 * Checks whether all required personal data is set
241 * @return Whether the required personal data is set
243 boolean isRequiredPersonalDataSet ();
246 * Checks whether all required personal data is set for changing them
248 * @return Whether the required personal data is set
250 boolean isRequiredChangePersonalDataSet ();
253 * Checks whether same passwords has been entered
255 * @return Whether same passwords has been entered
257 boolean isSamePasswordEntered ();
260 * Checks if the user id is empty
262 * @return Whether the user id is empty
264 boolean isUserIdEmpty ();
267 * Changes logged-in user's personal data if the current password matches
268 * and TAC + privacy statement has been accepted.
270 * @return New target page
272 String doChangePersonalData ();