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.jcontacts.events.contact.add.AdminAddedContactEvent;
23 import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
24 import org.mxchange.jusercore.events.login.UserLoggedInEvent;
25 import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
26 import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
27 import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
28 import org.mxchange.jusercore.events.user.update.AdminUpdatedUserDataEvent;
29 import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
30 import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
31 import org.mxchange.jusercore.exceptions.UserNotFoundException;
32 import org.mxchange.jusercore.model.user.User;
33 import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
36 * An interface for user beans
38 * @author Roland Haeder<roland@mxchange.org>
40 public interface JobsUserWebSessionController extends Serializable {
43 * Minimum password length
45 public static final Integer MINIMUM_PASSWORD_LENGTH = 5;
48 * Observes events being fired when an administrator has added a new
51 * @param event Event being fired
53 void afterAdminAddedContact (final AdminAddedContactEvent event);
56 * Event observer for newly added users by adminstrator
58 * @param event Event being fired
60 void afterAdminAddedUserEvent (final AdminAddedUserEvent event);
63 * Event observer for updated user data by administrator
65 * @param event Event being updated
67 void afterAdminUpdatedUserDataEvent (final AdminUpdatedUserDataEvent event);
70 * Event observer when user confirmed account.
72 * @param event Event being fired
74 void afterUserConfirmedAccount (final UserConfirmedAccountEvent event);
77 * Method being call after user's password has been updated (and history
78 * entry has been created).
80 * @param event Event being observed
82 void afterUserUpdatedPasswordEvent (final UpdatedUserPasswordEvent event);
85 * Listens to fired event when user updated personal data
87 * @param event Event being fired
89 void afterUserUpdatedPersonalData (final UpdatedUserPersonalDataEvent event);
92 * Event observer for new user registrations
94 * @param event User registration event
96 void afterRegistrationEvent (final UserRegisteredEvent event);
99 * Event observer for logged-in user
101 * @param event Event instance
103 void afterUserLogin (final UserLoggedInEvent event);
108 * @return A list of all public user profiles
110 List<User> allUsers ();
113 * All public user profiles
115 * @return A list of all public user profiles
117 List<User> allVisibleUsers ();
120 * Checks whether users are registered
122 * @return Whether users are registered
127 * Checks whether the given contact is a user
129 * @param contact Contact to check
131 * @return Whether the contact is a user
133 boolean isContactFound (final Contact contact);
136 * Checks whether a public user account is registered. This means that at
137 * least one user profile has its flag "public user profile" enabled.
139 * @return Whether at least one user has a public profile
141 boolean isVisibleUserFound ();
144 * Checks whether given user instance's name is used
146 * @param user User instance's name to check
148 * @return Whether it is already used
150 boolean isUserNameRegistered (final User user);
153 * Tries to lookup user by given id number. If the user is not found or the
154 * account status is not CONFIRMED proper exceptions are thrown.
156 * @param userId User id
158 * @return User instance
160 * @throws UserNotFoundException If the user is not found
162 User lookupUserById (final Long userId) throws UserNotFoundException;
165 * Tries to lookup user by given email address. If the user is not found a
166 * proper exceptions is thrown.
168 * @param emailAddress Email address
170 * @return User instance
172 * @throws UserEmailAddressNotFoundException If the user's email address is not found
174 User lookupUserByEmailAddress (final String emailAddress) throws UserEmailAddressNotFoundException;
177 * Returns a list of all selectable contacts for user creation. Contacts
178 * from already existing users are excluded in this list.
180 * @return A list of all selectable contacts
182 List<Contact> selectableContacts ();
185 * Creates an instance from all properties
187 * @return A user instance
189 User createUserInstance ();
192 * Creates a user instance for login phase
194 * @return User instance
196 User createUserLogin ();
208 * @param userId User id
210 void setUserId (final Long userId);
213 * Getter for user name
217 String getUserName ();
220 * Setter for user name
222 * @param userName User name
224 void setUserName (final String userName);
227 * Getter for unencrypted user password
229 * @return Unencrypted user password
231 String getUserPassword ();
234 * Setter for unencrypted user password
236 * @param userPassword Unencrypted user password
238 void setUserPassword (final String userPassword);
241 * Getter for unencrypted user password repeated
243 * @return Unencrypted user password repeated
245 String getUserPasswordRepeat ();
248 * Setter for unencrypted user password repeated
250 * @param userPasswordRepeat Unencrypted user password repeated
252 void setUserPasswordRepeat (final String userPasswordRepeat);
255 * Getter for user profile mode
257 * @return User profile mode
259 ProfileMode getUserProfileMode ();
262 * Setter for user profile mode
264 * @param userProfileMode User profile mode
266 void setUserProfileMode (final ProfileMode userProfileMode);
269 * Checks whether all required personal data is set
271 * @return Whether the required personal data is set
273 boolean isRequiredPersonalDataSet ();
276 * Checks whether all required personal data is set for changing them
278 * @return Whether the required personal data is set
280 boolean isRequiredChangePersonalDataSet ();
283 * Checks whether same passwords has been entered
285 * @return Whether same passwords has been entered
287 boolean isSamePasswordEntered ();
290 * Checks if the user id is empty
292 * @return Whether the user id is empty
294 boolean isUserIdEmpty ();
297 * Changes logged-in user's personal data if the current password matches
298 * and TAC + privacy statement has been accepted.
300 * @return New target page
302 String doChangePersonalData ();
305 * Checks whether this application requires a user name to be entered.
306 * Otherwise a random name like "userXXXXX" is generated
308 * @return Whether this application requires a user name
310 boolean isUserNameRequired ();
313 * Checks wether public user profiles are enabled. This requires that user
314 * names are also enabled.
316 * @return Whether public user profiles are enabled
318 boolean isPublicUserProfileEnabled ();