From a7d8eba3ec2a1d733b8c55cfbe41ae5baf548b21 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Wed, 22 Apr 2020 02:02:05 +0200 Subject: [PATCH] Don't cherry-pick: - JJobs has no need for addressbooks, it can be done without them - renamed backing beans for JJobs - fixed (maybe?) some JNDI names - a lot other fixes, still something is not correct, some interfaces have some missing methods while they should be there MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- lib/jaddressbook-core.jar | Bin 21951 -> 0 bytes lib/jaddressbook-lib.jar | Bin 2541 -> 0 bytes nbproject/build-impl.xml | 91 +++--- nbproject/project.properties | 4 - nbproject/project.xml | 2 - .../enterprise/BaseJobsEnterpriseBean.java | 37 --- .../JobsAddressbookSessionBean.java | 275 ------------------ .../model/user/JobsUserSessionBean.java | 4 +- .../user/login/JobsUserLoginSessionBean.java | 140 --------- 9 files changed, 45 insertions(+), 508 deletions(-) delete mode 100644 lib/jaddressbook-core.jar delete mode 100644 lib/jaddressbook-lib.jar delete mode 100644 src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java delete mode 100644 src/java/org/mxchange/juserlogincore/model/user/login/JobsUserLoginSessionBean.java diff --git a/lib/jaddressbook-core.jar b/lib/jaddressbook-core.jar deleted file mode 100644 index 6578dc4f2635534cb17646532bbb32d1bf77f588..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 21951 zcmeHPX>c6Jb$+ur23QOT5Clj9yp|Lx;UEZt6fH_TBoG8ikN`mfASsekpygr&t_bW> zy9G{ z{plA(J90&@Ls9!*_Kc3BIDc#L%@ytK*xtRVYhZ9$@21{pB7VJ{&b02fQ|WjzaYdwk z+49P8M?%Z#I2?@~v?IvF&GzNXR#k>OQ+70C54UbO#uZjCTRzl&S$pg1alRgCZ*N_} z*GOYuDjFNLBb~|A;bbbB0sW@RaAnwG^VJz0t{xSG&17n%Ex1IbDlv96b}*V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Fh4vA*kZXh1*Qlsyr9fx6`X3KTxW zr=3l2^kJY|gGaJF!CzHxPtl>3AlJ4M@douMxR}L&1H)x&W25RlFfyt%rnSuH(h7rQ zf@XJ;kDxi2jCy!cU@{ie3D(Fg3un9_Cl}%Xo&}ABeMp4XS+M+d{IZvg8}ZD*z=poQ zZ9{mfXK>fRPZ zqjaH=XY;g)$%=%QCC(7yEh&0ERjj*d_f_ps9qfcwQ}I>x+!Z4Hf@5gR8Xf{XWY@ss zjC2W3h|Pvm!w(@7oOlCQ7_;MKoTAVNBu+W-^Kw~_l^_1+4S+0vDfBAW2-g%hpQzIZQ8WR|s;FwGu_Hj5jN)a=)-^@F3r& z;=MIxMK$H8Df|{yh@@3qQz??uO5VloqT^J7Hyj+NX#;ObH(w5#?7#v{$6~bB00t$S zyc=S6TXt+SLbXLWz83JJHD6-+vf-e$e;ymFc?HVbU_oNt;E2)&m9?<<`g23~>23Kp<{cdfu13Vy+pw{7p6 zU7WV(K-U!9_JkLe_;%R)Dh#L5q3V2%PV~JyoCo|SPA)GB?}Ow{Q}@A42KR4bQ=Z`H z#OD0Y$~n!=hN3H^Ik^V4{)rIu#8$bJ-s2=rtB0Tn3UAfZ)qs}$c6Lt7`|zHiLRt>+ Xbh8~U!Pb%B+0@Zbuqgkjms9@-J}2Q5 diff --git a/lib/jaddressbook-lib.jar b/lib/jaddressbook-lib.jar deleted file mode 100644 index 7347bb6faa37497c4bed37f64828b031bb859372..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2541 zcmbtVOHUI~6h0S93)L!65b;IbK}b7PVmd7L}v`|f$pDd&enQGii^>SC)5!Wx4R z6f-+=GFQq<$43BVUzMUN`}In5P@P{>c=@VDxs=OhDm$rSwn%mLEwk+8E;B9F&{q=a z)KV-e>%xxQqRJji;2wTVFQuNuqMIh8HmfB!+8nT)T6&Xynoce|{9a9`laKg4F~4O} zMPrFg!)zHQwUK`z7L7$aW`2pwT^@zdOv9{8=WE1HG@AR$9@XnCKy|iPmDXw|v#hFN zybFNM1;Ls|jcEe7HzkV~gZo>-iT?h3_G5hnfM3PIh~$oI6?73Jy}_uy&6*)CFH{^T_a}l@`fx8j7M_{tfYyrB_&eaIy=L-$`o=O_VS1K5KeRZM0lj4WGA-dp2 zMBEVwR|!Nj`wDCE+*=X2k22M?jBcAMv)rRD%e>$j>Da0!6;#W{qsA&~U8lBVG6J9G zFKu%#^V&d641H@$LJYXG?bUU(Zw90N(!xd)zH-wEtn^yzpqgTsO!C6ZMTtW(6>e@s zx1CFa2lGs@+I43_asL9sHUYcW7TPJy6JNv~0egiai@*Z{aa9a!u7=UVT8^Ks<<|tJ zyL3ym$vo|~D_D=T(Td@i3d^b*7T`m{x3ewDlSp88+tF>c$#zvst!hlxb;EXllh_)Q zZld=k)~HHeA7ceQ@9GvYl7Ve_=6nL@mhxeP9F5Er*JHGNz2O;$@G-)r|NC{r-2eap diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml index c1872ee..362be6a 100644 --- a/nbproject/build-impl.xml +++ b/nbproject/build-impl.xml @@ -812,6 +812,9 @@ exists or setup the property manually. For example like this: + + + @@ -823,6 +826,9 @@ exists or setup the property manually. For example like this: + + + @@ -839,24 +845,21 @@ exists or setup the property manually. For example like this: - - - - - - - - + + + + + @@ -865,77 +868,68 @@ exists or setup the property manually. For example like this: - - - - - - - - + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + @@ -1326,6 +1320,7 @@ exists or setup the property manually. For example like this: + diff --git a/nbproject/project.properties b/nbproject/project.properties index ecc84d1..26c90f7 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -22,8 +22,6 @@ dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= file.reference.cdi-api.jar=lib/cdi-api.jar -file.reference.jaddressbook-core.jar=lib/jaddressbook-core.jar -file.reference.jaddressbook-lib.jar=lib/jaddressbook-lib.jar file.reference.jcontacts-business-core.jar=lib/jcontacts-business-core.jar file.reference.jcontacts-business-lib.jar=lib/jcontacts-business-lib.jar file.reference.jcontacts-core.jar=lib/jcontacts-core.jar @@ -75,8 +73,6 @@ javac.classpath=\ ${file.reference.juser-activity-core.jar}:\ ${file.reference.juser-activity-lib.jar}:\ ${file.reference.jletter-lib.jar}:\ - ${file.reference.jaddressbook-core.jar}:\ - ${file.reference.jaddressbook-lib.jar}:\ ${file.reference.jmailer-ee.jar}:\ ${reference.jjobs-core.jar}:\ ${reference.jjobs-lib.jar}:\ diff --git a/nbproject/project.xml b/nbproject/project.xml index dfb5b8b..5d8475c 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -21,8 +21,6 @@ file.reference.juser-activity-core.jar file.reference.juser-activity-lib.jar file.reference.jletter-lib.jar - file.reference.jaddressbook-core.jar - file.reference.jaddressbook-lib.jar file.reference.jmailer-ee.jar reference.jjobs-core.jar reference.jjobs-lib.jar diff --git a/src/java/org/mxchange/jjobs/enterprise/BaseJobsEnterpriseBean.java b/src/java/org/mxchange/jjobs/enterprise/BaseJobsEnterpriseBean.java index e3f6010..35cb77c 100644 --- a/src/java/org/mxchange/jjobs/enterprise/BaseJobsEnterpriseBean.java +++ b/src/java/org/mxchange/jjobs/enterprise/BaseJobsEnterpriseBean.java @@ -35,7 +35,6 @@ import org.mxchange.jcontactsbusiness.model.department.Department; import org.mxchange.jcontactsbusiness.model.employee.Employable; import org.mxchange.jcontactsbusiness.model.headquarter.Headquarter; import org.mxchange.jcontactsbusiness.model.jobposition.HireableJobPosition; -import org.mxchange.jcontactsbusiness.model.jobposition.JobPosition; import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime; import org.mxchange.jcoreee.bean.ejb.BaseEnterpriseBean; import org.mxchange.jcountry.model.data.Country; @@ -370,42 +369,6 @@ public abstract class BaseJobsEnterpriseBean extends BaseEnterpriseBean { return managedHeadquarter; } - /** - * Get back a managed instance from given job position - *

