From 7f5695ec0eb13e36e6f310adfb4e0046f4e3313f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 22 Sep 2022 19:20:23 +0200 Subject: [PATCH] Please cherry-pick: - registerBean is no longer used here (old, removed code) - baseUrl should never be NULL or empty - user.userContact must be valid MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../model/user/JobsAdminUserSessionBean.java | 6 ++++++ .../jusercore/model/user/JobsUserSessionBean.java | 12 ++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/java/org/mxchange/jusercore/model/user/JobsAdminUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/JobsAdminUserSessionBean.java index 9934467..58c1ff1 100644 --- a/src/java/org/mxchange/jusercore/model/user/JobsAdminUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/JobsAdminUserSessionBean.java @@ -69,6 +69,12 @@ public class JobsAdminUserSessionBean extends BaseJobsEnterpriseBean implements } else if (user.getUserId() instanceof Long) { // Not allowed here throw new IllegalStateException(MessageFormat.format("user.userId must be null, is: {0}", user.getUserId())); //NOI18N + } else if (null == user.getUserContact()) { + // Abort here + throw new NullPointerException("user.contact is null"); //NOI18N + } else if (user.getUserContact().getContactId() != null) { + // Not allowed here + throw new IllegalStateException(MessageFormat.format("user.userContact.contactId must be null, is: {0}", user.getUserId())); //NOI18N } // Check if user is registered diff --git a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java index c673c77..b814bda 100644 --- a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java @@ -20,7 +20,6 @@ import java.text.MessageFormat; import java.util.Date; import java.util.List; import java.util.Objects; -import javax.ejb.EJB; import javax.ejb.EJBException; import javax.ejb.Stateless; import javax.persistence.Query; @@ -39,7 +38,6 @@ import org.mxchange.jusercore.exceptions.UserStatusUnconfirmedException; 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.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote; /** * A user EJB @@ -54,12 +52,6 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS */ private static final long serialVersionUID = 542_145_347_916L; - /** - * Registration EJB - */ - @EJB (lookup = "java:global/jjobs-ejb/userRegistration!org.mxchange.juserlogincore.model.user.register.UserRegistrationSessionBeanRemote") - private UserRegistrationSessionBeanRemote registerBean; - /** * Default constructor */ @@ -96,7 +88,7 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS // Throw it again throw new NullPointerException("baseUrl is null"); //NOI18N } else if (baseUrl.isEmpty()) { - // Invalid parameter + // Throw IAE throw new IllegalArgumentException("baseUrl is empty"); //NOI18N } @@ -362,7 +354,7 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS managedUser.setUserEntryUpdated(new Date()); // Create history entry - PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), managedUser); + final PasswordHistory entry = new UserPasswordHistory(user.getUserEncryptedPassword(), managedUser); // Set created timestamp entry.setUserPasswordHistoryCreated(new Date()); -- 2.39.5