file.reference.juser-activity-lib.jar=lib/juser-activity-lib.jar
file.reference.juser-core.jar=lib/juser-core.jar
file.reference.juser-lib.jar=lib/juser-lib.jar
+file.reference.juser-login-core.jar=lib/juser-login-core.jar
+file.reference.juser-login-lib.jar=lib/juser-login-lib.jar
includes=**
j2ee.compile.on.save=true
j2ee.copy.static.files.on.save=true
${file.reference.juser-core.jar}:\
${file.reference.juser-lib.jar}:\
${file.reference.juser-activity-core.jar}:\
+ ${file.reference.juser-login-core.jar}:\
+ ${file.reference.juser-login-lib.jar}:\
+ ${file.reference.juser-activity-lib.jar}:\
${file.reference.jcontacts-business-core.jar}:\
${file.reference.jcontacts-business-lib.jar}:\
- ${file.reference.juser-activity-lib.jar}:\
${file.reference.jaddressbook-core.jar}:\
${file.reference.jaddressbook-lib.jar}:\
${reference.jjobs-core.jar}:\
source.reference.juser-lib.jar=../juser-lib/src/
source.reference.jaddressbook-core.jar=../jaddressbook-core/src/
source.reference.jaddressbook-lib.jar=../jaddressbook-lib/src/
+source.reference.juser-login-core.jar=../juser-login-core/src/
+source.reference.juser-login-lib.jar=../juser-login-lib/src/
source.root=src
src.dir=${source.root}/java
test.src.dir=test
<file>${file.reference.juser-activity-core.jar}</file>
</library>
<library dirs="200">
- <file>${file.reference.jcontacts-business-core.jar}</file>
+ <file>${file.reference.juser-login-core.jar}</file>
</library>
<library dirs="200">
- <file>${file.reference.jcontacts-business-lib.jar}</file>
+ <file>${file.reference.juser-login-lib.jar}</file>
</library>
<library dirs="200">
<file>${file.reference.juser-activity-lib.jar}</file>
</library>
+ <library dirs="200">
+ <file>${file.reference.jcontacts-business-core.jar}</file>
+ </library>
+ <library dirs="200">
+ <file>${file.reference.jcontacts-business-lib.jar}</file>
+ </library>
<library dirs="200">
<file>${file.reference.jaddressbook-core.jar}</file>
</library>
import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry;
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
/**
* An address book bean (controller)
import org.mxchange.jaddressbook.events.addressbook.ObservableAddressbookLoadedEvent;
import org.mxchange.jaddressbook.model.addressbook.Addressbook;
import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
/**
* An interface for address book beans
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.Locale;
-import java.util.MissingResourceException;
import java.util.Objects;
-import java.util.ResourceBundle;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Observes;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
import javax.faces.view.facelets.FaceletException;
import javax.inject.Inject;
import javax.inject.Named;
import javax.naming.NamingException;
import org.mxchange.jcontacts.contact.Contact;
import org.mxchange.jcontacts.contact.ContactSessionBeanRemote;
+import org.mxchange.jcontacts.contact.ContactUtils;
import org.mxchange.jcontacts.contact.UserContact;
import org.mxchange.jcontacts.contact.title.PersonalTitle;
-import org.mxchange.jcontacts.contact.ContactUtils;
import org.mxchange.jcontacts.events.contact.add.ObservableAdminAddedContactEvent;
import org.mxchange.jcontacts.events.contact.update.ObservableAdminUpdatedContactEvent;
import org.mxchange.jcontacts.exceptions.ContactNotFoundException;
import org.mxchange.jcountry.data.Country;
import org.mxchange.jjobs.beans.BaseJobsController;
-import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
+import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
import org.mxchange.jphone.phonenumbers.fax.DialableFaxNumber;
import org.mxchange.jphone.phonenumbers.fax.FaxNumber;
import org.mxchange.jphone.phonenumbers.landline.DialableLandLineNumber;
import org.mxchange.jphone.phonenumbers.mobile.DialableMobileNumber;
import org.mxchange.jphone.phonenumbers.mobile.MobileNumber;
import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
-import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
-import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent;
+import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
+import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
+import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
/**
* A general contact controller (bean)
*/
@Named ("contactController")
@SessionScoped
-public abstract class JobsContactWebSessionBean extends BaseJobsController implements JobsContactWebSessionController {
+public class JobsContactWebSessionBean extends BaseJobsController implements JobsContactWebSessionController {
/**
* Serial number
this.contactList.add(contact);
}
- /**
- * Returns given property key or throws an exception if not found.
- * <p>
- * @param parameterKey Property key
- * <p>
- * @return Property value
- * <p>
- * @throws NullPointerException If given key is not found
- * @throws NumberFormatException If no number is given in context parameter
- */
- protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException {
- // Get context parameter
- Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey));
- // Return it
- return contextValue;
- }
-
- /**
- * Returns given property key or throws an exception if not found.
- * <p>
- * @param parameterKey Property key
- * <p>
- * @return Property value
- * <p>
- * @throws NullPointerException If given key is not found
- */
- protected String getStringContextParameter (final String parameterKey) throws NullPointerException {
- // Get context parameter
- String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey);
- // Is it null?
- if (null == contextValue) {
- // Throw NPE
- throw new NullPointerException(MessageFormat.format("parameterKey={0} is not set.", parameterKey)); //NOI18N
- }
- // Return it
- return contextValue;
- }
-
- /**
- * Checks whether debug mode is enabled for given controller
- * <p>
- * @param controllerName Name of controller
- * <p>
- * @return Whether debug mode is enabled
- */
- protected boolean isDebugModeEnabled (final String controllerName) {
- // Parameters should be valid
- if (null == controllerName) {
- // Throw NPE
- throw new NullPointerException("controllerName is null"); //NOI18N
- } else if (controllerName.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("controllerName is empty"); //NOI18N
- }
- // Try to get context parameter
- String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N
- // Is it set and true?
- boolean isEnabled = Boolean.parseBoolean(contextParameter) == Boolean.TRUE;
- // Return it
- return isEnabled;
- }
-
- /**
- * Loads resource bundle for given locale. This must be implemented per
- * project so all projects can still customize their methods. Calling
- * ResourceBundleloadBundle() in this class means that also the bundle files
- * must be present here.
- * <p>
- * @param locale Locale from e.g. FacesContext
- * <p>
- * @return Initialized and loaded resource bundle
- */
- protected abstract ResourceBundle loadResourceBundle (final Locale locale);
-
- /**
- * Shows a faces message for given causing exception. The message from the
- * exception is being inserted into the message.
- * <p>
- * @param clientId Client id to send message to
- * @param cause Causing exception
- */
- protected void showFacesMessage (final String clientId, final Throwable cause) {
- // Get context and add message
- this.showFacesMessage(clientId, cause.getMessage());
- }
-
- /**
- * Shows a faces message with given message (i18n) key.
- * <p>
- * @param clientId Client id to send message to
- * @param i18nKey Message key
- * <p>
- * @throws NullPointerException If clientId or i18nKey is null
- * @throws IllegalArgumentException If clientId or i18nKey is empty
- */
- protected void showFacesMessage (final String clientId, final String i18nKey) throws NullPointerException, IllegalArgumentException {
- // Both parameter must be valid
- if (null == clientId) {
- // Throw NPE
- throw new NullPointerException("clientId is null"); //NOI18N
- } else if (clientId.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("clientId is null"); //NOI18N
- } else if (null == i18nKey) {
- // Throw NPE
- throw new NullPointerException("i18nKey is null"); //NOI18N
- } else if (i18nKey.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("i18nKey is null"); //NOI18N
- }
- // Get current locale
- Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
- // Get bundle bundle
- ResourceBundle bundle = this.loadResourceBundle(locale);
- // Default is i18nKey
- String message = MessageFormat.format("!{0}!", i18nKey); //NOI18N
- // Try it
- try {
- // Get message
- message = bundle.getString(i18nKey);
- } catch (final MissingResourceException ex) {
- // Did not find it, ignored
- }
- // Get context and add message
- FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message));
- }
-
}
import javax.faces.context.FacesContext;
import javax.inject.Named;
import org.mxchange.jjobs.beans.BaseJobsController;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
-import org.mxchange.jusercore.events.logout.ObservableUserLogoutEvent;
+import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
+import org.mxchange.juserlogincore.events.logout.ObservableUserLogoutEvent;
/**
* A session-scoped bean for handling localization/internationalization changes.
import org.mxchange.jjobs.beans.contact.JobsContactWebSessionController;
import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController;
import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController;
-import org.mxchange.jusercore.container.login.UserLoginContainer;
-import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
import org.mxchange.jusercore.events.user.add.AdminAddedUserEvent;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
import org.mxchange.jusercore.events.user.delete.AdminDeletedUserEvent;
import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserPasswordRepeatMismatchException;
import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
import org.mxchange.jusercore.exceptions.UserStatusLockedException;
import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-import org.mxchange.jusercore.model.user.UserUtils;
import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.juserlogincore.container.login.UserLoginContainer;
+import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
+import org.mxchange.juserlogincore.exceptions.UserPasswordRepeatMismatchException;
+import org.mxchange.juserlogincore.login.UserLoginUtils;
/**
* A user controller (bean)
return ""; //NOI18N
} else if ((this.getUserPassword() == null && (this.getUserPasswordRepeat() == null)) || ((this.getUserPassword().isEmpty()) && (this.getUserPasswordRepeat().isEmpty()))) {
// Empty password entered, then generate one
- password = UserUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
+ password = UserLoginUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
} else if (!this.isSamePasswordEntered()) {
// Both passwords don't match
throw new FaceletException(new UserPasswordRepeatMismatchException(user));
assert (password.length() >= JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH) : "Password is not long enough."; //NOI18N
// Encrypt password and set it
- user.setUserEncryptedPassword(UserUtils.encryptPassword(password));
+ user.setUserEncryptedPassword(UserLoginUtils.encryptPassword(password));
try {
// Now, that all is set, call EJB
return ""; //NOI18N
} else if (this.isSamePasswordEntered()) {
// Same password entered, create container
- if ((Objects.equals(user.getUserMustChangePassword(), this.getUserMustChangePassword())) && (UserUtils.ifPasswordMatches(new UserLoginContainer(user, this.getUserPassword())))) {
+ if ((Objects.equals(user.getUserMustChangePassword(), this.getUserMustChangePassword())) && (UserLoginUtils.ifPasswordMatches(new UserLoginContainer(user, this.getUserPassword())))) {
// Clear password fields
this.setUserPassword(null);
this.setUserPasswordRepeat(null);
}
// Encrypt password
- encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
+ encryptedPassword = UserLoginUtils.encryptPassword(this.getUserPassword());
}
// Set user name and flag
import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController;
import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
-import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
-import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
-import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
import org.mxchange.jusercore.events.user.update.ObservableAdminUpdatedUserDataEvent;
import org.mxchange.jusercore.events.user.update.ObservableUpdatedUserPersonalDataEvent;
import org.mxchange.jusercore.events.user.update.UpdatedUserPersonalDataEvent;
import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-import org.mxchange.jusercore.model.user.UserUtils;
import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
+import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent;
+import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
+import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
+import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
+import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
+import org.mxchange.juserlogincore.login.UserLoginUtils;
/**
* A user controller (bean)
this.setUserProfileMode(ProfileMode.INVISIBLE);
// Generate random password
- String randomPassword = UserUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
+ String randomPassword = UserLoginUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
// Set random password
this.setUserPassword(randomPassword);
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
-import java.util.Locale;
import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
-import javax.faces.application.FacesMessage;
-import javax.faces.context.FacesContext;
import javax.faces.view.facelets.FaceletException;
import javax.inject.Inject;
import javax.inject.Named;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.mxchange.jjobs.beans.BaseJobsController;
-import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.activity.LogableUserActivity;
-import org.mxchange.jusercore.model.user.activity.UserActivityLog;
-import org.mxchange.jusercore.model.user.activity.UserActivityLogSessionBeanRemote;
-import org.mxchange.jusercore.model.user.activity.comparator.UserActivityLogTimestampComparator;
-import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
-import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
-import org.mxchange.jusercore.events.resendlink.ObservableUserResendLinkAccountEvent;
+import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController;
import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
-import org.mxchange.jusercore.events.logout.ObservableUserLogoutEvent;
import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
-import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
import org.mxchange.jusercore.events.user.update.ObservableAdminUpdatedUserDataEvent;
import org.mxchange.jusercore.events.user.update.ObservableUpdatedUserPersonalDataEvent;
-import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController;
+import org.mxchange.jusercore.model.user.User;
+import org.mxchange.jusercore.model.user.activity.LogableUserActivity;
+import org.mxchange.jusercore.model.user.activity.UserActivityLog;
+import org.mxchange.jusercore.model.user.activity.UserActivityLogSessionBeanRemote;
+import org.mxchange.jusercore.model.user.activity.comparator.UserActivityLogTimestampComparator;
+import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent;
+import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
+import org.mxchange.juserlogincore.events.logout.ObservableUserLogoutEvent;
+import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
+import org.mxchange.juserlogincore.events.resendlink.ObservableUserResendLinkAccountEvent;
+import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
/**
* A controller (bean) for user activity log
*/
@Named ("userActivityController")
@ApplicationScoped
-public abstract class JobsUserActivityWebApplicationBean extends BaseJobsController implements JobsUserActivityWebApplicationController {
+public class JobsUserActivityWebApplicationBean extends BaseJobsController implements JobsUserActivityWebApplicationController {
/**
* Serial number
this.addUserActivityToCache(userActivity);
}
- @Override
+ /**
+ * Event observer for newly added users by administrator
+ * <p>
+ * @param event Event being fired
+ */
public void afterAdminAddedUserEvent (@Observes final ObservableAdminAddedUserEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getAddedUser(), "ADMIN_ADDED_USER_ACCOUNT"); //NOI18N
}
- @Override
+ /**
+ * Event observer for deleted user accounts (by administrator)
+ * <p>
+ * @param event Event being fired
+ */
public void afterAdminDeletedUserEvent (@Observes final ObservableAdminDeletedUserEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getDeletedUser(), "ADMIN_DELETED_USER_ACCOUNT", event.getUserDeleteReason()); //NOI18N
}
- @Override
+ /**
+ * Event observer for linked users with existing contact data
+ * <p>
+ * @param event Event being fired
+ */
public void afterAdminLinkedUserEvent (@Observes final ObservableAdminLinkedUserEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getLinkedUser(), "ADMIN_LINKED_USER_ACCOUNT"); //NOI18N
}
- @Override
+ /**
+ * Event observer for locked users
+ * <p>
+ * @param event Event being fired
+ */
public void afterAdminLockedUserEvent (@Observes final ObservableAdminLockedUserEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getLockedUser(), "ADMIN_LOCKED_USER_ACCOUNT", event.getLockedUser().getUserLastLockedReason()); //NOI18N
}
- @Override
+ /**
+ * Event observer for unlocked users
+ * <p>
+ * @param event Event being fired
+ */
public void afterAdminUnlockedUserEvent (@Observes final ObservableAdminUnlockedUserEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getUnlockedUser(), "ADMIN_UNLOCKED_USER_ACCOUNT"); //NOI18N
}
- @Override
+ /**
+ * Event observer for updated user data by administrator
+ * <p>
+ * @param event Event being updated
+ */
public void afterAdminUpdatedUserDataEvent (@Observes final ObservableAdminUpdatedUserDataEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getUpdatedUser(), "ADMIN_UPDATED_USER_PERSONAL_DATA"); //NOI18N
}
- @Override
+ /**
+ * Event observer when user confirmed account.
+ * <p>
+ * @param event Event being fired
+ */
public void afterUserConfirmedAccountEvent (@Observes final ObservableUserConfirmedAccountEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getConfirmedUser(), "USER_CONFIRMED_ACCOUNT"); //NOI18N
}
- @Override
+ /**
+ * Event observer for logged-in user
+ * <p>
+ * @param event Event being fired
+ */
public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getLoggedInUser(), "USER_LOGGED_IN"); //NOI18N
}
- @Override
+ /**
+ * Event observer for logged-out user
+ * <p>
+ * @param event Event instance
+ */
public void afterUserLogoutEvent (@Observes final ObservableUserLogoutEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getLoggedOutUser(), "USER_LOGGED_OUT"); //NOI18N
}
- @Override
+ /**
+ * Event observer for new user registrations
+ * <p>
+ * @param event Event being fired
+ */
public void afterUserRegistrationEvent (@Observes final ObservableUserRegisteredEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getRegisteredUser(), "USER_REGISTERED_NEW_ACCOUNT"); //NOI18N
}
- @Override
+ /**
+ * Event observer for users resending their confirmation link
+ * <p>
+ * @param event Event being fired
+ */
public void afterUserResendConfirmationLinkEvent (@Observes final ObservableUserResendLinkAccountEvent event) {
// event should not be null
if (null == event) {
this.addUserActivity(event.getResendLinkUser(), "USER_RESEND_CONFIRMATION_LINK"); //NOI18N
}
- @Override
+ /**
+ * Method being call after user's password has been updated (and history
+ * entry has been created).
+ * <p>
+ * @param event Event being observed
+ */
public void afterUserUpdatedPasswordEvent (@Observes final ObservableUpdatedUserPasswordEvent event) {
// Check parameter
if (null == event) {
this.addUserActivity(event.getPasswordHistory().getUserPasswordHistoryUser(), "USER_UPDATED_PASSWORD"); //NOI18N
}
- @Override
+ /**
+ * Listens to fired event when user updated personal data
+ * <p>
+ * @param event Event being fired
+ */
public void afterUserUpdatedPersonalDataEvent (@Observes final ObservableUpdatedUserPersonalDataEvent event) {
// Check parameter
if (null == event) {
this.usersActivity.get(userActivity.getActivityUser()).add(userActivity);
}
- /**
- * Returns given property key or throws an exception if not found.
- * <p>
- * @param parameterKey Property key
- * <p>
- * @return Property value
- * <p>
- * @throws NullPointerException If given key is not found
- * @throws NumberFormatException If no number is given in context parameter
- */
- protected int getIntegerContextParameter (final String parameterKey) throws NullPointerException, NumberFormatException {
- // Get context parameter
- Integer contextValue = Integer.parseInt(this.getStringContextParameter(parameterKey));
- // Return it
- return contextValue;
- }
-
- /**
- * Returns given property key or throws an exception if not found.
- * <p>
- * @param parameterKey Property key
- * <p>
- * @return Property value
- * <p>
- * @throws NullPointerException If given key is not found
- */
- protected String getStringContextParameter (final String parameterKey) throws NullPointerException {
- // Get context parameter
- String contextValue = FacesContext.getCurrentInstance().getExternalContext().getInitParameter(parameterKey);
- // Is it null?
- if (null == contextValue) {
- // Throw NPE
- throw new NullPointerException(MessageFormat.format("parameterKey={0} is not set.", parameterKey)); //NOI18N
- }
- // Return it
- return contextValue;
- }
-
- /**
- * Checks whether debug mode is enabled for given controller
- * <p>
- * @param controllerName Name of controller
- * <p>
- * @return Whether debug mode is enabled
- */
- protected boolean isDebugModeEnabled (final String controllerName) {
- // Parameters should be valid
- if (null == controllerName) {
- // Throw NPE
- throw new NullPointerException("controllerName is null"); //NOI18N
- } else if (controllerName.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("controllerName is empty"); //NOI18N
- }
- // Try to get context parameter
- String contextParameter = this.getStringContextParameter(String.format("is_debug_%s_enabled", controllerName)); //NOI18N
- // Is it set and true?
- boolean isEnabled = Boolean.parseBoolean(contextParameter) == Boolean.TRUE;
- // Return it
- return isEnabled;
- }
-
- /**
- * Loads resource bundle for given locale. This must be implemented per
- * project so all projects can still customize their methods. Calling
- * ResourceBundleloadBundle() in this class means that also the bundle files
- * must be present here.
- * <p>
- * @param locale Locale from e.g. FacesContext
- * <p>
- * @return Initialized and loaded resource bundle
- */
- protected abstract ResourceBundle loadResourceBundle (final Locale locale);
-
- /**
- * Shows a faces message for given causing exception. The message from the
- * exception is being inserted into the message.
- * <p>
- * @param clientId Client id to send message to
- * @param cause Causing exception
- */
- protected void showFacesMessage (final String clientId, final Throwable cause) {
- // Get context and add message
- this.showFacesMessage(clientId, cause.getMessage());
- }
-
- /**
- * Shows a faces message with given message (i18n) key.
- * <p>
- * @param clientId Client id to send message to
- * @param i18nKey Message key
- * <p>
- * @throws NullPointerException If clientId or i18nKey is null
- * @throws IllegalArgumentException If clientId or i18nKey is empty
- */
- protected void showFacesMessage (final String clientId, final String i18nKey) throws NullPointerException, IllegalArgumentException {
- // Both parameter must be valid
- if (null == clientId) {
- // Throw NPE
- throw new NullPointerException("clientId is null"); //NOI18N
- } else if (clientId.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("clientId is null"); //NOI18N
- } else if (null == i18nKey) {
- // Throw NPE
- throw new NullPointerException("i18nKey is null"); //NOI18N
- } else if (i18nKey.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("i18nKey is null"); //NOI18N
- }
- // Get current locale
- Locale locale = FacesContext.getCurrentInstance().getViewRoot().getLocale();
- // Get bundle bundle
- ResourceBundle bundle = this.loadResourceBundle(locale);
- // Default is i18nKey
- String message = MessageFormat.format("!{0}!", i18nKey); //NOI18N
- // Try it
- try {
- // Get message
- message = bundle.getString(i18nKey);
- } catch (final MissingResourceException ex) {
- // Did not find it, ignored
- }
- // Get context and add message
- FacesContext.getCurrentInstance().addMessage(clientId, new FacesMessage(message));
- }
-
}
import javax.ejb.Local;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.activity.LogableUserActivity;
-import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
-import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
-import org.mxchange.jusercore.events.resendlink.ObservableUserResendLinkAccountEvent;
-import org.mxchange.jusercore.events.user.add.ObservableAdminAddedUserEvent;
-import org.mxchange.jusercore.events.logout.ObservableUserLogoutEvent;
-import org.mxchange.jusercore.events.user.delete.ObservableAdminDeletedUserEvent;
-import org.mxchange.jusercore.events.user.linked.ObservableAdminLinkedUserEvent;
-import org.mxchange.jusercore.events.user.locked.ObservableAdminLockedUserEvent;
-import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
-import org.mxchange.jusercore.events.user.unlocked.ObservableAdminUnlockedUserEvent;
-import org.mxchange.jusercore.events.user.update.ObservableAdminUpdatedUserDataEvent;
-import org.mxchange.jusercore.events.user.update.ObservableUpdatedUserPersonalDataEvent;
/**
* A controller (bean) interface for user activity log
@Local
public interface JobsUserActivityWebApplicationController extends Serializable {
- /**
- * Event observer for newly added users by adminstrator
- * <p>
- * @param event Event being fired
- */
- void afterAdminAddedUserEvent (final ObservableAdminAddedUserEvent event);
-
- /**
- * Event observer for deleted user accounts (by administrator)
- * <p>
- * @param event Event being fired
- */
- void afterAdminDeletedUserEvent (final ObservableAdminDeletedUserEvent event);
-
- /**
- * Event observer for linked users with existing contact data
- * <p>
- * @param event Event being fired
- */
- void afterAdminLinkedUserEvent (final ObservableAdminLinkedUserEvent event);
-
- /**
- * Event observer for locked users
- * <p>
- * @param event Event being fired
- */
- void afterAdminLockedUserEvent (final ObservableAdminLockedUserEvent event);
-
- /**
- * Event observer for unlocked users
- * <p>
- * @param event Event being fired
- */
- void afterAdminUnlockedUserEvent (final ObservableAdminUnlockedUserEvent event);
-
- /**
- * Event observer for updated user data by administrator
- * <p>
- * @param event Event being updated
- */
- void afterAdminUpdatedUserDataEvent (final ObservableAdminUpdatedUserDataEvent event);
-
- /**
- * Event observer when user confirmed account.
- * <p>
- * @param event Event being fired
- */
- void afterUserConfirmedAccountEvent (final ObservableUserConfirmedAccountEvent event);
-
- /**
- * Event observer for logged-out user
- * <p>
- * @param event Event instance
- */
- void afterUserLogoutEvent (final ObservableUserLogoutEvent event);
-
- /**
- * Method being call after user's password has been updated (and history
- * entry has been created).
- * <p>
- * @param event Event being observed
- */
- void afterUserUpdatedPasswordEvent (final ObservableUpdatedUserPasswordEvent event);
-
- /**
- * Listens to fired event when user updated personal data
- * <p>
- * @param event Event being fired
- */
- void afterUserUpdatedPersonalDataEvent (final ObservableUpdatedUserPersonalDataEvent event);
-
- /**
- * Event observer for new user registrations
- * <p>
- * @param event Event being fired
- */
- void afterUserRegistrationEvent (final ObservableUserRegisteredEvent event);
-
- /**
- * Event observer for logged-in user
- * <p>
- * @param event Event being fired
- */
- void afterUserLoginEvent (final ObservableUserLoggedInEvent event);
-
- /**
- * Event observer for users resending their confirmation link
- * <p>
- * @param event Event being fired
- */
- void afterUserResendConfirmationLinkEvent (final ObservableUserResendLinkAccountEvent event);
-
/**
* Adds user activity entry with given type
* <p>
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.helper.JobsWebRequestHelperController;
import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
-import org.mxchange.jusercore.events.confirmation.ObservableUserConfirmedAccountEvent;
-import org.mxchange.jusercore.events.confirmation.UserConfirmedAccountEvent;
import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
import org.mxchange.jusercore.exceptions.UserStatusLockedException;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.juserlogincore.events.confirmation.ObservableUserConfirmedAccountEvent;
+import org.mxchange.juserlogincore.events.confirmation.UserConfirmedAccountEvent;
/**
* A web request bean for confirmation link handling
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
import org.mxchange.jusercore.model.email_address.ChangeableEmailAddress;
import org.mxchange.jusercore.model.email_address.EmailAddressChange;
import org.mxchange.jusercore.model.user.email_address.UserEmailChangeSessionBeanRemote;
import org.mxchange.jusercore.model.user.User;
+import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
/**
* A web session-scoped bean for changing email addresses
import javax.naming.NamingException;
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
-import org.mxchange.jusercore.container.login.LoginContainer;
-import org.mxchange.jusercore.container.login.UserLoginContainer;
-import org.mxchange.jusercore.events.login.ObservableUserLoggedInEvent;
-import org.mxchange.jusercore.events.login.UserLoggedInEvent;
-import org.mxchange.jusercore.events.logout.ObservableUserLogoutEvent;
-import org.mxchange.jusercore.events.logout.UserLogoutEvent;
-import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
import org.mxchange.jusercore.exceptions.UserStatusLockedException;
import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
-import org.mxchange.jusercore.model.login.user.UserLoginSessionBeanRemote;
import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserUtils;
import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
import org.mxchange.jusercore.model.user.password_history.UserPasswordHistorySessionBeanRemote;
import org.mxchange.jusercore.model.user.profilemodes.ProfileMode;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.juserlogincore.container.login.LoginContainer;
+import org.mxchange.juserlogincore.container.login.UserLoginContainer;
+import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
+import org.mxchange.juserlogincore.events.login.UserLoggedInEvent;
+import org.mxchange.juserlogincore.events.logout.ObservableUserLogoutEvent;
+import org.mxchange.juserlogincore.events.logout.UserLogoutEvent;
+import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
+import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
+import org.mxchange.juserlogincore.login.UserLoginUtils;
+import org.mxchange.juserlogincore.model.login.user.UserLoginSessionBeanRemote;
/**
* A web bean for user registration
LoginContainer container = new UserLoginContainer(this.getLoggedInUser(), this.getUserCurrentPassword());
// Now check if it matches
- return UserUtils.ifPasswordMatches(container, this.getLoggedInUser());
+ return UserLoginUtils.ifPasswordMatches(container, this.getLoggedInUser());
}
@Override
// Check all passwords
for (final PasswordHistory entry : this.getUserPasswordHistory()) {
// Is password the same?
- if (UserUtils.ifPasswordMatches(userPassword, entry.getUserPasswordHistoryUser())) {
+ if (UserLoginUtils.ifPasswordMatches(userPassword, entry.getUserPasswordHistoryUser())) {
// Yes, found it
isPasswordInHistory = true;
break;
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
import org.mxchange.jjobs.beans.user.login.JobsUserLoginWebSessionController;
-import org.mxchange.jusercore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
-import org.mxchange.jusercore.events.user.password_change.UpdatedUserPasswordEvent;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
-import org.mxchange.jusercore.exceptions.UserPasswordMismatchException;
import org.mxchange.jusercore.exceptions.UserStatusLockedException;
import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
-import org.mxchange.jusercore.model.user.UserUtils;
import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
+import org.mxchange.juserlogincore.events.user.password_change.ObservableUpdatedUserPasswordEvent;
+import org.mxchange.juserlogincore.events.user.password_change.UpdatedUserPasswordEvent;
+import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
+import org.mxchange.juserlogincore.login.UserLoginUtils;
/**
* A user password (change) controller (bean)
} else if (!this.featureController.isFeatureEnabled("change_user_password")) { //NOI18N
// Editing is not allowed
throw new IllegalStateException("User tried to change password."); //NOI18N
- } else if (!UserUtils.ifPasswordMatches(this.getUserCurrentPassword(), this.userLoginController.getLoggedInUser())) {
+ } else if (!UserLoginUtils.ifPasswordMatches(this.getUserCurrentPassword(), this.userLoginController.getLoggedInUser())) {
// Password mismatches
this.showFacesMessage("form_user_change_password:userCurrentPassword", "Entered current password does not matched stored password."); //NOI18N
User user = this.userLoginController.getLoggedInUser();
// Encrypt password
- String encryptedPassword = UserUtils.encryptPassword(this.getUserPassword());
+ String encryptedPassword = UserLoginUtils.encryptPassword(this.getUserPassword());
// Set it in user
user.setUserEncryptedPassword(encryptedPassword);
import org.mxchange.jjobs.beans.features.JobsFeaturesWebApplicationController;
import org.mxchange.jjobs.beans.user.JobsAdminUserWebRequestController;
import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
-import org.mxchange.jusercore.events.registration.ObservableUserRegisteredEvent;
-import org.mxchange.jusercore.events.registration.UserRegisteredEvent;
import org.mxchange.jusercore.exceptions.DataRepeatMismatchException;
import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.UserUtils;
-import org.mxchange.jusercore.model.user.register.UserRegistrationSessionBeanRemote;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.juserlogincore.events.registration.ObservableUserRegisteredEvent;
+import org.mxchange.juserlogincore.events.registration.UserRegisteredEvent;
+import org.mxchange.juserlogincore.login.UserLoginUtils;
+import org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote;
/**
* A web bean for user registration
throw new FaceletException(new DataRepeatMismatchException("Passwords not matching.")); //NOI18N
} else if (this.userController.ifBothPasswordsEmptyAllowed()) {
// Both passwords are left empty and is allowed, then generate a random password
- randomPassword = UserUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
+ randomPassword = UserLoginUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
// Set it in both fields
this.userController.setUserPassword(randomPassword);
}
// Encrypt password
- String encryptedPassword = UserUtils.encryptPassword(this.userController.getUserPassword());
+ String encryptedPassword = UserLoginUtils.encryptPassword(this.userController.getUserPassword());
// Set it here
user.setUserEncryptedPassword(encryptedPassword);
return ""; //NOI18N
} else if (this.userController.ifBothPasswordsEmptyAllowed()) {
// Both passwords are left empty and is allowed, then generate a random password
- String randomPassword = UserUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
+ String randomPassword = UserLoginUtils.createRandomPassword(JobsUserWebSessionController.MINIMUM_PASSWORD_LENGTH);
// Set it in both fields
this.userController.setUserPassword(randomPassword);
import org.mxchange.jjobs.beans.BaseJobsController;
import org.mxchange.jjobs.beans.localization.JobsLocalizationSessionController;
import org.mxchange.jjobs.beans.user.JobsUserWebSessionController;
-import org.mxchange.jusercore.events.resendlink.ObservableUserResendLinkAccountEvent;
-import org.mxchange.jusercore.events.resendlink.UserResendLinkAccountEvent;
import org.mxchange.jusercore.exceptions.UserEmailAddressNotFoundException;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
import org.mxchange.jusercore.exceptions.UserStatusLockedException;
import org.mxchange.jusercore.model.user.User;
-import org.mxchange.jusercore.model.user.resendlink.ResendLinkSessionBeanRemote;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.juserlogincore.events.resendlink.ObservableUserResendLinkAccountEvent;
+import org.mxchange.juserlogincore.events.resendlink.UserResendLinkAccountEvent;
+import org.mxchange.juserlogincore.model.user.resendlink.ResendLinkSessionBeanRemote;
/**
* A web session-scoped bean for resending confirmation link