import org.mxchange.jcontactsbusiness.model.department.Department;
import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition;
+import org.mxchange.jcontactsbusiness.model.utils.EmployeeUtils;
import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
import org.mxchange.jphone.model.phonenumbers.mobileprovider.MobileProvider;
import org.mxchange.jusercore.model.user.User;
// Check all entries
for (final Employable otherEmployee : this.employeeBean.fetchAllEmployees()) {
// Is same found?
- if (Employees.isSameEmployeeFound(employee, otherEmployee)) {
+ if (EmployeeUtils.isSameEmployeeFound(employee, otherEmployee)) {
// Found it
isFound = true;
break;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
+import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
+import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.jcontactsbusiness.exceptions.headquarter.HeadquarterAlreadyAddedException;
import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
+import org.mxchange.jcontactsbusiness.model.utils.HeadquarterUtils;
import org.mxchange.jcountry.model.data.Country;
-import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
import org.mxchange.jusercore.model.user.User;
/**
}
// Add created timestamp
- headquarter.setHeadquarterCreated(new Date());
+ headquarter.setHeadquarterEntryCreated(new Date());
+
+ // Is contact employee set?
+ if (headquarter.getHeadquarterContactEmployee() instanceof Contact) {
+ // Get managed lead contact
+ final Contact managedContact = this.createManaged(headquarter.getHeadquarterContactEmployee());
+
+ // Set it back
+ headquarter.setHeadquarterContactEmployee(managedContact);
+ }
// Is user instance set?
if (headquarter.getHeadquarterUserOwner() instanceof User) {
// Check all single addresses
for (final Headquarter hq : headquarters) {
// Is the same address found?
- if (Headquarters.isSameAddress(hq, headquarter)) {
+ if (HeadquarterUtils.isSameAddress(hq, headquarter)) {
// Found one
isFound = true;
break;
*/
package org.mxchange.jcontactsbusiness.model.headquarter;
-import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter;
import java.text.MessageFormat;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.Query;
import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
-import org.mxchange.jcontactsbusiness.model.headquarter.HeadquarterSessionBeanRemote;
/**
* A stateless session bean for general headquarter purposes
} else if (openingTime.getOpeningTimeId() instanceof Long) {
// Should not happen
throw new IllegalArgumentException("openingTime.openingId should not be set."); //NOI18N
- } else if (openingTime.getOpeningStartDay()== null) {
+ } else if (openingTime.getOpeningStartDay() == null) {
// Throw NPE
throw new NullPointerException("openingTime.openingStartDay is null"); //NOI18N
- } else if (openingTime.getOpeningStartTime()== null) {
+ } else if (openingTime.getOpeningStartTime() == null) {
// Throw NPE
throw new NullPointerException("openingTime.openingStartTime is null"); //NOI18N
- } else if (openingTime.getOpeningEndDay()== null) {
+ } else if (openingTime.getOpeningEndDay() == null) {
// Throw NPE
throw new NullPointerException("openingTime.openingEndDay is null"); //NOI18N
- } else if (openingTime.getOpeningEndTime()== null) {
+ } else if (openingTime.getOpeningEndTime() == null) {
// Throw NPE
throw new NullPointerException("openingTime.openingEndTime is null"); //NOI18N
}
import java.util.Objects;
import javax.ejb.EJB;
import javax.ejb.Stateless;
-import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
+import org.mxchange.jcountry.exceptions.CountryAlreadyAddedException;
/**
* A stateless EJB for administrative country purposes
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+ */
package org.mxchange.jcountry.model.data;
import java.text.MessageFormat;
import java.util.Date;
import javax.ejb.Stateless;
import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
+import org.mxchange.jphone.model.utils.MobileNumberUtils;
/**
* An EJB for administrative mobile number purposes
this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateMobileData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getMobileId())); //NOI18N
// Set updated timestamp
- MobileNumbers.copyMobileNumberData(mobileNumber, managedNumber);
+ MobileNumberUtils.copyMobileNumberData(mobileNumber, managedNumber);
managedNumber.setMobileEntryUpdated(new Date());
// Trace message
import javax.ejb.Stateless;
import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers;
import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
+import org.mxchange.jphone.model.utils.FaxNumberUtils;
+import org.mxchange.jphone.model.utils.LandLineNumberUtils;
/**
* An EJB for administrative phone purposes
this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateFaxData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N
// Set updated timestamp
- FaxNumbers.copyFaxNumberData(faxNumber, managedNumber);
+ FaxNumberUtils.copyFaxNumberData(faxNumber, managedNumber);
managedNumber.setPhoneEntryUpdated(new Date());
// Trace message
this.getLoggerBeanLocal().logDebug(MessageFormat.format("{0}.updateLandLineData: managedNumber.phoneId={1}", this.getClass().getSimpleName(), managedNumber.getPhoneId())); //NOI18N
// Set updated timestamp
- LandLineNumbers.copyLandLineNumberData(landLineNumber, managedNumber);
+ LandLineNumberUtils.copyLandLineNumberData(landLineNumber, managedNumber);
managedNumber.setPhoneEntryUpdated(new Date());
// Trace message
import java.util.Date;
import javax.ejb.EJB;
import javax.ejb.Stateless;
-import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
+import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
}
// Set created timestamp
- user.setUserCreated(new Date());
+ user.setUserEntryCreated(new Date());
user.getUserContact().setContactEntryCreated(new Date());
// Update mobile, land-line and fax instance
user.setUserContact(foundContact);
// Set timestamp
- user.setUserCreated(new Date());
+ user.setUserEntryCreated(new Date());
// Perist it
this.getEntityManager().persist(user);
import javax.persistence.Query;
import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
import org.mxchange.jcontacts.model.contact.Contact;
-import org.mxchange.jcontacts.model.contact.Contacts;
import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
-import org.mxchange.jphone.model.phonenumbers.fax.FaxNumbers;
import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
-import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumbers;
import org.mxchange.jphone.model.phonenumbers.mobile.DialableMobileNumber;
-import org.mxchange.jphone.model.phonenumbers.mobile.MobileNumbers;
+import org.mxchange.jphone.model.utils.FaxNumberUtils;
+import org.mxchange.jphone.model.utils.LandLineNumberUtils;
+import org.mxchange.jphone.model.utils.MobileNumberUtils;
import org.mxchange.jusercore.exceptions.UserNotFoundException;
import org.mxchange.jusercore.exceptions.UserStatusConfirmedException;
import org.mxchange.jusercore.exceptions.UserStatusLockedException;
import org.mxchange.jusercore.model.user.password_history.PasswordHistory;
import org.mxchange.jusercore.model.user.password_history.UserPasswordHistory;
import org.mxchange.jusercore.model.user.status.UserAccountStatus;
+import org.mxchange.jusercore.model.utils.UserUtils;
/**
* A user EJB
}
@Override
- public User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException {
+ public User confirmAccount (final User user, final String baseUrl) throws UserStatusConfirmedException, UserStatusLockedException, UserNotFoundException {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.confirmAccount: user={1},baseUrl={2} - CALLED!", this.getClass().getSimpleName(), user, baseUrl)); //NOI18N
// Update user status and remove confirmation key
managedUser.setUserAccountStatus(UserAccountStatus.CONFIRMED);
managedUser.setUserConfirmKey(null);
- managedUser.setUserUpdated(new Date());
+ managedUser.setUserEntryUpdated(new Date());
// Send out email
this.sendEmail("User account confirmed", "user_account_confirmed", managedUser, baseUrl, null); //NOI18N
}
@Override
- public User updateUserData (final User user) {
+ public User updateUserData (final User detachedUser) throws UserNotFoundException {
// Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
+ this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: detachedUser={1} - CALLED!", this.getClass().getSimpleName(), detachedUser)); //NOI18N
// user should not be null
- if (null == user) {
+ if (null == detachedUser) {
// Abort here
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
+ throw new NullPointerException("detachedUser is null"); //NOI18N
+ } else if (detachedUser.getUserId() == null) {
// Throw NPE again
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
+ throw new NullPointerException("detachedUser.userId is null"); //NOI18N
+ } else if (detachedUser.getUserId() < 1) {
// Not valid
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N
- } else if (user.getUserAccountStatus() == null) {
+ throw new IllegalArgumentException(MessageFormat.format("detachedUser.userId={0} is not valid.", detachedUser.getUserId())); //NOI18N
+ } else if (detachedUser.getUserAccountStatus() == null) {
// Throw NPE again
- throw new NullPointerException("user.userAccountStatus is null"); //NOI18N
- } else if (!this.ifUserExists(user)) {
+ throw new NullPointerException("detachedUser.userAccountStatus is null"); //NOI18N
+ } else if (!this.ifUserExists(detachedUser)) {
// User does not exist
- throw new EJBException(MessageFormat.format("User with id {0} does not exist.", user.getUserId())); //NOI18N
+ throw new UserNotFoundException(detachedUser.getUserId());
}
// Remove contact instance as this is not updated
- user.setUserContact(null);
+ detachedUser.setUserContact(null);
// Find the instance
- final User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId());
+ final User foundUser = this.getEntityManager().find(detachedUser.getClass(), detachedUser.getUserId());
// Should be found!
- assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
+ assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", detachedUser.getUserId()); //NOI18N
// Copy all data
- Users.copyUserData(user, foundUser);
+ UserUtils.copyUserData(detachedUser, foundUser);
// Merge user
final User managedUser = this.getEntityManager().merge(foundUser);
assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not merged, but should be.", managedUser.getUserId()); //NOI18N
// Set as updated
- managedUser.setUserUpdated(new Date());
+ managedUser.setUserEntryUpdated(new Date());
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.updateUserData: managedUser={1} - CALLED!", this.getClass().getSimpleName(), managedUser)); //NOI18N
final User managedUser = this.updateUserData(user);
// Update user account
- managedUser.setUserUpdated(new Date());
+ managedUser.setUserEntryUpdated(new Date());
// Create history entry
final PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), managedUser);
assert (managedUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N
// Copy all data
- Users.copyUserData(user, managedUser);
+ UserUtils.copyUserData(user, managedUser);
// Set as updated
- managedUser.setUserUpdated(new Date());
- managedUser.getUserContact().setContactEntryUpdated(new Date());
+ managedUser.setUserEntryUpdated(new Date());
- // Get contact from it and find it
- final Contact foundContact = this.getEntityManager().find(managedUser.getUserContact().getClass(), managedUser.getUserContact().getContactId());
-
- // Should be found
- assert (foundContact instanceof Contact) : MessageFormat.format("Contact with id {0} not found, but should be.", managedUser.getUserContact().getContactId()); //NOI18N
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("updateUserPersonalData: contact.contactId={0}", foundContact.getContactId())); //NOI18N
-
- // Merge contact instance
- final Contact managedContact = this.getEntityManager().merge(foundContact);
-
- // Copy all
- Contacts.copyContactData(managedUser.getUserContact(), managedContact);
+ // Update user data
+ final Contact managedContact = this.mergeContactData(managedUser.getUserContact());
// Set it back in user
managedUser.setUserContact(managedContact);
assert (foundMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", foundMobile.getMobileId()); //NOI18N
// Copy all
- MobileNumbers.copyMobileNumberData(managedUser.getUserContact().getContactMobileNumber(), foundMobile);
+ MobileNumberUtils.copyMobileNumberData(managedUser.getUserContact().getContactMobileNumber(), foundMobile);
// Then merge it, too
final DialableMobileNumber managedMobile = this.getEntityManager().merge(foundMobile);
// Should be there
assert (managedMobile instanceof DialableMobileNumber) : MessageFormat.format("Mobile number with id {0} not found but should be.", managedMobile.getMobileId()); //NOI18N
- // Copy all
- MobileNumbers.copyMobileNumberData(managedUser.getUserContact().getContactMobileNumber(), managedMobile);
-
// Set it back
managedContact.setContactMobileNumber(managedMobile);
}
assert (foundFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", foundFax.getPhoneId()); //NOI18N
// Copy all
- FaxNumbers.copyFaxNumberData(managedUser.getUserContact().getContactFaxNumber(), foundFax);
+ FaxNumberUtils.copyFaxNumberData(managedUser.getUserContact().getContactFaxNumber(), foundFax);
// Then merge it, too
final DialableFaxNumber managedFax = this.getEntityManager().merge(foundFax);
// Should be there
assert (managedFax instanceof DialableFaxNumber) : MessageFormat.format("Fax number with id {0} not found but should be.", managedFax.getPhoneId()); //NOI18N
- // Copy all
- FaxNumbers.copyFaxNumberData(managedUser.getUserContact().getContactFaxNumber(), managedFax);
-
// Set it back
managedContact.setContactFaxNumber(managedFax);
}
assert (foundLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", foundLandLine.getPhoneId()); //NOI18N
// Copy all
- LandLineNumbers.copyLandLineNumberData(managedUser.getUserContact().getContactLandLineNumber(), foundLandLine);
+ LandLineNumberUtils.copyLandLineNumberData(managedUser.getUserContact().getContactLandLineNumber(), foundLandLine);
// Then merge it, too
final DialableLandLineNumber managedLandLine = this.getEntityManager().merge(foundLandLine);
// Should be there
assert (managedLandLine instanceof DialableLandLineNumber) : MessageFormat.format("Land line number with id {0} not found but should be.", managedLandLine.getPhoneId()); //NOI18N
- // Copy all
- LandLineNumbers.copyLandLineNumberData(managedUser.getUserContact().getContactLandLineNumber(), managedLandLine);
-
// Set it back
managedContact.setContactLandLineNumber(managedLandLine);
}
+++ /dev/null
-/*
- * Copyright (C) 2016 - 2022 Free Software Foundation
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.juserlogincore.model.user.login;
-
-import java.text.MessageFormat;
-import javax.ejb.EJB;
-import javax.ejb.Stateless;
-import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
-import org.mxchange.jusercore.exceptions.UserNotFoundException;
-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.status.UserAccountStatus;
-import org.mxchange.juserlogincore.container.login.LoginContainer;
-import org.mxchange.juserlogincore.exceptions.UserPasswordMismatchException;
-import org.mxchange.juserlogincore.login.UserLoginUtils;
-
-/**
- * A session EJB for user logins
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@Stateless (name = "userLogin", description = "A bean handling the application-specific user login")
-public class AddressbookUserLoginSessionBean extends BaseAddressbookEnterpriseBean implements UserLoginSessionBeanRemote {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 21_785_978_127_581_965L;
-
- /**
- * User EJB
- */
- @EJB (lookup = "java:global/addressbook-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote")
- private UserSessionBeanRemote userBean;
-
- /**
- * Default constructor
- */
- public AddressbookUserLoginSessionBean () {
- // Call super constructor
- super();
- }
-
- @Override
- public User validateUserAccountStatus (final LoginContainer container) throws UserNotFoundException, UserStatusLockedException, UserStatusUnconfirmedException, UserPasswordMismatchException {
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.loginUser: container={1} - CALLED!", this.getClass().getSimpleName(), container)); //NOI18N
-
- // user should not be null
- if (null == container) {
- // Abort here
- throw new NullPointerException("container is null"); //NOI18N
- } else if (container.getUser() == null) {
- // NPE again
- throw new NullPointerException("container.user is null"); //NOI18N
- } else if (container.getUserPassword() == null) {
- // And yet again NPE
- throw new NullPointerException("container.userPassword is null"); //NOI18N
- } else if (container.getUserPassword().isEmpty()) {
- // Empty password is not allowed, hardcoded.
- throw new IllegalArgumentException("container.userPassword is empty"); //NOI18N
- }
-
- // Is the account there?
- if (!this.userBean.isUserNameRegistered(container.getUser())) {
- // Not registered
- throw new UserNotFoundException(container.getUser());
- }
-
- // Get user instance from persistance
- // @TODO Rewrite this to use JCache instead
- final User updatedUser = this.userBean.fillUserData(container.getUser());
-
- // Debug message
- this.getLoggerBeanLocal().logDebug(MessageFormat.format("loginUser: updatedUser={0}", updatedUser)); //NOI18N
-
- // Is the user account unconfirmed?
- if (updatedUser.getUserAccountStatus().equals(UserAccountStatus.UNCONFIRMED)) {
- // Is unconfirmed
- throw new UserStatusUnconfirmedException(container.getUser());
- } else if (updatedUser.getUserAccountStatus().equals(UserAccountStatus.LOCKED)) {
- // Is locked
- throw new UserStatusLockedException(container.getUser());
- } else if (!this.isPasswordMatching(container, updatedUser)) {
- // Not matcing passwords
- throw new UserPasswordMismatchException(container.getUser());
- }
-
- // Trace message
- this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.loginUser: updatedUser={1} - EXIT!", this.getClass().getSimpleName(), updatedUser)); //NOI18N
-
- // Return it
- return updatedUser;
- }
-
- /**
- * Checks if password matches of both instances. Both user instances must
- * not match, the first one is the one from the calling bean/controller, the
- * second is the from database.
- * <p>
- * @param container Container instance holding the user instance and
- * clear-text password
- * @param updatedUser Updated user instance found for given user name
- * <p>
- * @return Whether the password matches
- */
- private boolean isPasswordMatching (final LoginContainer container, final User updatedUser) {
- // First math both instances
- if (null == container) {
- // Throw NPE
- throw new NullPointerException("container is null"); //NOI18N
- } else if (null == updatedUser) {
- // Throw NPE
- throw new NullPointerException("updatedUser is null"); //NOI18N
- } else if (container.getUser().equals(updatedUser)) {
- // Both same instance!
- throw new IllegalArgumentException(MessageFormat.format("container.user matches updatedUser: {0}", container.getUser())); //NOI18N
- }
-
- // Is it the same same password?
- return UserLoginUtils.ifPasswordMatches(container, updatedUser);
- }
-
-}
package org.mxchange.juserlogincore.model.user.register;
import java.text.MessageFormat;
+import java.util.List;
import java.util.Objects;
import javax.ejb.EJB;
import javax.ejb.Stateless;
-import javax.persistence.NoResultException;
-import javax.persistence.Query;
import org.mxchange.addressbook.enterprise.BaseAddressbookEnterpriseBean;
-import org.mxchange.jcontacts.model.contact.Contact;
import org.mxchange.jusercore.exceptions.EmailAddressAlreadyRegisteredException;
import org.mxchange.jusercore.exceptions.UserNameAlreadyRegisteredException;
import org.mxchange.jusercore.model.user.AdminUserSessionBeanRemote;
-import org.mxchange.jusercore.model.user.LoginUser;
import org.mxchange.jusercore.model.user.User;
import org.mxchange.jusercore.model.user.UserSessionBeanRemote;
import org.mxchange.juserlogincore.login.UserLoginUtils;
throw new NullPointerException("user is null"); //NOI18N
}
- // Create named instance
- final Query query = this.getEntityManager().createNamedQuery("SearchUserByConfirmKey", LoginUser.class); //NOI18N
+ // Fetch whole list
+ final List<User> users = this.userBean.fetchAllUsers();
// Init confirmation key
String confirmationKey = null;
// Find a free one
while (confirmationKey == null) {
// Create new one
- final String key = UserLoginUtils.generatedConfirmationKey(user);
-
- // Set key as parameter
- query.setParameter("confirmKey", key); //NOI18N
-
- // Try it
- try {
- // Get contact instance
- final Contact contact = (Contact) query.getSingleResult();
-
- // Warning message
- this.getLoggerBeanLocal().logWarning(MessageFormat.format("{0}.generateConfirmationKey: key {1} already found: contact.contactId={2}", this.getClass().getSimpleName(), key, contact.getContactId())); //NOI18N
- } catch (final NoResultException ex) {
- // Not found, normal case
- confirmationKey = key;
- break;
+ confirmationKey = UserLoginUtils.generatedConfirmationKey(user);
+
+ // Check all entries
+ for (final User currentUser : users) {
+ // Does the key match?
+ if (Objects.equals(currentUser.getUserConfirmKey(), confirmationKey)) {
+ // Set key to null and exit loop
+ confirmationKey = null;
+ break;
+ }
}
}
// Is password set?
if ((randomPassword instanceof String) && (!randomPassword.isEmpty())) {
- // Switch to other template
+ // Switch to template with random password exposed
templateName = "user_registration_random"; //NOI18N
}