- * @param jobPosition Unmanaged/detached job position instance - *

- * @return Managed job position instance - */ - protected JobPosition createManaged (final JobPosition jobPosition) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: jobPosition={1} - CALLED!", this.getClass().getSimpleName(), jobPosition)); //NOI18N - - // user should not be null - if (null == jobPosition) { - // Abort here - throw new NullPointerException("jobPosition is null"); //NOI18N - } else if (jobPosition.getJobPositionId() == null) { - // Id is set - throw new NullPointerException("jobPosition.jobPositionId is null"); //NOI18N - } else if (jobPosition.getJobPositionId() < 1) { - // Id is set - throw new IllegalArgumentException(MessageFormat.format("jobPosition.jobPositionId={0} is invalid", jobPosition.getJobPositionId())); //NOI18N - } - - // Try to find it (should be there) - final JobPosition managedJobPosition = this.getEntityManager().find(jobPosition.getClass(), jobPosition.getJobPositionId()); - - // Should be there - assert (managedJobPosition instanceof JobPosition) : "managedJobPosition is null"; //NOI18N - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.createManaged: managedJobPosition={1} - EXIT!", this.getClass().getSimpleName(), managedJobPosition)); //NOI18N - - // Return it - return managedJobPosition; - } - /** * Get back a managed instance from given mobile provider *

