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.jjobs.beans.user;
19 import java.io.Serializable;
20 import java.util.List;
21 import org.mxchange.jcontacts.contact.Contact;
22 import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
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.linked.AdminLinkedUserEvent;
27 import org.mxchange.jusercore.events.user.locked.AdminLockedUserEvent;
28 import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
29 import org.mxchange.jusercore.events.user.unlocked.AdminUnlockedUserEvent;
30 import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
31 import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
32 import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
33 import org.mxchange.jusercore.exceptions.UserNotFoundException;
34 import org.mxchange.jusercore.model.user.User;
35 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
38 * An interface for user beans
40 * @author Roland Haeder<roland@mxchange.org>
42 public interface JobsUserWebSessionController extends Serializable {
45 * Minimum password length
47 public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
50 * Event observer for newly added users by adminstrator
52 * @param event Event being fired
54 void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
57 * Event observer for linked users with existing contact data
59 * @param event Event being fired
61 void afterAdminLinkedUserEvent (final AdminLinkedUserEvent event);
64 * Event observer for locked users
66 * @param event Event being fired
68 void afterAdminLockedUserEvent (final AdminLockedUserEvent event);
71 * Event observer for unlocked users
73 * @param event Event being fired
75 void afterAdminUnlockedUserEvent (final AdminUnlockedUserEvent event);
78 * Event observer for updated user data by administrator
80 * @param event Event being updated
82 void afterAdminUpdatedUserDataEvent (final AdminUpdatedUserDataEvent event);
85 * Event observer when user confirmed account.
87 * @param event Event being fired
89 void afterUserConfirmedAccountEvent (final UserConfirmedAccountEvent event);
92 * Method being call after user's password has been updated (and history
93 * entry has been created).
95 * @param event Event being observed
97 void afterUserUpdatedPasswordEvent (final UpdatedUserPasswordEvent event);
100 * Listens to fired event when user updated personal data
102 * @param event Event being fired
104 void afterUserUpdatedPersonalDataEvent (final UpdatedUserPersonalDataEvent event);
107 * Event observer for new user registrations
109 * @param event User registration event
111 void afterUserRegistrationEvent (final UserRegisteredEvent event);
114 * Event observer for logged-in user
116 * @param event Event instance
118 void afterUserLoginEvent (final UserLoggedInEvent event);
123 * @return A list of all public user profiles
125 List<User> allUsers ();
128 * All public user profiles
130 * @return A list of all public user profiles
132 List<User> allVisibleUsers ();
135 * Checks whether the given contact is a user
137 * @param contact Contact to check
139 * @return Whether the contact is a user
141 boolean isContactFound (final Contact contact);
144 * Checks whether a public user account is registered. This means that at
145 * least one user profile has its flag "public user profile" enabled.
147 * @return Whether at least one user has a public profile
149 boolean isVisibleUserFound ();
152 * Checks whether given user instance's name is used
154 * @param user User instance's name to check
156 * @return Whether it is already used
158 boolean isUserNameRegistered (final User user);
161 * Tries to lookup user by given id number. If the user is not found or the
162 * account status is not CONFIRMED proper exceptions are thrown.
164 * @param userId User id
166 * @return User instance
168 * @throws UserNotFoundException If the user is not found
170 User lookupUserById (final Long userId) throws UserNotFoundException;
173 * Tries to lookup user by given email address. If the user is not found a
174 * proper exceptions is thrown.
176 * @param emailAddress Email address
178 * @return User instance
180 * @throws UserEmailAddressNotFoundException If the user's email address is not found
182 User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException;
185 * Creates an instance from all properties
187 * @param createContactData Whether contact data should be created
189 * @return A user instance
191 User createUserInstance (final boolean createContactData);
194 * Creates a user instance for login phase
196 * @return User instance
198 User createUserLogin ();
210 * @param userId User id
212 void setUserId (final Long userId);
215 * Getter for user name
219 String getUserName ();
222 * Setter for user name
224 * @param userName User name
226 void setUserName (final String userName);
229 * Getter for unencrypted user password
231 * @return Unencrypted user password
233 String getUserPassword ();
236 * Setter for unencrypted user password
238 * @param userPassword Unencrypted user password
240 void setUserPassword (final String userPassword);
243 * Getter for unencrypted user password repeated
245 * @return Unencrypted user password repeated
247 String getUserPasswordRepeat ();
250 * Setter for unencrypted user password repeated
252 * @param userPasswordRepeat Unencrypted user password repeated
254 void setUserPasswordRepeat (final String userPasswordRepeat);
257 * Getter for user profile mode
259 * @return User profile mode
261 ProfileMode getUserProfileMode ();
264 * Setter for user profile mode
266 * @param userProfileMode User profile mode
268 void setUserProfileMode (final ProfileMode userProfileMode);
271 * Checks whether all required personal data is set
273 * @return Whether the required personal data is set
275 boolean isRequiredPersonalDataSet ();
278 * Checks whether all required personal data is set for changing them
280 * @return Whether the required personal data is set
282 boolean isRequiredChangePersonalDataSet ();
285 * Checks whether same passwords has been entered
287 * @return Whether same passwords has been entered
289 boolean isSamePasswordEntered ();
292 * Checks if the user id is empty
294 * @return Whether the user id is empty
296 boolean isUserIdEmpty ();
299 * Changes logged-in user's personal data if the current password matches
300 * and TAC + privacy statement has been accepted.
302 * @return New target page
304 String doChangePersonalData ();
307 * Checks whether this application requires a user name to be entered.
308 * Otherwise a random name like "userXXXXX" is generated
310 * @return Whether this application requires a user name
312 boolean isUserNameRequired ();
315 * Checks wether public user profiles are enabled. This requires that user
316 * names are also enabled.
318 * @return Whether public user profiles are enabled
320 boolean isPublicUserProfileEnabled ();