From c8fb824119f1dacd685d55f8c79cddc4e6738613 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 20 Apr 2017 00:29:13 +0200 Subject: [PATCH] other projects will have more than one login, not just users (Java files) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../AddressbookWebSessionBean.java | 30 +++++++++---------- .../AddressbookContactWebSessionBean.java | 6 ++-- .../AddressbookEmailChangeWebSessionBean.java | 12 ++++---- .../AddressbookUserLoginWebSessionBean.java | 2 +- .../AddressbookUserProfileWebRequestBean.java | 4 +-- .../AddressbookSharesWebSessionBean.java | 20 ++++++------- .../user/AddressbookUserWebSessionBean.java | 12 ++++---- .../AddressbookUserPasswordValidator.java | 6 ++-- 8 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java index 0e260eaa..688f6914 100644 --- a/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/addressbook/AddressbookWebSessionBean.java @@ -108,7 +108,7 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme * Login controller */ @Inject - private AddressbookUserLoginWebSessionController loginController; + private AddressbookUserLoginWebSessionController userLoginController; /** * A list of all user's address books @@ -138,7 +138,7 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme @Override public String addAddressbook () { // Is this name already used? - if (!this.loginController.isUserLoggedIn()) { + if (!this.userLoginController.isUserLoggedIn()) { // Not logged in throw new FaceletException("This method can only be called as logged-in user."); //NOI18N } else if (this.getAddressbookName() == null) { @@ -153,7 +153,7 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme } // Create address book instance with name - Addressbook book = new UserAddressbook(this.getAddressbookName(), this.loginController.getLoggedInUser()); + Addressbook book = new UserAddressbook(this.getAddressbookName(), this.userLoginController.getLoggedInUser()); try { // Register this address book @@ -215,10 +215,10 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme } else if (event.getLoggedInUser()== null) { // user is null throw new NullPointerException("event.user is null"); //NOI18N - } else if (!event.getLoggedInUser().equals(this.loginController.getLoggedInUser())) { + } else if (!event.getLoggedInUser().equals(this.userLoginController.getLoggedInUser())) { // Not matching - throw new IllegalStateException("event.user and loginController.loggedInUser don't match."); //NOI18N - } else if (!this.loginController.isUserLoggedIn()) { + throw new IllegalStateException("event.user and userLoginController.loggedInUser don't match."); //NOI18N + } else if (!this.userLoginController.isUserLoggedIn()) { // Not logged in throw new FaceletException("This method can only be called as logged-in user."); //NOI18N } @@ -230,7 +230,7 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme @Override public List allAddressbooks () { // Is the user logged in? - if (!this.loginController.isUserLoggedIn()) { + if (!this.userLoginController.isUserLoggedIn()) { // Not logged in throw new FaceletException("This method can only be called as logged-in user."); //NOI18N } @@ -241,7 +241,7 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme @Override public List allEntries (final Addressbook addressbook) { // Is the user logged in? - if (!this.loginController.isUserLoggedIn()) { + if (!this.userLoginController.isUserLoggedIn()) { // Not logged in throw new FaceletException("This method can only be called as logged-in user."); //NOI18N } @@ -259,13 +259,13 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme @Override public List allUsersNotSharing () { // Is the user logged in? - if (!this.loginController.isUserLoggedIn()) { + if (!this.userLoginController.isUserLoggedIn()) { // Not logged in throw new FaceletException("This method can only be called as logged-in user."); //NOI18N } // Call EJB - return this.addressbookBean.allUsersNotSharing(this.loginController.getLoggedInUser(), this.getAddressbook()); + return this.addressbookBean.allUsersNotSharing(this.userLoginController.getLoggedInUser(), this.getAddressbook()); } @Override @@ -339,7 +339,7 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme @Override public boolean hasCreatedAddressbooks () { // Is the user logged in? - if (!this.loginController.isUserLoggedIn()) { + if (!this.userLoginController.isUserLoggedIn()) { // Not logged in throw new FaceletException("This method can only be called as logged-in user."); //NOI18N } @@ -357,7 +357,7 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme this.usersAddressbooks = new LinkedList<>(); // Is the user logged-in? - if (this.loginController.isUserLoggedIn()) { + if (this.userLoginController.isUserLoggedIn()) { // Initialize list this.initAddressbookList(); } @@ -411,13 +411,13 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme @Override public boolean isOwnAddressbook () { // Is the user logged in? - if (!this.loginController.isUserLoggedIn()) { + if (!this.userLoginController.isUserLoggedIn()) { // No, then no own address book throw new IllegalStateException("isOwnAddressbook() has been invoked for a guest account"); //NOI18N } // Is same user? - return Objects.equals(this.getAddressbookUser(), this.loginController.getLoggedInUser()); + return Objects.equals(this.getAddressbookUser(), this.userLoginController.getLoggedInUser()); } @Override @@ -457,7 +457,7 @@ public class AddressbookWebSessionBean extends BaseAddressbookController impleme */ private void initAddressbookList () { // Get user instance - User user = this.loginController.getLoggedInUser(); + User user = this.userLoginController.getLoggedInUser(); // Fill list with entries this.usersAddressbooks = this.addressbookBean.getUsersAddressbookList(user); diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java index fe688e7d..62b02388 100644 --- a/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/contact/AddressbookContactWebSessionBean.java @@ -561,9 +561,9 @@ public class AddressbookContactWebSessionBean extends BaseAddressbookController Contact contact = this.userLoginController.getLoggedInUser().getUserContact(); // It should be there, so run some tests on it - assert (contact instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N - assert (contact.getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N - assert (contact.getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N + assert (contact instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N + assert (contact.getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N + assert (contact.getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", contact.getContactId()); //NOI18N // Update all fields contact.setContactGender(this.getGender()); diff --git a/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java index f5b61027..0f3dbf1f 100644 --- a/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/email_address/AddressbookEmailChangeWebSessionBean.java @@ -128,12 +128,12 @@ public class AddressbookEmailChangeWebSessionBean extends BaseAddressbookControl User user = this.userLoginController.getLoggedInUser(); // It should be there, so run some tests on it - assert (user instanceof User) : "Instance loginController.loggedInUser is null"; //NOI18N - assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; //NOI18N - assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N - assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; //NOI18N - assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; //NOI18N - assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N + assert (user instanceof User) : "Instance userLoginController.loggedInUser is null"; //NOI18N + assert (user.getUserId() instanceof Long) : "Instance userLoginController.loggedInUser.userId is null"; //NOI18N + assert (user.getUserId() > 0) : MessageFormat.format("userLoginController.loggedInUser.userId={0} is invalid", user.getUserId()); //NOI18N + assert (user.getUserContact() instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; //NOI18N + assert (user.getUserContact().getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; //NOI18N + assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); //NOI18N // Check if the email address is already enqueued if (this.isEmailAddressQueued(this.getEmailAddress())) { diff --git a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java index c9a0eb77..f0ea1b4a 100644 --- a/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/login/AddressbookUserLoginWebSessionBean.java @@ -57,7 +57,7 @@ import org.mxchange.jusercore.model.user.status.UserAccountStatus; *

* @author Roland Häder */ -@Named ("loginController") +@Named ("userLoginController") @SessionScoped public class AddressbookUserLoginWebSessionBean extends BaseAddressbookController implements AddressbookUserLoginWebSessionController { diff --git a/src/java/org/mxchange/addressbook/beans/profile/AddressbookUserProfileWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/profile/AddressbookUserProfileWebRequestBean.java index deed84dd..569f63d6 100644 --- a/src/java/org/mxchange/addressbook/beans/profile/AddressbookUserProfileWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/profile/AddressbookUserProfileWebRequestBean.java @@ -46,7 +46,7 @@ public class AddressbookUserProfileWebRequestBean extends BaseAddressbookControl * Login controller */ @Inject - private AddressbookUserLoginWebSessionController loginController; + private AddressbookUserLoginWebSessionController userLoginController; /** * User controller @@ -111,7 +111,7 @@ public class AddressbookUserProfileWebRequestBean extends BaseAddressbookControl // Check all conditions (except for admin) return ((profileMode.equals(ProfileMode.PUBLIC)) || - (this.loginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS))); + (this.userLoginController.isUserLoggedIn()) && (profileMode.equals(ProfileMode.MEMBERS))); } } diff --git a/src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionBean.java index d2a9a127..8db16f94 100644 --- a/src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/shares/AddressbookSharesWebSessionBean.java @@ -67,7 +67,7 @@ public class AddressbookSharesWebSessionBean extends BaseAddressbookController i * Login controller injection */ @Inject - private AddressbookUserLoginWebSessionController loginController; + private AddressbookUserLoginWebSessionController userLoginController; /** * Share instance @@ -173,7 +173,7 @@ public class AddressbookSharesWebSessionBean extends BaseAddressbookController i @Override public List allShares () { // Is the user logged in? - if (!this.loginController.isUserLoggedIn()) { + if (!this.userLoginController.isUserLoggedIn()) { // Not logged in throw new FaceletException("This method can only be called as logged-in user."); //NOI18N } @@ -221,7 +221,7 @@ public class AddressbookSharesWebSessionBean extends BaseAddressbookController i @Override public boolean isSharingAddressbooks () { // Only to be called for logged-in users - if (!this.loginController.isUserLoggedIn()) { + if (!this.userLoginController.isUserLoggedIn()) { // Not logged in throw new FaceletException("This method can only be called as logged-in user."); //NOI18N } else if (this.isUserSharing instanceof Boolean) { @@ -230,7 +230,7 @@ public class AddressbookSharesWebSessionBean extends BaseAddressbookController i } // Call the proper bean - this.isUserSharing = this.shareBean.isUserSharingAddressbooks(this.loginController.getLoggedInUser()); + this.isUserSharing = this.shareBean.isUserSharingAddressbooks(this.userLoginController.getLoggedInUser()); // Return it return this.isUserSharing; @@ -239,7 +239,7 @@ public class AddressbookSharesWebSessionBean extends BaseAddressbookController i @Override public String startSharing (final User user, final Addressbook addressbook) { // Check conditions - if (!this.loginController.isUserLoggedIn()) { + if (!this.userLoginController.isUserLoggedIn()) { // No, then throw exception throw new FaceletException("This method can only be called as logged-in user."); //NOI18N } else if (null == user) { @@ -251,7 +251,7 @@ public class AddressbookSharesWebSessionBean extends BaseAddressbookController i } else if (user.getUserId() < 1) { // Invalid id number throw new IllegalStateException(MessageFormat.format("user.userId={0} is invalid", user.getUserId())); //NOI18N - } else if (Objects.equals(user, this.loginController.getLoggedInUser())) { + } else if (Objects.equals(user, this.userLoginController.getLoggedInUser())) { // Sharing with yourself! throw new IllegalStateException("User tries to share with himself."); //NOI18N } else if (null == addressbook) { @@ -263,12 +263,12 @@ public class AddressbookSharesWebSessionBean extends BaseAddressbookController i } else if (addressbook.getAddressbookId() < 1) { // Invalid id number throw new IllegalArgumentException(MessageFormat.format("addressbook.addressbookId={0} is invalid.", addressbook.getAddressbookId())); //NOI18N - } else if (!Objects.equals(addressbook.getAddressbookUser(), this.loginController.getLoggedInUser())) { + } else if (!Objects.equals(addressbook.getAddressbookUser(), this.userLoginController.getLoggedInUser())) { // Not the same user! - throw new IllegalStateException(MessageFormat.format("Address book id {0} owner id {1} mismatching logged-in user id {2}", addressbook.getAddressbookId(), addressbook.getAddressbookUser().getUserId(), this.loginController.getLoggedInUser().getUserId())); //NOI18N - } else if (this.loginController.getLoggedInUser().getUserProfileMode() == ProfileMode.INVISIBLE) { + throw new IllegalStateException(MessageFormat.format("Address book id {0} owner id {1} mismatching logged-in user id {2}", addressbook.getAddressbookId(), addressbook.getAddressbookUser().getUserId(), this.userLoginController.getLoggedInUser().getUserId())); //NOI18N + } else if (this.userLoginController.getLoggedInUser().getUserProfileMode() == ProfileMode.INVISIBLE) { // User is invisible - throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot start sharing address books.", this.loginController.getLoggedInUser().getUserId())); //NOI18N + throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot start sharing address books.", this.userLoginController.getLoggedInUser().getUserId())); //NOI18N } else if (user.getUserProfileMode() == ProfileMode.INVISIBLE) { // User is invisible throw new FaceletException(MessageFormat.format("user {0} is invisible and cannot be selected for sharing.", user.getUserId())); //NOI18N diff --git a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java index 26da5734..e872c23e 100644 --- a/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/AddressbookUserWebSessionBean.java @@ -504,12 +504,12 @@ public class AddressbookUserWebSessionBean extends BaseAddressbookController imp this.contactController.updateContactDataFromController(user.getUserContact()); // It should be there, so run some tests on it - assert (user instanceof User) : "Instance loginController.loggedInUser is null"; - assert (user.getUserId() instanceof Long) : "Instance loginController.loggedInUser.userId is null"; - assert (user.getUserId() > 0) : MessageFormat.format("loginController.loggedInUser.userId={0} is invalid", user.getUserId()); - assert (user.getUserContact() instanceof Contact) : "Instance loginController.loggedInUser.userContact is null"; - assert (user.getUserContact().getContactId() instanceof Long) : "Instance loginController.userContact.contactId is null"; - assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance loginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); + assert (user instanceof User) : "Instance userLoginController.loggedInUser is null"; + assert (user.getUserId() instanceof Long) : "Instance userLoginController.loggedInUser.userId is null"; + assert (user.getUserId() > 0) : MessageFormat.format("userLoginController.loggedInUser.userId={0} is invalid", user.getUserId()); + assert (user.getUserContact() instanceof Contact) : "Instance userLoginController.loggedInUser.userContact is null"; + assert (user.getUserContact().getContactId() instanceof Long) : "Instance userLoginController.userContact.contactId is null"; + assert (user.getUserContact().getContactId() > 0) : MessageFormat.format("Instance userLoginController.userContact.contactId={0} is invalid", user.getUserContact().getContactId()); // Update all fields user.setUserProfileMode(this.getUserProfileMode()); diff --git a/src/java/org/mxchange/addressbook/validator/password/AddressbookUserPasswordValidator.java b/src/java/org/mxchange/addressbook/validator/password/AddressbookUserPasswordValidator.java index 3f58d958..d339162c 100644 --- a/src/java/org/mxchange/addressbook/validator/password/AddressbookUserPasswordValidator.java +++ b/src/java/org/mxchange/addressbook/validator/password/AddressbookUserPasswordValidator.java @@ -46,7 +46,7 @@ public class AddressbookUserPasswordValidator extends BaseStringValidator implem * User login controller */ @Inject - private AddressbookUserLoginWebSessionController loginController; + private AddressbookUserLoginWebSessionController userLoginController; @Override public void validate (final FacesContext context, final UIComponent component, final Object value) throws ValidatorException { @@ -60,10 +60,10 @@ public class AddressbookUserPasswordValidator extends BaseStringValidator implem super.preValidate(context, component, value, requiredFields, false); // value is known to be an entered password, so instance login container - LoginContainer container = new UserLoginContainer(this.loginController.getLoggedInUser(), (String) value); + LoginContainer container = new UserLoginContainer(this.userLoginController.getLoggedInUser(), (String) value); // Test it here - if (!UserUtils.ifPasswordMatches(container, this.loginController.getLoggedInUser())) { + if (!UserUtils.ifPasswordMatches(container, this.userLoginController.getLoggedInUser())) { // Password mismatches throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "Password mismatching.", "The password the user has entered does not match the stored password.")); //NOI18N } -- 2.39.5