diff --git a/src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java b/src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java deleted file mode 100644 index 36e3626..0000000 --- a/src/java/org/mxchange/jjobs/model/addressbook/JobsAddressbookSessionBean.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 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 . - */ -package org.mxchange.jjobs.model.addressbook; - -import java.text.MessageFormat; -import java.util.Date; -import java.util.List; -import javax.ejb.Stateless; -import javax.persistence.NoResultException; -import javax.persistence.Query; -import org.mxchange.addressbook.model.addressbook.AddressbookSessionBeanRemote; -import org.mxchange.jaddressbook.exceptions.AddressbookNameAlreadyUsedException; -import org.mxchange.jaddressbook.exceptions.AddressbookNotFoundException; -import org.mxchange.jaddressbook.model.addressbook.Addressbook; -import org.mxchange.jaddressbook.model.addressbook.UserAddressbook; -import org.mxchange.jaddressbook.model.addressbook.entry.AddressbookEntry; -import org.mxchange.jjobs.enterprise.BaseJobsEnterpriseBean; -import org.mxchange.jusercore.model.user.User; - -/** - * A stateless bean handling address books - *

- * @author Roland Häder - */ -@Stateless (name = "addressbook", description = "A stateless bean for handling JJobs addressbooks") -public class JobsAddressbookSessionBean extends BaseJobsEnterpriseBean implements AddressbookSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 129_857_871_287_691L; - - /** - * Default constructor - */ - public JobsAddressbookSessionBean () { - // Call super constructor - super(); - } - - @Override - @SuppressWarnings ("unchecked") - public List allEntries (final Addressbook addressbook) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("allEntries: addressbook={0} - CALLED!", addressbook)); //NOI18N - - // Validate parameter - if (null == addressbook) { - // Throw NPE - throw new NullPointerException("addressbook is null"); //NOI18N - } else if (addressbook.getAddressbookId() == null) { - // Throw NPE again - throw new NullPointerException("addressbook.addressbookId is null"); //NOI18N - } else if (addressbook.getAddressbookId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N - } else if (addressbook.getAddressbookUser() == null) { - // Throw again NPE - throw new NullPointerException("addressbook.addressbookUser is null"); //NOI18N - } else if (addressbook.getAddressbookUser().getUserId() == null) { - // Throw again NPE - throw new NullPointerException("addressbook.addressbookUser.userId is null"); //NOI18N - } else if (addressbook.getAddressbookUser().getUserId() < 1) { - // Invalid id number again - throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid", addressbook.getAddressbookUser().getUserId())); //NOI18N - } - - // Generate query - Query query = this.getEntityManager().createNamedQuery("SearchUsersAddressbookEntries", List.class); //NOI18N - - // Set parameters - query.setParameter("addressbook", addressbook); //NOI18N - query.setParameter("owner", addressbook.getAddressbookUser()); //NOI18N - - // Return it - return query.getResultList(); - } - - @Override - public Addressbook createAddressbook (final Addressbook addressbook) throws AddressbookNameAlreadyUsedException { - // Is it not null? - if (null == addressbook) { - // Abort here - throw new NullPointerException("addressbook is null"); //NOI18N - } else if (addressbook.getAddressbookUser() == null) { - // User instance is null - throw new NullPointerException("addressbook.user should not be null."); //NOI18N - } else if (addressbook.getAddressbookName() == null) { - // Address book name not set - throw new NullPointerException("addressbook.addressbookName should not be null"); //NOI18N - } else if (addressbook.getAddressbookName().isEmpty()) { - // Address book name not set - throw new IllegalArgumentException("addressbook.addressbookName should not be empty"); //NOI18N - } else if (this.isAddressbookNameUsed(addressbook)) { - // The assigned user already used that name - throw new AddressbookNameAlreadyUsedException(addressbook); - } - - // Add timestamp of creation - addressbook.setAddressbookCreated(new Date()); - - // Persist it now - this.getEntityManager().persist(addressbook); - - // Flush it to get all data - this.getEntityManager().flush(); - - // Return it updated - return addressbook; - } - - @Override - public Addressbook getAddressbookById (final Long addressbookId) throws AddressbookNotFoundException { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("getAddressbookById: addressbookId={0} - CALLED!", addressbookId)); //NOI18N - - // addressbookId should not be null or below 1 - if (null == addressbookId) { - // Throw NPE - throw new NullPointerException("addressbookId is null"); //NOI18N - } else if (addressbookId < 1) { - // Not valid - throw new IllegalArgumentException(MessageFormat.format("addressbookId is not valid: {0}", addressbookId)); //NOI18N - } else if (!this.isAddressbookIdUsed(addressbookId)) { - // No address book found - throw new AddressbookNotFoundException(addressbookId); - } - - // Get named query instance - Query query = this.getEntityManager().createNamedQuery("SearchAddressbookById", UserAddressbook.class); //NOI18N - - // Set parameter - query.setParameter("id", addressbookId); //NOI18N - - // Return it - return (Addressbook) query.getSingleResult(); - } - - @Override - @SuppressWarnings ("unchecked") - public List getUsersAddressbookList (final User loggedInUser) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("getUsersList: loggedInUser={0} - CALLED!", loggedInUser)); //NOI18N - - // Is the user instance null? - if (null == loggedInUser) { - // Abort here - throw new NullPointerException("loggedInUser is null"); //NOI18N - } - - // Get query instance - Query query = this.getEntityManager().createNamedQuery("AllUsersAddressbooks", List.class); //NOI18N - - // Set parameter - query.setParameter("param", loggedInUser); //NOI18N - - // Get full list from JPA - List addressbooks = query.getResultList(); - - // Return it - return addressbooks; - } - - @Override - public boolean isAddressbookIdUsed (final Long addressbookId) { - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isAddressbookIdUsed: addressbookId={0} - CALLED!", addressbookId)); //NOI18N - - // Is it null or zero? - if (null == addressbookId) { - // Throw NPE - throw new NullPointerException("addressbookId is null"); //NOI18N - } else if (addressbookId < 1) { - // Not valid id number - throw new IllegalArgumentException(MessageFormat.format("addressbookId is not valid: {0}", addressbookId)); //NOI18N - } - - // Get query instance - Query query = this.getEntityManager().createNamedQuery("SearchAddressbookById", UserAddressbook.class); //NOI18N - - // Set parameter - query.setParameter("id", addressbookId); //NOI18N - - // Default is not valid - boolean isValid = false; - - // Try it again, yes no other way - try { - // Get single result - Addressbook addressbook = (Addressbook) query.getSingleResult(); - - // Debug message - this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookIdUsed: addressbook={0} - FOUND!", addressbook)); //NOI18N - - // Found one! - isValid = true; - } catch (final NoResultException ex) { - // Debug log only, maybe out-dated link followed - this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookIdUsed: addressbookId={0} is not valid: {1}", addressbookId, ex)); //NOI18N - } - - // Trace message - this.getLoggerBeanLocal().logTrace(MessageFormat.format("isAddressbookIdUsed: isValid={0} - EXIT!", isValid)); //NOI18N - - // Return result - return isValid; - } - - @Override - public boolean isAddressbookNameUsed (final Addressbook addressbook) { - // Is it not null? - if (null == addressbook) { - // Abort here - throw new NullPointerException("addressbook is null"); //NOI18N - } else if (addressbook.getAddressbookUser() == null) { - // User instance is null - throw new NullPointerException("addressbook.addressbookUser is null."); //NOI18N - } else if (addressbook.getAddressbookUser().getUserId() == null) { - // User instance is null - throw new NullPointerException("addressbook.addressbookUser.userId is null."); //NOI18N - } else if (addressbook.getAddressbookUser().getUserId() < 1) { - // User instance is null - throw new NullPointerException(MessageFormat.format("addressbook.addressbookUser.userId={0} is invalid.", addressbook.getAddressbookUser().getUserId())); //NOI18N - } else if (addressbook.getAddressbookName() == null) { - // Address book name not set - throw new NullPointerException("addressbook.addressbookName should not be null"); //NOI18N - } else if (addressbook.getAddressbookName().isEmpty()) { - // Address book name not set - throw new IllegalArgumentException("addressbook.addressbookName should not be empty"); //NOI18N - } - - // Get query instance - Query query = this.getEntityManager().createNamedQuery("SearchUserAddressbookName", Addressbook.class); //NOI18N - - // Set parameter - query.setParameter("user", addressbook.getAddressbookUser()); //NOI18N - query.setParameter("name", addressbook.getAddressbookName()); //NOI18N - - // Default is not found - boolean isUsed = false; - - // Try it - try { - // Get a single result - Addressbook dummy = (Addressbook) query.getSingleResult(); - - // Log it - this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookNameUsed: Found an address book: {0}", dummy)); //NOI18N - - // Found one - isUsed = true; - } catch (final NoResultException ex) { - // No result found, so log it away - this.getLoggerBeanLocal().logDebug(MessageFormat.format("isAddressbookNameUsed: getSingleResult() did not return a result: {0}", ex)); //NOI18N - } - - // Return result - return isUsed; - } - -} diff --git a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java index 40ae85c..9ff0e68 100644 --- a/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java +++ b/src/java/org/mxchange/jusercore/model/user/JobsUserSessionBean.java @@ -287,10 +287,10 @@ public class JobsUserSessionBean extends BaseJobsEnterpriseBean implements UserS final User foundUser = this.getEntityManager().find(user.getClass(), user.getUserId()); // Should be found! - assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", detachedUser.getUserId()); //NOI18N + assert (foundUser instanceof User) : MessageFormat.format("User with id {0} not found, but should be.", user.getUserId()); //NOI18N // Copy all data - Users.copyUserData(detachedUser, foundUser); + Users.copyUserData(user, foundUser); // Merge user final User managedUser = this.getEntityManager().merge(foundUser); diff --git a/src/java/org/mxchange/juserlogincore/model/user/login/JobsUserLoginSessionBean.java b/src/java/org/mxchange/juserlogincore/model/user/login/JobsUserLoginSessionBean.java deleted file mode 100644 index a7f2e75..0000000 --- a/src/java/org/mxchange/juserlogincore/model/user/login/JobsUserLoginSessionBean.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (C) 2016 - 2020 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 . - */ -package org.mxchange.juserlogincore.model.user.login; - -import java.text.MessageFormat; -import javax.ejb.EJB; -import javax.ejb.Stateless; -import org.mxchange.jjobs.enterprise.BaseJobsEnterpriseBean; -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 - *

- * @author Roland Häder - */ -@Stateless (name = "userLogin", description = "A bean handling the user login for Jobs project") -public class JobsUserLoginSessionBean extends BaseJobsEnterpriseBean implements UserLoginSessionBeanRemote { - - /** - * Serial number - */ - private static final long serialVersionUID = 21_785_978_127_581_965L; - - /** - * User EJB - */ - @EJB (lookup = "java:global/jjobs-ejb/user!org.mxchange.jusercore.model.user.UserSessionBeanRemote") - private UserSessionBeanRemote userBean; - - /** - * Default constructor - */ - public JobsUserLoginSessionBean () { - // 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. - *

- * @param container Container instance holding the user instance and - * clear-text password - * @param updatedUser Updated user instance found for given user name - *

- * @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); - } - -} -- 2.39.5