From: Roland Häder Date: Wed, 12 Jul 2017 19:01:45 +0000 (+0200) Subject: created new project based on juser-core. this should separate login/registration X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=57639b1beb1058a5d757ea7a4fab9855c2f58a73;p=juser-login-core.git created new project based on juser-core. this should separate login/registration out of user-stuff, as there might be applications (such as SWING) which won't have login and registration. Signed-off-by: Roland Häder --- diff --git a/build.xml b/build.xml index 8726c4d..fe5bb01 100644 --- a/build.xml +++ b/build.xml @@ -7,8 +7,8 @@ - - Builds, tests, and runs the project juser-core. + + Builds, tests, and runs the project juser-login-core. - + @@ -468,7 +468,7 @@ is divided into following sections: - + @@ -619,7 +619,7 @@ is divided into following sections: - + @@ -911,7 +911,7 @@ is divided into following sections: - + @@ -1396,7 +1396,7 @@ is divided into following sections: - + diff --git a/nbproject/project.properties b/nbproject/project.properties index aff75ec..0a45fec 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -3,7 +3,7 @@ annotation.processing.enabled.in.editor=true annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=juser-core +application.title=juser-login-core application.vendor=Roland H\u00e4der auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml build.classes.dir=${build.dir}/classes @@ -26,12 +26,13 @@ debug.test.classpath=\ dist.archive.excludes= # This directory is removed when the project is cleaned: dist.dir=dist -dist.jar=${dist.dir}/juser-core.jar +dist.jar=${dist.dir}/juser-login-core.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= file.reference.jcontacts-core.jar=lib/jcontacts-core.jar file.reference.jcoreee.jar=lib/jcoreee.jar +file.reference.juser-core.jar=lib/juser-core.jar includes=** jar.archive.disabled=${jnlp.enabled} jar.compress=false @@ -39,6 +40,7 @@ jar.index=${jnlp.enabled} javac.classpath=\ ${file.reference.jcoreee.jar}:\ ${file.reference.jcontacts-core.jar}:\ + ${file.reference.juser-core.jar}:\ ${libs.Commons_Codec_1.10.classpath}:\ ${libs.javaee-api-7.0.classpath} # Space-separated list of extra javac options @@ -95,5 +97,6 @@ run.test.classpath=\ source.encoding=UTF-8 source.reference.jcontacts-core.jar=../jcontacts-core/src/ source.reference.jcoreee.jar=../jcoreee/src/ +source.reference.juser-core.jar=../juser-core/src/ src.dir=src test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml index 1643b78..70464d8 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -3,7 +3,7 @@ org.netbeans.modules.java.j2seproject - juser-core + juser-login-core diff --git a/src/org/mxchange/jusercore/container/login/LoginContainer.java b/src/org/mxchange/jusercore/container/login/LoginContainer.java deleted file mode 100644 index dfbc476..0000000 --- a/src/org/mxchange/jusercore/container/login/LoginContainer.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.container.login; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * A container for login data - *

- * @author Roland Häder - */ -public interface LoginContainer extends Serializable { - - /** - * Getter for user instance - *

- * @return User instance - */ - User getUser (); - - /** - * Setter for user instance - *

- * @param user User instance - */ - void setUser (final User user); - - /** - * Getter for user password - *

- * @return User password - */ - String getUserPassword (); - - /** - * Setter for user password - *

- * @param userPassword User password - */ - void setUserPassword (final String userPassword); - -} diff --git a/src/org/mxchange/jusercore/container/login/UserLoginContainer.java b/src/org/mxchange/jusercore/container/login/UserLoginContainer.java deleted file mode 100644 index 1077a15..0000000 --- a/src/org/mxchange/jusercore/container/login/UserLoginContainer.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.container.login; - -import org.mxchange.jusercore.model.user.User; - -/** - * A user login container - *

- * @author Roland Häder - */ -public class UserLoginContainer implements LoginContainer { - - /** - * Serial number - */ - private static final long serialVersionUID = 158_768_718_689_760_186L; - - /** - * User instance - */ - private User user; - - /** - * Clear-text password - */ - private String userPassword; - - /** - * Constructor with user instance and clear-text password - *

- * @param user User instance - * @param userPassword Clear-text password - */ - public UserLoginContainer (final User user, final String userPassword) { - // Is both set? - if (null == user) { - // Throw NPE - throw new NullPointerException("user is null"); //NOI18N - } else if (null == userPassword) { - // Throw NPE again - throw new NullPointerException("userPassword is null"); //NOI18N - } else if (userPassword.isEmpty()) { - // Empty password - throw new IllegalArgumentException("user password is empty."); //NOI18N - } - - // Set both - this.user = user; - this.userPassword = userPassword; - } - - @Override - public User getUser () { - return this.user; - } - - @Override - public void setUser (final User user) { - this.user = user; - } - - @Override - public String getUserPassword () { - return this.userPassword; - } - - @Override - public void setUserPassword (final String userPassword) { - this.userPassword = userPassword; - } - -} diff --git a/src/org/mxchange/jusercore/events/confirmation/ObservableUserConfirmedAccountEvent.java b/src/org/mxchange/jusercore/events/confirmation/ObservableUserConfirmedAccountEvent.java deleted file mode 100644 index d96067b..0000000 --- a/src/org/mxchange/jusercore/events/confirmation/ObservableUserConfirmedAccountEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.confirmation; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An event interface, fired if a new user has registered - *

- * @author Roland Häder - */ -public interface ObservableUserConfirmedAccountEvent extends Serializable { - - /** - * Getter for user instance - *

- * @return User instance - */ - User getConfirmedUser (); - -} diff --git a/src/org/mxchange/jusercore/events/confirmation/UserConfirmedAccountEvent.java b/src/org/mxchange/jusercore/events/confirmation/UserConfirmedAccountEvent.java deleted file mode 100644 index f1771fc..0000000 --- a/src/org/mxchange/jusercore/events/confirmation/UserConfirmedAccountEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.confirmation; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event, fired if a new confirmedUser has confirmed - *

- * @author Roland Häder - */ -public class UserConfirmedAccountEvent implements ObservableUserConfirmedAccountEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 575_412_375_267_190L; - - /** - * Newly confirmed user - */ - private final User confirmedUser; - - /** - * Constructor with newly confirmed confirmedUser - *

- * @param confirmedUser Newly confirmed confirmedUser - */ - public UserConfirmedAccountEvent (final User confirmedUser) { - // Is the confirmed user instance valid? - if (null == confirmedUser) { - // Throw NPE - throw new NullPointerException("confirmedUser is null"); //NOI18N - } else if (confirmedUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("confirmedUser.userId is null"); //NOI18N - } else if (confirmedUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("confirmedUser.userId={0} is invalid.", confirmedUser.getUserId())); //NOI18N - } - - // Set it here - this.confirmedUser = confirmedUser; - } - - @Override - public User getConfirmedUser () { - return this.confirmedUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/login/ObservableUserLoggedInEvent.java b/src/org/mxchange/jusercore/events/login/ObservableUserLoggedInEvent.java deleted file mode 100644 index ba77094..0000000 --- a/src/org/mxchange/jusercore/events/login/ObservableUserLoggedInEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.login; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events after the user has logged in - *

- * @author Roland Häder - */ -public interface ObservableUserLoggedInEvent extends Serializable { - - /** - * Getter for user instance - *

- * @return User instance - */ - User getLoggedInUser (); - -} diff --git a/src/org/mxchange/jusercore/events/login/UserLoggedInEvent.java b/src/org/mxchange/jusercore/events/login/UserLoggedInEvent.java deleted file mode 100644 index b69e302..0000000 --- a/src/org/mxchange/jusercore/events/login/UserLoggedInEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.login; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * This event is fired when the loggedInUser has logged in - *

- * @author Roland Häder - */ -public class UserLoggedInEvent implements ObservableUserLoggedInEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 163_294_958_817_560L; - - /** - * User instance - */ - private final User loggedInUser; - - /** - * Constructor with updated user instance - *

- * @param loggedInUser Updated user instance - */ - public UserLoggedInEvent (final User loggedInUser) { - // Is the logged-in user instance valid? - if (null == loggedInUser) { - // Throw NPE - throw new NullPointerException("loggedInUser is null"); //NOI18N - } else if (loggedInUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("loggedInUser.userId is null"); //NOI18N - } else if (loggedInUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("loggedInUser.userId={0} is invalid.", loggedInUser.getUserId())); //NOI18N - } - - // Set loggedInUser - this.loggedInUser = loggedInUser; - } - - @Override - public User getLoggedInUser () { - return this.loggedInUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/logout/ObservableUserLogoutEvent.java b/src/org/mxchange/jusercore/events/logout/ObservableUserLogoutEvent.java deleted file mode 100644 index 32fc8c8..0000000 --- a/src/org/mxchange/jusercore/events/logout/ObservableUserLogoutEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.logout; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events after the user has logged in - *

- * @author Roland Häder - */ -public interface ObservableUserLogoutEvent extends Serializable { - - /** - * Getter for user instance - *

- * @return User instance - */ - User getLoggedOutUser (); - -} diff --git a/src/org/mxchange/jusercore/events/logout/UserLogoutEvent.java b/src/org/mxchange/jusercore/events/logout/UserLogoutEvent.java deleted file mode 100644 index 9f80042..0000000 --- a/src/org/mxchange/jusercore/events/logout/UserLogoutEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.logout; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * This event is fired when the loggedOutUser has logged in - *

- * @author Roland Häder - */ -public class UserLogoutEvent implements ObservableUserLogoutEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 58_617_641_290_620L; - - /** - * User instance - */ - private final User loggedOutUser; - - /** - * Constructor with updated loggedOutUser instance - *

- * @param loggedOutUser Updated loggedOutUser instance - */ - public UserLogoutEvent (final User loggedOutUser) { - // Is the logged-in user instance valid? - if (null == loggedOutUser) { - // Throw NPE - throw new NullPointerException("loggedOutUser is null"); //NOI18N - } else if (loggedOutUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("loggedOutUser.userId is null"); //NOI18N - } else if (loggedOutUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("loggedOutUser.userId={0} is invalid.", loggedOutUser.getUserId())); //NOI18N - } - - // Set loggedOutUser - this.loggedOutUser = loggedOutUser; - } - - @Override - public User getLoggedOutUser () { - return this.loggedOutUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/registration/ObservableUserRegisteredEvent.java b/src/org/mxchange/jusercore/events/registration/ObservableUserRegisteredEvent.java deleted file mode 100644 index cd8af04..0000000 --- a/src/org/mxchange/jusercore/events/registration/ObservableUserRegisteredEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.registration; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An event interface, fired if a new user has registered - *

- * @author Roland Häder - */ -public interface ObservableUserRegisteredEvent extends Serializable { - - /** - * Getter for user instance - *

- * @return User instance - */ - User getRegisteredUser (); - -} diff --git a/src/org/mxchange/jusercore/events/registration/UserRegisteredEvent.java b/src/org/mxchange/jusercore/events/registration/UserRegisteredEvent.java deleted file mode 100644 index dffb067..0000000 --- a/src/org/mxchange/jusercore/events/registration/UserRegisteredEvent.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.registration; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event, fired if a new registeredUser has registered - *

- * @author Roland Häder - */ -public class UserRegisteredEvent implements ObservableUserRegisteredEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 186_956_974_127_691L; - - /** - * Newly registered registeredUser; - */ - private final User registeredUser; - - /** - * Constructor with newly registered registeredUser - *

- * @param registeredUser Newly registered registeredUser - */ - public UserRegisteredEvent (final User registeredUser) { - // Is the registered user instance valid? - if (null == registeredUser) { - // Throw NPE - throw new NullPointerException("registeredUser is null"); //NOI18N - } else if (registeredUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("registeredUser.userId is null"); //NOI18N - } else if (registeredUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("registeredUser.userId={0} is invalid.", registeredUser.getUserId())); //NOI18N - } - - // Set it here - this.registeredUser = registeredUser; - } - - /** - * Getter for registeredUser instance - *

- * @return User instance - */ - @Override - public User getRegisteredUser () { - return this.registeredUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/resendlink/ObservableUserResendLinkAccountEvent.java b/src/org/mxchange/jusercore/events/resendlink/ObservableUserResendLinkAccountEvent.java deleted file mode 100644 index 3aa8450..0000000 --- a/src/org/mxchange/jusercore/events/resendlink/ObservableUserResendLinkAccountEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.resendlink; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An event interface, fired if a user has resend confirmation link - *

- * @author Roland Häder - */ -public interface ObservableUserResendLinkAccountEvent extends Serializable { - - /** - * Getter for user instance - *

- * @return User instance - */ - User getResendLinkUser (); - -} diff --git a/src/org/mxchange/jusercore/events/resendlink/UserResendLinkAccountEvent.java b/src/org/mxchange/jusercore/events/resendlink/UserResendLinkAccountEvent.java deleted file mode 100644 index 3916936..0000000 --- a/src/org/mxchange/jusercore/events/resendlink/UserResendLinkAccountEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.resendlink; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event, fired if a user has resend confirmation link - *

- * @author Roland Häder - */ -public class UserResendLinkAccountEvent implements ObservableUserResendLinkAccountEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 575_412_375_267_190L; - - /** - * user resend confirmation link - */ - private final User resendLinkUser; - - /** - * Constructor with user resend confirmation link - *

- * @param resendLinkUser User resend confirmation link - */ - public UserResendLinkAccountEvent (final User resendLinkUser) { - // Is the confirmed user instance valid? - if (null == resendLinkUser) { - // Throw NPE - throw new NullPointerException("resendLinkUser is null"); //NOI18N - } else if (resendLinkUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("resendLinkUser.userId is null"); //NOI18N - } else if (resendLinkUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("resendLinkUser.userId={0} is invalid.", resendLinkUser.getUserId())); //NOI18N - } - - // Set it here - this.resendLinkUser = resendLinkUser; - } - - @Override - public User getResendLinkUser () { - return this.resendLinkUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/user/add/AdminAddedUserEvent.java b/src/org/mxchange/jusercore/events/user/add/AdminAddedUserEvent.java deleted file mode 100644 index 9a739c6..0000000 --- a/src/org/mxchange/jusercore/events/user/add/AdminAddedUserEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.add; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event being fired when the administrator has added a new user account - *

- * @author Roland Häder - */ -public class AdminAddedUserEvent implements ObservableAdminAddedUserEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 14_785_787_174_676_290L; - - /** - * Added user instance - */ - private final User addedUser; - - /** - * Constructor with added user instance - *

- * @param addedUser Added user instance - */ - public AdminAddedUserEvent (final User addedUser) { - // Is the user instance valid? - if (null == addedUser) { - // Throw NPE - throw new NullPointerException("addedUser is null"); //NOI18N - } else if (addedUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("addedUser.userId is null"); //NOI18N - } else if (addedUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("addedUser.userId={0} is invalid.", addedUser.getUserId())); //NOI18N - } - - // Set it here - this.addedUser = addedUser; - } - - @Override - public User getAddedUser () { - return this.addedUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/user/add/ObservableAdminAddedUserEvent.java b/src/org/mxchange/jusercore/events/user/add/ObservableAdminAddedUserEvent.java deleted file mode 100644 index c76f57d..0000000 --- a/src/org/mxchange/jusercore/events/user/add/ObservableAdminAddedUserEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.add; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events being fired when an administrator added a new user - * account. - *

- * @author Roland Häder - */ -public interface ObservableAdminAddedUserEvent extends Serializable { - - /** - * Getter for added user instance - *

- * @return Added user instance - */ - User getAddedUser (); - -} diff --git a/src/org/mxchange/jusercore/events/user/delete/AdminDeletedUserEvent.java b/src/org/mxchange/jusercore/events/user/delete/AdminDeletedUserEvent.java deleted file mode 100644 index 8001a85..0000000 --- a/src/org/mxchange/jusercore/events/user/delete/AdminDeletedUserEvent.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.delete; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event being fired when the administrator has deleted a user account - *

- * @author Roland Häder - */ -public class AdminDeletedUserEvent implements ObservableAdminDeletedUserEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 14_785_787_174_676_290L; - - /** - * Deleted user instance - */ - private final User deletedUser; - - /** - * Delete reason - */ - private final String userDeleteReason; - - /** - * Constructor with deleted user instance - *

- * @param deletedUser Deleted user instance - * @param userDeleteReason Delete reason - */ - public AdminDeletedUserEvent (final User deletedUser, final String userDeleteReason) { - // Is the user instance valid? - if (null == deletedUser) { - // Throw NPE - throw new NullPointerException("deletedUser is null"); //NOI18N - } else if (deletedUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("deletedUser.userId is null"); //NOI18N - } else if (deletedUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("deletedUser.userId={0} is invalid.", deletedUser.getUserId())); //NOI18N - } - - // Set it here - this.deletedUser = deletedUser; - this.userDeleteReason = userDeleteReason; - } - - @Override - public User getDeletedUser () { - return this.deletedUser; - } - - @Override - public String getUserDeleteReason () { - return this.userDeleteReason; - } - -} diff --git a/src/org/mxchange/jusercore/events/user/delete/ObservableAdminDeletedUserEvent.java b/src/org/mxchange/jusercore/events/user/delete/ObservableAdminDeletedUserEvent.java deleted file mode 100644 index fe98f94..0000000 --- a/src/org/mxchange/jusercore/events/user/delete/ObservableAdminDeletedUserEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.delete; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events being fired when an administrator added a new user - * account. - *

- * @author Roland Häder - */ -public interface ObservableAdminDeletedUserEvent extends Serializable { - - /** - * Getter for deleted user instance - *

- * @return Deleted user instance - */ - User getDeletedUser (); - - /** - * Getter for user delete reason - *

- * @return User delete reason - */ - String getUserDeleteReason (); - -} diff --git a/src/org/mxchange/jusercore/events/user/linked/AdminLinkedUserEvent.java b/src/org/mxchange/jusercore/events/user/linked/AdminLinkedUserEvent.java deleted file mode 100644 index b199e27..0000000 --- a/src/org/mxchange/jusercore/events/user/linked/AdminLinkedUserEvent.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.linked; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event being fired when the administrator has linked a new user account - * with existing contact data. - *

- * @author Roland Häder - */ -public class AdminLinkedUserEvent implements ObservableAdminLinkedUserEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 14_785_787_174_676_290L; - - /** - * Linked user instance - */ - private final User linkedUser; - - /** - * Constructor with linked user instance - *

- * @param linkedUser Linked user instance - */ - public AdminLinkedUserEvent (final User linkedUser) { - // Is the user instance valid? - if (null == linkedUser) { - // Throw NPE - throw new NullPointerException("linkedUser is null"); //NOI18N - } else if (linkedUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("linkedUser.userId is null"); //NOI18N - } else if (linkedUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("linkedUser.userId={0} is invalid.", linkedUser.getUserId())); //NOI18N - } - - // Set it here - this.linkedUser = linkedUser; - } - - @Override - public User getLinkedUser () { - return this.linkedUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/user/linked/ObservableAdminLinkedUserEvent.java b/src/org/mxchange/jusercore/events/user/linked/ObservableAdminLinkedUserEvent.java deleted file mode 100644 index 5ef669e..0000000 --- a/src/org/mxchange/jusercore/events/user/linked/ObservableAdminLinkedUserEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.linked; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events being fired when an administrator linked a new user - * account with existing contact data. - *

- * @author Roland Häder - */ -public interface ObservableAdminLinkedUserEvent extends Serializable { - - /** - * Getter for linked user instance - *

- * @return linked user instance - */ - User getLinkedUser (); - -} diff --git a/src/org/mxchange/jusercore/events/user/locked/AdminLockedUserEvent.java b/src/org/mxchange/jusercore/events/user/locked/AdminLockedUserEvent.java deleted file mode 100644 index 1eab489..0000000 --- a/src/org/mxchange/jusercore/events/user/locked/AdminLockedUserEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.locked; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event being fired when the administrator has locked a user account. - *

- * @author Roland Häder - */ -public class AdminLockedUserEvent implements ObservableAdminLockedUserEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 14_785_787_174_676_290L; - - /** - * Locked user instance - */ - private final User lockedUser; - - /** - * Constructor with linked user instance - *

- * @param lockedUser Locked user instance - */ - public AdminLockedUserEvent (final User lockedUser) { - // Is the user instance valid? - if (null == lockedUser) { - // Throw NPE - throw new NullPointerException("lockedUser is null"); //NOI18N - } else if (lockedUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("lockedUser.userId is null"); //NOI18N - } else if (lockedUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("lockedUser.userId={0} is invalid.", lockedUser.getUserId())); //NOI18N - } - - // Set it here - this.lockedUser = lockedUser; - } - - @Override - public User getLockedUser () { - return this.lockedUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/user/locked/ObservableAdminLockedUserEvent.java b/src/org/mxchange/jusercore/events/user/locked/ObservableAdminLockedUserEvent.java deleted file mode 100644 index 3a48a97..0000000 --- a/src/org/mxchange/jusercore/events/user/locked/ObservableAdminLockedUserEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.locked; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events being fired when an administrator locked a user - * account. - *

- * @author Roland Häder - */ -public interface ObservableAdminLockedUserEvent extends Serializable { - - /** - * Getter for locked user instance - *

- * @return locked user instance - */ - User getLockedUser (); - -} diff --git a/src/org/mxchange/jusercore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java b/src/org/mxchange/jusercore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java deleted file mode 100644 index 6ae3c4f..0000000 --- a/src/org/mxchange/jusercore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.password_change; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.password_history.PasswordHistory; - -/** - * An interface for events being fired when a user updates personal data. - *

- * @author Roland Häder - */ -public interface ObservableUpdatedUserPasswordEvent extends Serializable { - - /** - * Getter for password history entry - *

- * @return Password history entry - */ - PasswordHistory getPasswordHistory (); - -} diff --git a/src/org/mxchange/jusercore/events/user/password_change/UpdatedUserPasswordEvent.java b/src/org/mxchange/jusercore/events/user/password_change/UpdatedUserPasswordEvent.java deleted file mode 100644 index 42a5524..0000000 --- a/src/org/mxchange/jusercore/events/user/password_change/UpdatedUserPasswordEvent.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.password_change; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.password_history.PasswordHistory; - -/** - * An event being fired when the user has updated personal data - *

- * @author Roland Häder - */ -public class UpdatedUserPasswordEvent implements ObservableUpdatedUserPasswordEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 14_785_787_174_676_290L; - - /** - * Updated user instance - */ - private final PasswordHistory passwordHistory; - - /** - * Constructor with updated user instance - *

- * @param passwordHistory Updated user instance - */ - public UpdatedUserPasswordEvent (final PasswordHistory passwordHistory) { - // Is the user instance valid? - if (null == passwordHistory) { - // Throw NPE - throw new NullPointerException("passwordHistory is null"); //NOI18N - } else if (passwordHistory.getUserPasswordHistoryUser() == null) { - // Throw NPE again - throw new NullPointerException("passwordHistory.userPasswordHistoryUser is null"); //NOI18N - } else if (passwordHistory.getUserPasswordHistoryUser().getUserId() == null) { - // Throw NPE again - throw new NullPointerException("passwordHistory.userPasswordHistoryUser.userId is null"); //NOI18N - } else if (passwordHistory.getUserPasswordHistoryUser().getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("passwordHistory.userPasswordHistoryUser.userId={0} is invalid.", passwordHistory.getUserPasswordHistoryUser().getUserId())); //NOI18N - } - - // Set it here - this.passwordHistory = passwordHistory; - } - - @Override - public PasswordHistory getPasswordHistory () { - return this.passwordHistory; - } - -} diff --git a/src/org/mxchange/jusercore/events/user/unlocked/AdminUnlockedUserEvent.java b/src/org/mxchange/jusercore/events/user/unlocked/AdminUnlockedUserEvent.java deleted file mode 100644 index 09b7da3..0000000 --- a/src/org/mxchange/jusercore/events/user/unlocked/AdminUnlockedUserEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.unlocked; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event being fired when the administrator has unlocked a user account. - *

- * @author Roland Häder - */ -public class AdminUnlockedUserEvent implements ObservableAdminUnlockedUserEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 14_785_787_174_676_290L; - - /** - * Unlocked user instance - */ - private final User unlockedUser; - - /** - * Constructor with linked user instance - *

- * @param unlockedUser Unlocked user instance - */ - public AdminUnlockedUserEvent (final User unlockedUser) { - // Is the user instance valid? - if (null == unlockedUser) { - // Throw NPE - throw new NullPointerException("unlockedUser is null"); //NOI18N - } else if (unlockedUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("unlockedUser.userId is null"); //NOI18N - } else if (unlockedUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("unlockedUser.userId={0} is invalid.", unlockedUser.getUserId())); //NOI18N - } - - // Set it here - this.unlockedUser = unlockedUser; - } - - @Override - public User getUnlockedUser () { - return this.unlockedUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/user/unlocked/ObservableAdminUnlockedUserEvent.java b/src/org/mxchange/jusercore/events/user/unlocked/ObservableAdminUnlockedUserEvent.java deleted file mode 100644 index 35f2e45..0000000 --- a/src/org/mxchange/jusercore/events/user/unlocked/ObservableAdminUnlockedUserEvent.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.unlocked; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events being fired when an administrator unlocked a user - * account. - *

- * @author Roland Häder - */ -public interface ObservableAdminUnlockedUserEvent extends Serializable { - - /** - * Getter for unlocked user instance - *

- * @return Unlocked user instance - */ - User getUnlockedUser (); - -} diff --git a/src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java b/src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java deleted file mode 100644 index a60b0a6..0000000 --- a/src/org/mxchange/jusercore/events/user/update/AdminUpdatedUserDataEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.update; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event being fired when the administrator has updated user data - *

- * @author Roland Häder - */ -public class AdminUpdatedUserDataEvent implements ObservableAdminUpdatedUserDataEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 14_785_787_174_676_290L; - - /** - * Updated user instance - */ - private final User updatedUser; - - /** - * Constructor with updated user instance - *

- * @param updatedUser Updated user instance - */ - public AdminUpdatedUserDataEvent (final User updatedUser) { - // Is the user instance valid? - if (null == updatedUser) { - // Throw NPE - throw new NullPointerException("updatedUser is null"); //NOI18N - } else if (updatedUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("updatedUser.userId is null"); //NOI18N - } else if (updatedUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("updatedUser.userId={0} is invalid.", updatedUser.getUserId())); //NOI18N - } - - // Set it here - this.updatedUser = updatedUser; - } - - @Override - public User getUpdatedUser () { - return this.updatedUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/user/update/ObservableAdminUpdatedUserDataEvent.java b/src/org/mxchange/jusercore/events/user/update/ObservableAdminUpdatedUserDataEvent.java deleted file mode 100644 index 3218e17..0000000 --- a/src/org/mxchange/jusercore/events/user/update/ObservableAdminUpdatedUserDataEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.update; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events being fired when an administrator updated user data. - *

- * @author Roland Häder - */ -public interface ObservableAdminUpdatedUserDataEvent extends Serializable { - - /** - * Getter for updated user instance - *

- * @return Added user instance - */ - User getUpdatedUser (); - -} diff --git a/src/org/mxchange/jusercore/events/user/update/ObservableUpdatedUserPersonalDataEvent.java b/src/org/mxchange/jusercore/events/user/update/ObservableUpdatedUserPersonalDataEvent.java deleted file mode 100644 index a104611..0000000 --- a/src/org/mxchange/jusercore/events/user/update/ObservableUpdatedUserPersonalDataEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.update; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events being fired when a user updates personal data. - *

- * @author Roland Häder - */ -public interface ObservableUpdatedUserPersonalDataEvent extends Serializable { - - /** - * Getter for updated user instance - *

- * @return Added user instance - */ - User getUpdatedUser (); - -} diff --git a/src/org/mxchange/jusercore/events/user/update/UpdatedUserPersonalDataEvent.java b/src/org/mxchange/jusercore/events/user/update/UpdatedUserPersonalDataEvent.java deleted file mode 100644 index 4c85964..0000000 --- a/src/org/mxchange/jusercore/events/user/update/UpdatedUserPersonalDataEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.update; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event being fired when the user has updated personal data - *

- * @author Roland Häder - */ -public class UpdatedUserPersonalDataEvent implements ObservableUpdatedUserPersonalDataEvent { - - /** - * Serial number - */ - private static final long serialVersionUID = 14_785_787_174_676_290L; - - /** - * Updated user instance - */ - private final User updatedUser; - - /** - * Constructor with updated user instance - *

- * @param updatedUser Updated user instance - */ - public UpdatedUserPersonalDataEvent (final User updatedUser) { - // Is the user instance valid? - if (null == updatedUser) { - // Throw NPE - throw new NullPointerException("updatedUser is null"); //NOI18N - } else if (updatedUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("updatedUser.userId is null"); //NOI18N - } else if (updatedUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("updatedUser.userId={0} is invalid.", updatedUser.getUserId())); //NOI18N - } - - // Set it here - this.updatedUser = updatedUser; - } - - @Override - public User getUpdatedUser () { - return this.updatedUser; - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/DataRepeatMismatchException.java b/src/org/mxchange/jusercore/exceptions/DataRepeatMismatchException.java deleted file mode 100644 index f86aadd..0000000 --- a/src/org/mxchange/jusercore/exceptions/DataRepeatMismatchException.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -/** - * An exception thrown when the user has not entered same email addresses - *

- * @author Roland Häder - */ -public class DataRepeatMismatchException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 12_857_813_986_248_156L; - - /** - * Constructor with message - *

- * @param message Message to show - */ - public DataRepeatMismatchException (final String message) { - super(message); - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/EmailAddressAlreadyRegisteredException.java b/src/org/mxchange/jusercore/exceptions/EmailAddressAlreadyRegisteredException.java deleted file mode 100644 index 65c4ccd..0000000 --- a/src/org/mxchange/jusercore/exceptions/EmailAddressAlreadyRegisteredException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An exception thrown when the user's email address is already registered. - *

- * @author Roland Häder - */ -public class EmailAddressAlreadyRegisteredException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 16_435_892_878_271L; - - /** - * Constructor with already registered user instance - *

- * @param user User instance - */ - public EmailAddressAlreadyRegisteredException (final User user) { - // Call super contructor - super(MessageFormat.format("Email address {0} already registered.", user.getUserContact().getContactEmailAddress())); //NOI18N - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/UserEmailAddressNotFoundException.java b/src/org/mxchange/jusercore/exceptions/UserEmailAddressNotFoundException.java deleted file mode 100644 index 9e1c12e..0000000 --- a/src/org/mxchange/jusercore/exceptions/UserEmailAddressNotFoundException.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; - -/** - * An exception thrown when an user email address was not found. - *

- * @author Roland Häder - */ -public class UserEmailAddressNotFoundException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 50_375_271_856_714_906L; - - /** - * Constructor with email address - *

- * @param emailAddress Email address - */ - public UserEmailAddressNotFoundException (final String emailAddress) { - super(MessageFormat.format("User email address {0} not found.", emailAddress)); //NOI18N - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/UserNameAlreadyRegisteredException.java b/src/org/mxchange/jusercore/exceptions/UserNameAlreadyRegisteredException.java deleted file mode 100644 index d8767a9..0000000 --- a/src/org/mxchange/jusercore/exceptions/UserNameAlreadyRegisteredException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An exception thrown when the user name is already registered - *

- * @author Roland Häder - */ -public class UserNameAlreadyRegisteredException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 16_435_892_878_271L; - - /** - * Constructor with already registered user instance - *

- * @param user User instance - */ - public UserNameAlreadyRegisteredException (final User user) { - // Call super contructor - super(MessageFormat.format("User name {0} already registered at record id {1}. Maybe forgot to call isRegistered(user) ?", user.getUserName(), user.getUserId())); - } - - /** - * Constructor with already registered user name - *

- * @param userName User name - */ - public UserNameAlreadyRegisteredException (final String userName) { - // Call super contructor - super(MessageFormat.format("User name {0} already used. Maybe forgot to call isRegistered(user) ?", userName)); - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/UserNotFoundException.java b/src/org/mxchange/jusercore/exceptions/UserNotFoundException.java deleted file mode 100644 index 2cf5c15..0000000 --- a/src/org/mxchange/jusercore/exceptions/UserNotFoundException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An exception thrown when the user's account was not found - *

- * @author Roland Häder - */ -public class UserNotFoundException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 42_895_928_956_718_956L; - - /** - * Constructor with already registered user instance - *

- * @param user User instance - */ - public UserNotFoundException (final User user) { - // Call super contructor - super(MessageFormat.format("User name {0} not found.", user.getUserName())); //NOI18N - } - - /** - * Constructor with user id - *

- * @param userId User id - */ - public UserNotFoundException (final Long userId) { - super(MessageFormat.format("User id {0} not found.", userId)); //NOI18N - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/UserPasswordMismatchException.java b/src/org/mxchange/jusercore/exceptions/UserPasswordMismatchException.java deleted file mode 100644 index 58f7a94..0000000 --- a/src/org/mxchange/jusercore/exceptions/UserPasswordMismatchException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An exception thrown when the entered password did not match the stored - * password. - *

- * @author Roland Häder - */ -public class UserPasswordMismatchException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 97_283_567_871_569_401L; - - /** - * Creates an exception with given user instance - *

- * @param user User instance - */ - public UserPasswordMismatchException (final User user) { - super(MessageFormat.format("Password for user {0} does not match stored password.", user)); - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/UserPasswordRepeatMismatchException.java b/src/org/mxchange/jusercore/exceptions/UserPasswordRepeatMismatchException.java deleted file mode 100644 index 41f5bb0..0000000 --- a/src/org/mxchange/jusercore/exceptions/UserPasswordRepeatMismatchException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An exception thrown when the entered password did not match the stored - * password. - *

- * @author Roland Häder - */ -public class UserPasswordRepeatMismatchException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 51_782_450_671_256_594L; - - /** - * Creates an exception with given user instance - *

- * @param user User instance - */ - public UserPasswordRepeatMismatchException (final User user) { - super(MessageFormat.format("Passwords don't match, userId={0}", user.getUserId())); - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/UserStatusConfirmedException.java b/src/org/mxchange/jusercore/exceptions/UserStatusConfirmedException.java deleted file mode 100644 index 8d60a59..0000000 --- a/src/org/mxchange/jusercore/exceptions/UserStatusConfirmedException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An exception thrown when the user account is unconfirmed - *

- * @author Roland Häder - */ -public class UserStatusConfirmedException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 541_378_578_296_710L; - - /** - * Constructor with already registered user instance - *

- * @param user User instance - */ - public UserStatusConfirmedException (final User user) { - // Call super contructor - super(MessageFormat.format("User account with user name {0} is confirmed.", user.getUserName())); - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/UserStatusLockedException.java b/src/org/mxchange/jusercore/exceptions/UserStatusLockedException.java deleted file mode 100644 index 62c80e2..0000000 --- a/src/org/mxchange/jusercore/exceptions/UserStatusLockedException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An exception thrown when the user account is locked - *

- * @author Roland Häder - */ -public class UserStatusLockedException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 438_395_891_288_681L; - - /** - * Constructor with already registered user instance - *

- * @param user User instance - */ - public UserStatusLockedException (final User user) { - // Call super contructor - super(MessageFormat.format("User account with user name {0} is locked.", user.getUserName())); - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/UserStatusUnconfirmedException.java b/src/org/mxchange/jusercore/exceptions/UserStatusUnconfirmedException.java deleted file mode 100644 index 31c9f40..0000000 --- a/src/org/mxchange/jusercore/exceptions/UserStatusUnconfirmedException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An exception thrown when the user account is unconfirmed - *

- * @author Roland Häder - */ -public class UserStatusUnconfirmedException extends Exception { - - /** - * Serial number - */ - private static final long serialVersionUID = 438_395_891_288_681L; - - /** - * Constructor with already registered user instance - *

- * @param user User instance - */ - public UserStatusUnconfirmedException (final User user) { - // Call super contructor - super(MessageFormat.format("User account with user name {0} is unconfirmed.", user.getUserName())); - } - -} diff --git a/src/org/mxchange/jusercore/model/email_address/ChangeableEmailAddress.java b/src/org/mxchange/jusercore/model/email_address/ChangeableEmailAddress.java deleted file mode 100644 index c0beccb..0000000 --- a/src/org/mxchange/jusercore/model/email_address/ChangeableEmailAddress.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.model.email_address; - -import java.io.Serializable; -import java.util.Calendar; -import org.mxchange.jusercore.model.email_address.status.EmailChangeStatus; -import org.mxchange.jusercore.model.user.User; - -/** - * A POJI for email address changes. This is required to have the user confirm - * the change (avoids abuse a bit). - *

- * @author Roland Häder - */ -public interface ChangeableEmailAddress extends Serializable { - - /** - * Getter for email change id - *

- * @return Email change id - */ - Long getEmailChangeId (); - - /** - * Setter for email change id - *

- * @param emailChangeId Email change id - */ - void setEmailChangeId (final Long emailChangeId); - - /** - * Getter for email address to change to - *

- * @return Email address to change to - */ - String getEmailAddress (); - - /** - * Setter for email address to change to - *

- * @param emailAddress Email address to change to - */ - void setEmailAddress (final String emailAddress); - - /** - * Getter for created "email change" timestamp - *

- * @return Created "email change" timestamp - */ - Calendar getEmailChangeCreated (); - - /** - * Setter for created "email change" timestamp - *

- * @param emailChangeCreated Created "email change" timestamp - */ - void setEmailChangeCreated (final Calendar emailChangeCreated); - - /** - * Getter for user initiating the email change - *

- * @return User initiating the email change - */ - User getEmailChangeUser (); - - /** - * Setter for user initiating the email change - *

- * @param emailChangeUser User initiating the email change - */ - void setEmailChangeUser (final User emailChangeUser); - - /** - * Getter for email change done/undone - *

- * @return Email change done/undone - */ - Calendar getEmailChangeDone (); - - /** - * Setter for email change done/undone - *

- * @param emailChangeDone Email change done/undone - */ - void setEmailChangeDone (final Calendar emailChangeDone); - - /** - * Getter for email change status - *

- * @return Email change status - */ - EmailChangeStatus getEmailChangeStatus (); - - /** - * Setter for email change status - *

- * @param emailChangeStatus Email change status - */ - void setEmailChangeStatus (final EmailChangeStatus emailChangeStatus); - - /** - * Getter for email change hash - *

- * @return Email change hash - */ - String getEmailChangeHash (); - - /** - * Getter for email change hash - *

- * @param emailChangeHash Email change hash - */ - void setEmailChangeHash (final String emailChangeHash); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); -} diff --git a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java b/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java deleted file mode 100644 index bbfd485..0000000 --- a/src/org/mxchange/jusercore/model/email_address/EmailAddressChange.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.model.email_address; - -import java.util.Calendar; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.mxchange.jusercore.model.email_address.status.EmailChangeStatus; -import org.mxchange.jusercore.model.user.LoginUser; -import org.mxchange.jusercore.model.user.User; - -/** - * A POJO for changing email addresses. - *

- * @author Roland Häder - */ -@Entity (name = "email_changes") -@Table (name = "email_changes") -@NamedQueries ( - value = { - @NamedQuery (name = "SearchEmailChangeByEmail", query = "SELECT e FROM email_changes AS e WHERE LOWER(e.emailAddress) LIKE LOWER(:email)"), - @NamedQuery (name = "AllEmailAddressChanges", query = "SELECT e.emailAddress FROM email_changes AS e ORDER BY e.emailChangeId ASC"), - @NamedQuery (name = "SearchEmailChangeByHash", query = "SELECT e FROM email_changes AS e WHERE e.emailChangeHash = :hash") - } -) -@SuppressWarnings ("PersistenceUnitPresent") -public class EmailAddressChange implements ChangeableEmailAddress { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 398_459_287_176_139L; - - /** - * Email address to change to - */ - @Basic (optional = false) - @Column (name = "email_address", length = 100, nullable = false, updatable = false) - private String emailAddress; - - /** - * Timestamp when this change has been added - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "email_change_created", nullable = false, updatable = false) - private Calendar emailChangeCreated; - - /** - * Timestamp when this change has been done or undone - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "email_change_done", nullable = false, updatable = false) - private Calendar emailChangeDone; - - /** - * Email change hash the user has to click - */ - @Basic (optional = false) - @Column (name = "email_change_hash", unique = true) - private String emailChangeHash; - - /** - * Email change id - */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "email_change_id", nullable = false, updatable = false) - private Long emailChangeId; - - /** - * Email change status - */ - @Basic (optional = false) - @Column (name = "email_change_status", nullable = false, updatable = false) - @Enumerated (EnumType.STRING) - private EmailChangeStatus emailChangeStatus; - - /** - * User initiating the email change - */ - @JoinColumn (name = "email_change_user_id", nullable = false, updatable = false) - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false) - private User emailChangeUser; - - /** - * Default constructor - */ - public EmailAddressChange () { - // Set default email change status - this.emailChangeStatus = EmailChangeStatus.NEW; - } - - /** - * Constructor with all fields to set - *

- * @param emailChangeId Email change id - * @param user User instance - * @param emailAddress Email address - * @param emailChangeCreated Timestamp for creation - * @param emailChangeStatus Email change status - * @param emailChangeDone When this entry has been done - * @param emailChangeHash Email change hash - */ - public EmailAddressChange (final Long emailChangeId, final User user, final String emailAddress, final Calendar emailChangeCreated, final EmailChangeStatus emailChangeStatus, final Calendar emailChangeDone, final String emailChangeHash) { - // Call other constructor - this(user, emailAddress); - - // Set remaining - this.emailChangeId = emailChangeId; - this.emailChangeCreated = emailChangeCreated; - this.emailChangeStatus = emailChangeStatus; - this.emailChangeDone = emailChangeDone; - this.emailChangeHash = emailChangeHash; - } - - /** - * Constructor with user and email address - *

- * @param user User instance - * @param emailAddress Email address - */ - public EmailAddressChange (final User user, final String emailAddress) { - // Call other constructor - this(); - - // Set all - this.emailChangeUser = user; - this.emailAddress = emailAddress; - } - - @Override - public boolean equals (final Object object) { - if (this == object) { - return true; - } else if (null == object) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - final ChangeableEmailAddress otherEmail = (ChangeableEmailAddress) object; - - if (!Objects.equals(this.getEmailChangeId(), otherEmail.getEmailChangeId())) { - return false; - } else if (!Objects.equals(this.getEmailAddress(), otherEmail.getEmailAddress())) { - return false; - } else if (!Objects.equals(this.getEmailChangeUser(), otherEmail.getEmailChangeUser())) { - return false; - } - - return true; - } - - @Override - public String getEmailAddress () { - return this.emailAddress; - } - - @Override - public void setEmailAddress (final String emailAddress) { - this.emailAddress = emailAddress; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getEmailChangeCreated () { - return this.emailChangeCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setEmailChangeCreated (final Calendar emailChangeCreated) { - this.emailChangeCreated = emailChangeCreated; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getEmailChangeDone () { - return this.emailChangeDone; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setEmailChangeDone (final Calendar emailChangeDone) { - this.emailChangeDone = emailChangeDone; - } - - @Override - public String getEmailChangeHash () { - return this.emailChangeHash; - } - - @Override - public void setEmailChangeHash (final String emailChangeHash) { - this.emailChangeHash = emailChangeHash; - } - - @Override - public Long getEmailChangeId () { - return this.emailChangeId; - } - - @Override - public void setEmailChangeId (final Long emailChangeId) { - this.emailChangeId = emailChangeId; - } - - @Override - public EmailChangeStatus getEmailChangeStatus () { - return this.emailChangeStatus; - } - - @Override - public void setEmailChangeStatus (final EmailChangeStatus emailChangeStatus) { - this.emailChangeStatus = emailChangeStatus; - } - - @Override - public User getEmailChangeUser () { - return this.emailChangeUser; - } - - @Override - public void setEmailChangeUser (final User emailChangeUser) { - this.emailChangeUser = emailChangeUser; - } - - @Override - public int hashCode () { - int hash = 5; - - hash = 71 * hash + Objects.hashCode(this.getEmailChangeId()); - hash = 71 * hash + Objects.hashCode(this.getEmailAddress()); - hash = 71 * hash + Objects.hashCode(this.getEmailChangeUser()); - - return hash; - } - -} diff --git a/src/org/mxchange/jusercore/model/email_address/status/EmailChangeStatus.java b/src/org/mxchange/jusercore/model/email_address/status/EmailChangeStatus.java deleted file mode 100644 index 49afb45..0000000 --- a/src/org/mxchange/jusercore/model/email_address/status/EmailChangeStatus.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.model.email_address.status; - -import java.io.Serializable; - -/** - * An enumeration for email changing - *

- * @author Roland Häder - */ -public enum EmailChangeStatus implements Serializable { - - /** - * Newly added email address (default) - */ - NEW("EMAIL_CHANGE_STATUS_NEW"), //NOI18N - - /** - * User changed to this address - */ - CHANGED("EMAIL_CHANGE_STATUS_CHANGED"), //NOI18N - - /** - * Has withdrawn the action - */ - WITHDRAWN("EMAIL_CHANGE_STATUS_WITHDRAWN"), //NOI18N - - /** - * User has "deleted" the entry. This is not done to keep a history of email changes. - */ - DELETED("EMAIL_CHANGE_STATUS_DELETED"); //NOI18N - - /** - * Message key - */ - private final String messageKey; - - /** - * Constructor with i18n translation key - *

- * @param messageKey Message key (i18n) - */ - private EmailChangeStatus (final String messageKey) { - // Set it here - this.messageKey = messageKey; - } - - /** - * Output value (for messages) - *

- * @return the messageKey - */ - public String getMessageKey () { - return this.messageKey; - } - -} diff --git a/src/org/mxchange/jusercore/model/user/LoginUser.java b/src/org/mxchange/jusercore/model/user/LoginUser.java deleted file mode 100644 index e400dc4..0000000 --- a/src/org/mxchange/jusercore/model/user/LoginUser.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.model.user; - -import java.util.Calendar; -import java.util.Locale; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.Lob; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jcontacts.contact.UserContact; -import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; -import org.mxchange.jusercore.model.user.status.UserAccountStatus; - -/** - * A generic user entity class - *

- * @author Roland Häder - */ -@Entity (name = "users") -@Table ( - name = "users" -) -@NamedQueries ( - { - @NamedQuery (name = "AllUserNames", query = "SELECT DISTINCT u.userName FROM users AS u ORDER BY u.userId ASC"), - @NamedQuery (name = "AllEmailAddresses", query = "SELECT DISTINCT c.contactEmailAddress FROM contacts AS c INNER JOIN users AS u ON u.userContact = c ORDER BY c.contactId ASC"), - @NamedQuery (name = "SearchUserByName", query = "SELECT u FROM users AS u WHERE LOWER(u.userName) LIKE LOWER(:userName)"), - @NamedQuery (name = "SearchUserById", query = "SELECT u FROM users AS u WHERE u.userId = :id"), - @NamedQuery (name = "SearchUserByEmailAddress", query = "SELECT u FROM users AS u INNER JOIN contacts AS c ON u.userContact = c WHERE LOWER(c.contactEmailAddress) LIKE LOWER(:emailAddress)"), - @NamedQuery (name = "SearchUserByConfirmKey", query = "SELECT u FROM users AS u WHERE u.userConfirmKey = :confirmKey"), - @NamedQuery (name = "SearchAllUsersExcept", query = "SELECT u FROM users AS u WHERE u != :user ORDER BY u.userId ASC"), - @NamedQuery (name = "AllUsers", query = "SELECT u FROM users AS u ORDER BY u.userId ASC"), - @NamedQuery (name = "AllPublicUsers", query = "SELECT u FROM users AS u WHERE u.userAccountStatus = :status AND u.userProfileMode = :mode ORDER BY u.userId ASC"), - @NamedQuery (name = "AllMemberPublicUsers", query = "SELECT u FROM users AS u WHERE u.userAccountStatus = :status AND u.userProfileMode IN (:public, :members) ORDER BY u.userId ASC") - } -) -@SuppressWarnings ("PersistenceUnitPresent") -public class LoginUser implements User { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 4_328_454_581_751L; - - /** - * Account status - */ - @Basic (optional = false) - @Column (name = "user_account_status", nullable = false) - @Enumerated (value = EnumType.STRING) - private UserAccountStatus userAccountStatus; - - /** - * Confirmation key - */ - @Column (name = "user_confirm_key", unique = true) - private String userConfirmKey; - - /** - * Id number from "contacts" table - */ - @JoinColumn (name = "user_contact_id", referencedColumnName = "contact_id", nullable = false, updatable = false, unique = true) - @OneToOne (targetEntity = UserContact.class, cascade = CascadeType.ALL, optional = false) - private Contact userContact; - - /** - * "created" timestamp - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "user_created", nullable = false, updatable = false) - private Calendar userCreated; - - /** - * Encrypted password - */ - @Basic (optional = false) - @Column (name = "user_encrypted_password", nullable = false) - private String userEncryptedPassword; - - /** - * User id - */ - @Id - @Column (name = "user_id", nullable = false, updatable = false) - @GeneratedValue (strategy = GenerationType.IDENTITY) - private Long userId; - - /** - * Last "locked" timestamp - */ - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "user_last_locked_timestamp") - private Calendar userLastLocked; - - /** - * Last locked reason - */ - @Lob - @Column (name = "user_last_locked_reason") - private String userLastLockedReason; - - /** - * User locale - */ - @Column (name = "user_locale") - private Locale userLocale; - - /** - * Whether the user must change password after login - */ - @Column (name = "user_must_change_password") - private Boolean userMustChangePassword; - - /** - * User name - */ - @Basic (optional = false) - @Column (name = "user_name", nullable = false, length = 30, unique = true) - private String userName; - - /** - * Profile mode of this user - */ - @Basic (optional = false) - @Enumerated (EnumType.STRING) - @Column (name = "user_profile_mode", nullable = false) - private ProfileMode userProfileMode; - - /** - * When this user has been updated - */ - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "user_updated", insertable = false) - private Calendar userUpdated; - - /** - * Default constructor - */ - public LoginUser () { - // Default is invisible - this.userProfileMode = ProfileMode.INVISIBLE; - } - - @Override - public boolean equals (final Object object) { - if (null == object) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - final User other = (User) object; - - if (!Objects.equals(this.getUserName(), other.getUserName())) { - return false; - } else if (!Objects.equals(this.getUserId(), other.getUserId())) { - return false; - } - - return true; - } - - @Override - public UserAccountStatus getUserAccountStatus () { - return this.userAccountStatus; - } - - @Override - public void setUserAccountStatus (final UserAccountStatus userAccountStatus) { - this.userAccountStatus = userAccountStatus; - } - - @Override - public String getUserConfirmKey () { - return this.userConfirmKey; - } - - @Override - public void setUserConfirmKey (final String userConfirmKey) { - this.userConfirmKey = userConfirmKey; - } - - @Override - public Contact getUserContact () { - return this.userContact; - } - - @Override - public void setUserContact (final Contact userContact) { - this.userContact = userContact; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getUserCreated () { - return this.userCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setUserCreated (final Calendar userCreated) { - this.userCreated = userCreated; - } - - @Override - public String getUserEncryptedPassword () { - return this.userEncryptedPassword; - } - - @Override - public void setUserEncryptedPassword (final String userEncryptedPassword) { - this.userEncryptedPassword = userEncryptedPassword; - } - - @Override - public Long getUserId () { - return this.userId; - } - - @Override - public void setUserId (final Long userId) { - this.userId = userId; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getUserLastLocked () { - return this.userLastLocked; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setUserLastLocked (final Calendar userLastLocked) { - this.userLastLocked = userLastLocked; - } - - @Override - public String getUserLastLockedReason () { - return this.userLastLockedReason; - } - - @Override - public void setUserLastLockedReason (final String userLastLockedReason) { - this.userLastLockedReason = userLastLockedReason; - } - - @Override - public Locale getUserLocale () { - return this.userLocale; - } - - @Override - public void setUserLocale (final Locale userLocale) { - this.userLocale = userLocale; - } - - @Override - public Boolean getUserMustChangePassword () { - return this.userMustChangePassword; - } - - @Override - public void setUserMustChangePassword (final Boolean userMustChangePassword) { - this.userMustChangePassword = userMustChangePassword; - } - - @Override - public String getUserName () { - return this.userName; - } - - @Override - public void setUserName (final String userName) { - this.userName = userName; - } - - @Override - public ProfileMode getUserProfileMode () { - return this.userProfileMode; - } - - @Override - public void setUserProfileMode (final ProfileMode userProfileMode) { - this.userProfileMode = userProfileMode; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getUserUpdated () { - return this.userUpdated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setUserUpdated (final Calendar userUpdated) { - this.userUpdated = userUpdated; - } - - @Override - public int hashCode () { - int hash = 5; - hash = 83 * hash + Objects.hashCode(this.getUserName()); - hash = 83 * hash + Objects.hashCode(this.getUserId()); - return hash; - } - -} diff --git a/src/org/mxchange/jusercore/model/user/User.java b/src/org/mxchange/jusercore/model/user/User.java deleted file mode 100644 index 09e4f33..0000000 --- a/src/org/mxchange/jusercore/model/user/User.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.model.user; - -import java.io.Serializable; -import java.util.Calendar; -import java.util.Locale; -import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jusercore.model.user.profilemodes.ProfileMode; -import org.mxchange.jusercore.model.user.status.UserAccountStatus; - -/** - * A user POJI - *

- * @author Roland Häder - */ -public interface User extends Serializable { - - /** - * Getter for account status - *

- * @return Account status - */ - UserAccountStatus getUserAccountStatus (); - - /** - * Setter for account status - *

- * @param userStatus Account status - */ - void setUserAccountStatus (final UserAccountStatus userStatus); - - /** - * Getter for confirmation key - *

- * @return Confirmation key - */ - String getUserConfirmKey (); - - /** - * Setter for confirmation key - *

- * @param userConfirmKey Confirmation key - */ - void setUserConfirmKey (final String userConfirmKey); - - /** - * Getter for contact instance - *

- * @return Contact id number - */ - Contact getUserContact (); - - /** - * Setter for contact instance - *

- * @param contact Contact instance - */ - void setUserContact (final Contact contact); - - /** - * Getter for "created" timestamp - *

- * @return "created" timestamp - */ - Calendar getUserCreated (); - - /** - * Setter for "created" timestamp - *

- * @param userCreated "created" timestamp - */ - void setUserCreated (final Calendar userCreated); - - /** - * Getter for encrypted password - *

- * @return Encrypted password - */ - String getUserEncryptedPassword (); - - /** - * Setter for password hash - *

- * @param userEncryptedPassword Encrypted password - */ - void setUserEncryptedPassword (final String userEncryptedPassword); - - /** - * Getter for customer id number - *

- * @return User id number - */ - Long getUserId (); - - /** - * Settte for customer id number - *

- * @param customerId User id number - */ - void setUserId (final Long customerId); - - /** - * Getter for "locked" timestamp - *

- * @return "locked" timestamp - */ - Calendar getUserLastLocked (); - - /** - * Getter for "locked" timestamp - *

- * @param userLocked "locked" timestamp - */ - void setUserLastLocked (final Calendar userLocked); - - /** - * Getter for reason of last locked - *

- * @return Reason of last locked - */ - String getUserLastLockedReason (); - - /** - * Setter for reason of last locked - *

- * @param lastLockedReason Reason of last locked - */ - void setUserLastLockedReason (final String lastLockedReason); - - /** - * Getter for user name - *

- * @return User name - */ - String getUserName (); - - /** - * Setter for user name - *

- * @param userName User name - */ - void setUserName (final String userName); - - /** - * Getter for public user profile flag - *

- * @return Whether the user has a public profile - */ - ProfileMode getUserProfileMode (); - - /** - * Setter for public user profile flag - *

- * @param userPublicProfile Whether the user has a public profile - */ - void setUserProfileMode (final ProfileMode userPublicProfile); - - /** - * Getter for updated timestamp - *

- * @return Updated timestamp - */ - Calendar getUserUpdated (); - - /** - * Setter for updated timestamp - *

- * @param userUpdated Updated timestamp - */ - void setUserUpdated (final Calendar userUpdated); - - /** - * Getter for user's locale - *

- * @return User's locale - */ - Locale getUserLocale (); - - /** - * Setteror user's locale - *

- * @param userLocale User's locale - */ - void setUserLocale (final Locale userLocale); - - /** - * Getter for flag if user needs to change password - *

- * @return Flag if user needs to change password - */ - Boolean getUserMustChangePassword (); - - /** - * Setter for flag if user needs to change password - *

- * @param userMustChangePassword Flag if user needs to change password - */ - void setUserMustChangePassword (final Boolean userMustChangePassword); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); - -} diff --git a/src/org/mxchange/jusercore/model/user/UserUtils.java b/src/org/mxchange/jusercore/model/user/UserUtils.java deleted file mode 100644 index 3562caa..0000000 --- a/src/org/mxchange/jusercore/model/user/UserUtils.java +++ /dev/null @@ -1,610 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.model.user; - -import java.io.Serializable; -import java.security.SecureRandom; -import java.text.DateFormat; -import java.text.MessageFormat; -import java.util.Calendar; -import java.util.Properties; -import java.util.Random; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.commons.codec.digest.Crypt; -import org.apache.commons.codec.digest.DigestUtils; -import org.mxchange.jcontacts.contact.Contact; -import org.mxchange.jcontacts.contact.ContactUtils; -import org.mxchange.jusercore.container.login.LoginContainer; - -/** - * An utilities class for users - *

- * @author Roland Häder - */ -public class UserUtils implements Serializable { - - /** - * Password alphabet - */ - private static final String PASSWORD_ALPHABET; - - /** - * Password alphabet parts - */ - private static final String[] PASSWORD_ALPHABET_PARTS = { - // lower-case - "abcdefghijklmnopqrstuvwxyz", //NOI18N - - // upper-case - "ABCDEFGHIJKLMNOPQRSTUVWXYZ", //NOI18N - - // numbers - "0123456789", //NOI18N - - // characters - "~^!$%&/()=?{[]}@+*#-_,.;:<|>" //NOI18N - }; - - /** - * Hard-coded minimum password length - */ - private static final Integer PASSWORD_MINIMUM_LENGTH = 5; - - /** - * Random number generator - */ - private static final Random RANDOM_NUMBER_GENERATOR; - - /** - * Serial number - */ - private static final long serialVersionUID = 18_356_847_120_972L; - - /** - * Static initializer - */ - static { - // Init RNG - RANDOM_NUMBER_GENERATOR = new SecureRandom(); - - // Init alphabet - PASSWORD_ALPHABET = UserUtils.PASSWORD_ALPHABET_PARTS[0] + - UserUtils.PASSWORD_ALPHABET_PARTS[1] + - UserUtils.PASSWORD_ALPHABET_PARTS[2] + - UserUtils.PASSWORD_ALPHABET_PARTS[3]; - } - - /** - * Calculates entropy value for given password, higher means better. This - * method is based on - * http://stackoverflow.com/questions/14591701/how-to-check-password-strength-in-vaadin - *

- * @param password Clear text password - *

- * @return Entropy factor - */ - public static double calculateEntropyFactor (final String password) { - // Should not be null - if (null == password) { - // Throw NPE - throw new NullPointerException("password is null"); //NOI18N - } - - // Calculate it - double entropyFactor = password.length() * Math.log10(PASSWORD_ALPHABET.length()) / Math.log10(2); - - // Return it - return entropyFactor; - } - - /** - * Determines given password's strength: 0 = worst, 100 = best. This method - * is based on - * http://stackoverflow.com/questions/1614811/how-do-i-measure-the-strength-of-a-password - *

- * @param password Clear-text password - *

- * @return Strength of password - */ - public static double calculatePasswordScore (final String password) { - // Should not be null - if (null == password) { - // Throw NPE - throw new NullPointerException("password is null"); //NOI18N - } else if (password.isEmpty()) { - // Is empty - return 0.0f; - } - - // Init score - double score = 0.0f; - - // Password length - score += password.length() * calculateEntropyFactor(password) / 100; - - // Password has 3 numbers - if (ifRegExFoundInString("(.*[0-9].*[0-9].*[0-9].*)+", password)) { //NOI18N - score += 5; - } - - // Password has 2 symbols - if (ifRegExFoundInString("(.*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*)+", password)) { //NOI18N - score += 5; - } - - // Password has Upper and Lower chars - if (ifRegExFoundInString("(.*[a-z].*[A-Z])|([A-Z].*[a-z].*)+", password)) { //NOI18N - score += 10; - } - - // Password has number and chars - if (ifRegExFoundInString("(.*[a-zA-Z].*)+", password) && ifRegExFoundInString("(.*[0-9].*)+", password)) { //NOI18N - score += 15; - } - - // Password has number and symbol - if (ifRegExFoundInString("(.*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*)+", password) && ifRegExFoundInString("(.*[0-9].*)+", password)) { //NOI18N - score += 15; - } - - // Password has char and symbol - if (ifRegExFoundInString("(.*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*)+", password) && ifRegExFoundInString("(.*[a-zA-Z].*)+", password)) { //NOI18N - score += 15; - } - - // Password is just numbers or chars - if (ifRegExFoundInString("^[a-zA-Z]+$", password) || ifRegExFoundInString("^[0-9]+$", password)) { //NOI18N - score -= 10; - } - - // Larger than 100 is not allowed - score = Math.max(Math.min(score, 100.0f), 0.0f); - - // Return it - return score; - } - - /** - * Copies all attributes from other user object to target - *

- * @param sourceUser Source instance - * @param targetUser Target instance - */ - public static void copyAll (final User sourceUser, final User targetUser) { - // Check all parameter - if (null == sourceUser) { - // Throw NPE - throw new NullPointerException("sourceUser is null"); //NOI18N - } else if (null == targetUser) { - // Throw NPE - throw new NullPointerException("targetUser is null"); //NOI18N - } - - // Is contact set? - if (sourceUser.getUserContact() instanceof Contact) { - // Copy also contact data - ContactUtils.copyAll(sourceUser.getUserContact(), targetUser.getUserContact()); - } - - // Copy other data - targetUser.setUserConfirmKey(sourceUser.getUserConfirmKey()); - targetUser.setUserName(sourceUser.getUserName()); - targetUser.setUserEncryptedPassword(sourceUser.getUserEncryptedPassword()); - targetUser.setUserAccountStatus(sourceUser.getUserAccountStatus()); - targetUser.setUserCreated(sourceUser.getUserCreated()); - targetUser.setUserLastLocked(sourceUser.getUserLastLocked()); - targetUser.setUserLastLockedReason(sourceUser.getUserLastLockedReason()); - targetUser.setUserUpdated(sourceUser.getUserUpdated()); - targetUser.setUserProfileMode(sourceUser.getUserProfileMode()); - targetUser.setUserLocale(sourceUser.getUserLocale()); - targetUser.setUserMustChangePassword(sourceUser.getUserMustChangePassword()); - } - - /** - * Creates a pseudo-random password with given length - *

- * @param length Length of the password - *

- * @return Pseudo-random password - */ - public static String createRandomPassword (final Integer length) { - // Parameter should be valid - if (null == length) { - // Throw NPE - throw new NullPointerException("length is null"); //NOI18N - } else if (length < PASSWORD_MINIMUM_LENGTH) { - // To weak passwords - throw new IllegalArgumentException(MessageFormat.format("Password length {0} is to short, minimum: {1}", length, PASSWORD_MINIMUM_LENGTH)); //NOI18N - } - - // Init variable - StringBuilder password = new StringBuilder(length); - - // Start creating it - for (int i = 0; i < length; i++) { - // Take random part - String alphabet = PASSWORD_ALPHABET_PARTS[RANDOM_NUMBER_GENERATOR.nextInt(PASSWORD_ALPHABET_PARTS.length)]; - - // Generate random number - int pos = RANDOM_NUMBER_GENERATOR.nextInt(alphabet.length()); - - // Get char at this position and add it to the final password - password.append(String.valueOf(alphabet.charAt(pos))); - } - - // Should have the wanted length - assert (password.length() == length) : MessageFormat.format("Password length {0} doesn't match requested: {1}", password.length(), length); //NOI18N - - // Return it - return password.toString(); - } - - /** - * Hashes given user password and adds a salt to it - *

- * @param userPassword User password to be hashed - *

- * @return Hashed user password - */ - public static String encryptPassword (final String userPassword) { - // Is it null or empty? - if (null == userPassword) { - // Throw NPE - throw new NullPointerException("userPassword is null"); //NOI18N - } else if (userPassword.isEmpty()) { - // Empty passwords are hardcoded not allowed due to security risks - throw new IllegalArgumentException("userPassword is empty"); //NOI18N - } - - // Generate large number - String number = Long.toString(RANDOM_NUMBER_GENERATOR.nextLong() * 10_000_000_000L); - - // Generate salt - String salt = Crypt.crypt(number); - - // First encrypt password - String encryptedPassword = Crypt.crypt(userPassword, salt); - - // Return it - return encryptedPassword; - } - - /** - * Generates a pseudo-random user name - *

- * @return User name - */ - public static String generateRandomUserName () { - // User name's format is normally "user" + random number (10 digits) - String userName = String.format("user%d", RANDOM_NUMBER_GENERATOR.nextInt(10000000)); //NOI18N - - // Return it - return userName; - } - - /** - * Generate a key suitable for confirmation. This is basicly a large and - * strong hash with a lop entropy. - *

- * @param user User instance to use as additional entropy source - *

- * @return Generated key - */ - public static String generatedConfirmationKey (final User user) { - /** - * Generates random string by creating a random, encrypted password - * which gives nice entropy to start with. - */ - StringBuilder key = new StringBuilder(encryptPassword(generateRandomUserName())); - - // Is user set? - if (user instanceof User) { - // Add it's name, too - key.append(":").append(user); //NOI18N - - // Is user name set? - if (user.getUserName() instanceof String) { - // Add it - key.append(":").append(user.getUserName()); //NOI18N - } - - // Is password set? - if (user.getUserEncryptedPassword() instanceof String) { - // Add it, too - key.append(":").append(user.getUserEncryptedPassword()); //NOI18N - } - - // Get contact instance - Contact contact = user.getUserContact(); - - // Is contact set? - if (contact instanceof Contact) { - // Add it, too - key.append(":").append(contact); //NOI18N - - // Is email address set? - if (contact.getContactEmailAddress() instanceof String) { - // Add it, too - key.append(":").append(contact.getContactEmailAddress()); //NOI18N - } - } - } - - // Hash key - String hash = DigestUtils.sha256Hex(key.toString()); - - // Return it - return hash; - } - - /** - * Returns a Properties object from given user instance. - *

- * @param user User instance to get all fields from - *

- * @return All properties from given user - */ - public static Properties getAllUserFields (final User user) { - // Parameter should be valid - if (null == user) { - // Throw NPE - throw new NullPointerException("user is null"); //NOI18N - } else if (user.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("user.userId is null"); //NOI18N - } else if (user.getUserId() < 1) { - // Not valid number - throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid.", user.getUserId())); //NOI18N - } else if (user.getUserName() == null) { - // Throw NPE again - throw new NullPointerException("user.userName is null"); //NOI18N - } else if (user.getUserName().isEmpty()) { - // Empty string - throw new IllegalArgumentException("user.userName is empty"); //NOI18N - } else if (user.getUserAccountStatus() == null) { - // Throw NPE - throw new NullPointerException("user.userAccountStatus is null"); //NOI18N - } else if (user.getUserContact() == null) { - // Throw it again - throw new NullPointerException("user.userContact is null"); //NOI18N - } else if (user.getUserContact().getContactId() == null) { - // .. and again - throw new NullPointerException("user.userContact.contactId is null"); //NOI18N - } else if (user.getUserContact().getContactId() < 1) { - // Invalid id - throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is invalid", user.getUserContact().getContactId())); //NOI18N - } else if (user.getUserContact().getContactPersonalTitle() == null) { - // Throw NPE again - throw new NullPointerException("user.userContact.contactPersonalTitle is null"); //NOI18N - } - - // Init properties list - Properties properties = new Properties(); - - // Init some vbalues with empty strings - properties.setProperty("userConfirmKey", ""); //NOI18N - properties.setProperty("userUpdated", ""); //NOI18N - properties.setProperty("userLastLockedReason", ""); //NOI18N - properties.setProperty("contactTitle", ""); //NOI18N - properties.setProperty("contactStreet", ""); //NOI18N - properties.setProperty("contactHouseNumber", ""); //NOI18N - properties.setProperty("contactCity", ""); //NOI18N - // @TODO Unfinished: - properties.setProperty("contactCountry", ""); //NOI18N - properties.setProperty("contactZipCode", ""); //NOI18N - properties.setProperty("contactBirthday", ""); //NOI18N - properties.setProperty("contactEmailAddress", ""); //NOI18N - properties.setProperty("contactUpdated", ""); //NOI18N - - // Set all: - // - User data - properties.setProperty("userId", Long.toString(user.getUserId())); //NOI18N - properties.setProperty("userName", user.getUserName()); //NOI18N - properties.setProperty("userCreated", getFormattedTimestampFromUser(user, user.getUserCreated())); //NOI18N - if (user.getUserUpdated() != null) { - properties.setProperty("userUpdated", getFormattedTimestampFromUser(user, user.getUserUpdated())); //NOI18N - } - if (user.getUserConfirmKey() != null) { - properties.setProperty("userConfirmKey", user.getUserConfirmKey()); //NOI18N - } - if (user.getUserLastLockedReason() != null) { - properties.setProperty("userLastLockedReason", user.getUserLastLockedReason()); //NOI18N - } - if (user.getUserLastLocked() != null) { - properties.setProperty("userLastLocked", getFormattedTimestampFromUser(user, user.getUserLastLocked())); //NOI18N - } - properties.setProperty("userAccountStatus", user.getUserAccountStatus().toString()); //NOI18N - - // - Contact data - properties.setProperty("contactPersonalTitle", user.getUserContact().getContactPersonalTitle().toString()); //NOI18N - if (user.getUserContact().getContactTitle() != null) { - properties.setProperty("contactTitle", user.getUserContact().getContactTitle()); //NOI18N - } - properties.setProperty("contactFirstName", user.getUserContact().getContactFirstName()); //NOI18N - properties.setProperty("contactFamilyName", user.getUserContact().getContactFamilyName()); //NOI18N - if (user.getUserContact().getContactStreet() != null) { - properties.setProperty("contactStreet", user.getUserContact().getContactStreet()); //NOI18N - } - if (user.getUserContact().getContactHouseNumber() != null) { - properties.setProperty("contactHouseNumber", Short.toString(user.getUserContact().getContactHouseNumber())); //NOI18N - } - if (user.getUserContact().getContactCity() != null) { - properties.setProperty("contactCity", user.getUserContact().getContactCity()); //NOI18N - } - if (user.getUserContact().getContactZipCode() != null) { - properties.setProperty("contactZipCode", Integer.toString(user.getUserContact().getContactZipCode())); //NOI18N - } - if (user.getUserContact().getContactBirthday() != null) { - properties.setProperty("contactBirthday", user.getUserContact().getContactBirthday().toString()); //NOI18N - } - if (user.getUserContact().getContactEmailAddress() != null) { - properties.setProperty("contactEmailAddress", user.getUserContact().getContactEmailAddress()); //NOI18N - } - properties.setProperty("contactCreated", user.getUserContact().getContactCreated().toString()); //NOI18N - if (user.getUserContact().getContactUpdated() != null) { - properties.setProperty("contactUpdated", user.getUserContact().getContactUpdated().toString()); //NOI18N - } - - // Return it - return properties; - } - - /** - * Returns a formatted string from given user's locale and Calendar instance - *

- * @param user User instance - * @param calendar Calendar instance - *

- * @return A formatted string from Calendar instance - */ - public static String getFormattedTimestampFromUser (final User user, final Calendar calendar) { - // Get formatter - DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, user.getUserLocale()); - - // Now simply format the calendar's Time (not just time) field - String dateTime = format.format(calendar.getTime()); - - // Return it - return dateTime; - } - - /** - * Checks if password from container matches the updatedUser's password - *

- * @param container Container holding user instance and clear-text - * password - * @param updatedUser Updated user instance from database - *

- * @return Whether the password matches - */ - public static boolean ifPasswordMatches (final LoginContainer container, final User updatedUser) { - // Validate parameters - if (null == container) { - // Throw NPE - throw new NullPointerException("container is null"); //NOI18N - } else if (null == updatedUser) { - // And again NPE ... - throw new NullPointerException("updatedUser is null"); //NOI18N - } else if (container.getUser() == null) { - // NPE for user in container - throw new NullPointerException("container.user is null"); //NOI18N - } else if (container.getUserPassword() == null) { - // NPE for user password in container - throw new NullPointerException("container.userPassword is null"); //NOI18N - } else if (container.getUserPassword().isEmpty()) { - // Empty password in container - throw new IllegalArgumentException("container.userPassword is empty"); //NOI18N - } - - // Call below method - return ifPasswordMatches(container.getUserPassword(), updatedUser); - } - - /** - * Checks if direct password the updatedUser's password - *

- * @param clearTextPassword Clear-text (direct) password - * @param updatedUser Updated user instance from database - *

- * @return Whether the password matches - */ - public static boolean ifPasswordMatches (final String clearTextPassword, final User updatedUser) { - // Validate parameters - if (null == clearTextPassword) { - // Throw NPE - throw new NullPointerException("clearTextPassword is null"); //NOI18N - } else if (clearTextPassword.isEmpty()) { - // NPE for user in container - throw new NullPointerException("clearTextPassword is empty."); //NOI18N - } else if (null == updatedUser) { - // And again NPE ... - throw new NullPointerException("updatedUser is null"); //NOI18N - } - - // First encrypt password - String encryptedPassword = Crypt.crypt(clearTextPassword, updatedUser.getUserEncryptedPassword()); - - // Is it matching? - return encryptedPassword.equals(updatedUser.getUserEncryptedPassword()); - } - - /** - * Checks if password from container matches with from user instance. - *

- * @param container Container holding user instance and clear-text password - *

- * @return Whether it maches - */ - public static boolean ifPasswordMatches (final LoginContainer container) { - // Validate parameters - if (null == container) { - // Throw NPE - throw new NullPointerException("container is null"); //NOI18N - } else if (container.getUser() == null) { - // NPE for user in container - throw new NullPointerException("container.user is null"); //NOI18N - } else if (container.getUserPassword() == null) { - // NPE for user password in container - throw new NullPointerException("container.userPassword is null"); //NOI18N - } else if (container.getUserPassword().isEmpty()) { - // Empty password in container - throw new IllegalArgumentException("container.userPassword is empty"); //NOI18N - } - - // Call other method - return ifPasswordMatches(container.getUserPassword(), container.getUser()); - } - - /** - * Checks if the regular expression is found in given string - *

- * @param pattern Regular expression - * @param str String - *

- * @return Whether it is found - */ - private static boolean ifRegExFoundInString (final String pattern, final String str) { - // Mus be valid parameters - if (null == pattern) { - // Throw NPE - throw new NullPointerException("pattern is null"); //NOI18N - } else if (pattern.isEmpty()) { - // Is empty - throw new IllegalArgumentException("pattern is empty"); //NOI18N - } else if (null == str) { - // Throw NPE - throw new NullPointerException("str is null"); //NOI18N - } - - // Compile pattern - Pattern r = Pattern.compile(pattern); - - // Get matcher - Matcher m = r.matcher(str); - - // Check if it is found - return m.find(); - } - - /** - * No instance from this class - */ - private UserUtils () { - } - -} diff --git a/src/org/mxchange/jusercore/model/user/password_history/PasswordHistory.java b/src/org/mxchange/jusercore/model/user/password_history/PasswordHistory.java deleted file mode 100644 index 123bfcf..0000000 --- a/src/org/mxchange/jusercore/model/user/password_history/PasswordHistory.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.model.user.password_history; - -import java.io.Serializable; -import java.util.Calendar; -import org.mxchange.jusercore.model.user.User; - -/** - * A POJI for user password history - *

- * @author Roland Häder - */ -public interface PasswordHistory extends Serializable { - - /** - * Getter for timestamp this history entry has been created (usually in - * EJB). - *

- * @return Timestamp when this history entry has been created - */ - Calendar getUserPasswordHistoryCreated (); - - /** - * Setter for timestamp this history entry has been created (usually in - * EJB). - *

- * @param userPasswordHistoryCreated Timestamp when this history entry has - * been created - */ - void setUserPasswordHistoryCreated (final Calendar userPasswordHistoryCreated); - - /** - * Getter for history entry id (primary key) - *

- * @return History entry id (primary key) - */ - Long getUserPasswordHistoryId (); - - /** - * Setter for history entry id (primary key) - *

- * @param userPasswordHistoryId History entry id (primary key) - */ - void setUserPasswordHistoryId (final Long userPasswordHistoryId); - - /** - * Getter for user's password hash - *

- * @return User's password hash - */ - String getUserPasswordHistoryPasswordHash (); - - /** - * Setter for user's password hash - *

- * @param userPasswordHistoryPasswordHash User's password hash - */ - void setUserPasswordHistoryPasswordHash (final String userPasswordHistoryPasswordHash); - - /** - * Getter for user instance - *

- * @return User instance - */ - User getUserPasswordHistoryUser (); - - /** - * Setter for user instance - *

- * @param userPasswordHistoryUser User instance - */ - void setUserPasswordHistoryUser (final User userPasswordHistoryUser); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); - -} diff --git a/src/org/mxchange/jusercore/model/user/password_history/UserPasswordHistory.java b/src/org/mxchange/jusercore/model/user/password_history/UserPasswordHistory.java deleted file mode 100644 index 06b3a6b..0000000 --- a/src/org/mxchange/jusercore/model/user/password_history/UserPasswordHistory.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.model.user.password_history; - -import java.util.Calendar; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.NamedQueries; -import javax.persistence.NamedQuery; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.mxchange.jusercore.model.user.LoginUser; -import org.mxchange.jusercore.model.user.User; - -/** - * A POJO for user password history - *

- * @author Roland Häder - */ -@Entity (name = "user_password_history") -@Table ( - name = "user_password_history" -) -@NamedQueries ( - { - @NamedQuery (name = "AllUsersHistoryEntries", query = "SELECT h FROM user_password_history AS h WHERE h.userPasswordHistoryUser = :user ORDER BY h.userPasswordHistoryId DESC") - } -) -@SuppressWarnings ("PersistenceUnitPresent") -public class UserPasswordHistory implements PasswordHistory { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 573_482_374_873_853_710L; - - /** - * Timestamp when this entry has been created - */ - @Basic (optional = false) - @Column (name = "history_created", nullable = false, updatable = false) - @Temporal (TemporalType.TIMESTAMP) - private Calendar userPasswordHistoryCreated; - - /** - * Id number (primary key) - */ - @Id - @Column (name = "history_id", updatable = false) - @GeneratedValue (strategy = GenerationType.IDENTITY) - private Long userPasswordHistoryId; - - /** - * Password hash being used - */ - @Basic (optional = false) - @Column (name = "history_password_hash", nullable = false, updatable = false) - private String userPasswordHistoryPasswordHash; - - /** - * User instance for this history entry - */ - @JoinColumn (name = "history_user_id", nullable = true, updatable = false) - @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH) - private User userPasswordHistoryUser; - - /** - * Default constructor - */ - public UserPasswordHistory () { - } - - /** - * Constructor with password hash and user instance - *

- * @param userPasswordHistoryPasswordHash Password hash - * @param userPasswordHistoryUser User instance - */ - public UserPasswordHistory (final String userPasswordHistoryPasswordHash, final User userPasswordHistoryUser) { - // Set all - this.userPasswordHistoryPasswordHash = userPasswordHistoryPasswordHash; - this.userPasswordHistoryUser = userPasswordHistoryUser; - } - - @Override - public boolean equals (final Object object) { - if (this == object) { - return true; - } else if (object == null) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - final PasswordHistory other = (PasswordHistory) object; - - if (!Objects.equals(this.getUserPasswordHistoryId(), other.getUserPasswordHistoryId())) { - return false; - } else if (!Objects.equals(this.getUserPasswordHistoryPasswordHash(), other.getUserPasswordHistoryPasswordHash())) { - return false; - } else if (!Objects.equals(this.getUserPasswordHistoryUser(), other.getUserPasswordHistoryUser())) { - return false; - } - - return true; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Calendar getUserPasswordHistoryCreated () { - return this.userPasswordHistoryCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setUserPasswordHistoryCreated (final Calendar userPasswordHistoryCreated) { - this.userPasswordHistoryCreated = userPasswordHistoryCreated; - } - - @Override - public Long getUserPasswordHistoryId () { - return this.userPasswordHistoryId; - } - - @Override - public void setUserPasswordHistoryId (final Long userPasswordHistoryId) { - this.userPasswordHistoryId = userPasswordHistoryId; - } - - @Override - public String getUserPasswordHistoryPasswordHash () { - return this.userPasswordHistoryPasswordHash; - } - - @Override - public void setUserPasswordHistoryPasswordHash (final String userPasswordHistoryPasswordHash) { - this.userPasswordHistoryPasswordHash = userPasswordHistoryPasswordHash; - } - - @Override - public User getUserPasswordHistoryUser () { - return this.userPasswordHistoryUser; - } - - @Override - public void setUserPasswordHistoryUser (final User userPasswordHistoryUser) { - this.userPasswordHistoryUser = userPasswordHistoryUser; - } - - @Override - public int hashCode () { - int hash = 7; - - hash = 79 * hash + Objects.hashCode(this.getUserPasswordHistoryId()); - hash = 79 * hash + Objects.hashCode(this.getUserPasswordHistoryPasswordHash()); - hash = 79 * hash + Objects.hashCode(this.getUserPasswordHistoryUser()); - - return hash; - } - -} diff --git a/src/org/mxchange/jusercore/model/user/profilemodes/ProfileMode.java b/src/org/mxchange/jusercore/model/user/profilemodes/ProfileMode.java deleted file mode 100644 index 208a3f5..0000000 --- a/src/org/mxchange/jusercore/model/user/profilemodes/ProfileMode.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.model.user.profilemodes; - -import java.io.Serializable; - -/** - * User profile modes - *

- * @author Roland Häder - */ -public enum ProfileMode implements Serializable { - - /** - * Invisible to guests and members (not administrators) - */ - INVISIBLE("PROFILE_MODE_INVISIBLE"), //NOI18N - - /** - * Only visible to members (and administrators) - */ - MEMBERS("PROFILE_MODE_MEMBERS"), //NOI18N - - /** - * Visible to all (public in Internet) - */ - PUBLIC("PROFILE_MODE_PUBLIC"); //NOI18N - - /** - * Message key (i18n) - */ - private final String messageKey; - - /** - * Constructor with message key - *

- * @param messageKey Message key - */ - private ProfileMode (final String messageKey) { - this.messageKey = messageKey; - } - - /** - * Getter for message key (i18n) - *

- * @return Message key - */ - public String getMessageKey () { - return this.messageKey; - } - -} diff --git a/src/org/mxchange/jusercore/model/user/status/UserAccountStatus.java b/src/org/mxchange/jusercore/model/user/status/UserAccountStatus.java deleted file mode 100644 index d1cc53c..0000000 --- a/src/org/mxchange/jusercore/model/user/status/UserAccountStatus.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.model.user.status; - -import java.io.Serializable; - -/** - * An enumeration for user's account status like confirmed, locked, etc. - *

- * @author Roland Häder - */ -public enum UserAccountStatus implements Serializable { - - /** - * Unconfirmed (default) - */ - UNCONFIRMED("USER_ACCOUNT_STATUS_UNCONFIRMED", "user_status_unconfirmed"), //NOI18N - - /** - * Confirmed (email address validated) - */ - CONFIRMED("USER_ACCOUNT_STATUS_CONFIRMED", "user_status_confirmed"), //NOI18N - - /** - * Locked (maybe violated T&C) - */ - LOCKED("USER_ACCOUNT_STATUS_LOCKED", "user_status_locked"); //NOI18N - - /** - * Message key - */ - private final String messageKey; - - /** - * CSS style class - */ - private final String styleClass; - - /** - * Constructor with i18n translation key and CSS style class - *

- * @param messageKey Message key (i18n) - * @param styleClass CSS style class - */ - private UserAccountStatus (final String messageKey, final String styleClass) { - // Set it here - this.messageKey = messageKey; - this.styleClass = styleClass; - } - - /** - * Getter for message key - *

- * @return Message key (i18n) - */ - public String getMessageKey () { - return this.messageKey; - } - - /** - * Getter for CSS style class - *

- * @return CSS style class - */ - public String getStyleClass () { - return this.styleClass; - } - -} diff --git a/src/org/mxchange/juserlogincore/container/login/LoginContainer.java b/src/org/mxchange/juserlogincore/container/login/LoginContainer.java new file mode 100644 index 0000000..bab211d --- /dev/null +++ b/src/org/mxchange/juserlogincore/container/login/LoginContainer.java @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.container.login; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.User; + +/** + * A container for login data + *

+ * @author Roland Häder + */ +public interface LoginContainer extends Serializable { + + /** + * Getter for user instance + *

+ * @return User instance + */ + User getUser (); + + /** + * Setter for user instance + *

+ * @param user User instance + */ + void setUser (final User user); + + /** + * Getter for user password + *

+ * @return User password + */ + String getUserPassword (); + + /** + * Setter for user password + *

+ * @param userPassword User password + */ + void setUserPassword (final String userPassword); + +} diff --git a/src/org/mxchange/juserlogincore/container/login/UserLoginContainer.java b/src/org/mxchange/juserlogincore/container/login/UserLoginContainer.java new file mode 100644 index 0000000..ca191c0 --- /dev/null +++ b/src/org/mxchange/juserlogincore/container/login/UserLoginContainer.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.container.login; + +import org.mxchange.jusercore.model.user.User; + +/** + * A user login container + *

+ * @author Roland Häder + */ +public class UserLoginContainer implements LoginContainer { + + /** + * Serial number + */ + private static final long serialVersionUID = 158_768_718_689_760_186L; + + /** + * User instance + */ + private User user; + + /** + * Clear-text password + */ + private String userPassword; + + /** + * Constructor with user instance and clear-text password + *

+ * @param user User instance + * @param userPassword Clear-text password + */ + public UserLoginContainer (final User user, final String userPassword) { + // Is both set? + if (null == user) { + // Throw NPE + throw new NullPointerException("user is null"); //NOI18N + } else if (null == userPassword) { + // Throw NPE again + throw new NullPointerException("userPassword is null"); //NOI18N + } else if (userPassword.isEmpty()) { + // Empty password + throw new IllegalArgumentException("user password is empty."); //NOI18N + } + + // Set both + this.user = user; + this.userPassword = userPassword; + } + + @Override + public User getUser () { + return this.user; + } + + @Override + public void setUser (final User user) { + this.user = user; + } + + @Override + public String getUserPassword () { + return this.userPassword; + } + + @Override + public void setUserPassword (final String userPassword) { + this.userPassword = userPassword; + } + +} diff --git a/src/org/mxchange/juserlogincore/events/confirmation/ObservableUserConfirmedAccountEvent.java b/src/org/mxchange/juserlogincore/events/confirmation/ObservableUserConfirmedAccountEvent.java new file mode 100644 index 0000000..b92dce7 --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/confirmation/ObservableUserConfirmedAccountEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.events.confirmation; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.User; + +/** + * An event interface, fired if a new user has registered + *

+ * @author Roland Häder + */ +public interface ObservableUserConfirmedAccountEvent extends Serializable { + + /** + * Getter for user instance + *

+ * @return User instance + */ + User getConfirmedUser (); + +} diff --git a/src/org/mxchange/juserlogincore/events/confirmation/UserConfirmedAccountEvent.java b/src/org/mxchange/juserlogincore/events/confirmation/UserConfirmedAccountEvent.java new file mode 100644 index 0000000..da2c141 --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/confirmation/UserConfirmedAccountEvent.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.events.confirmation; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * An event, fired if a new confirmedUser has confirmed + *

+ * @author Roland Häder + */ +public class UserConfirmedAccountEvent implements ObservableUserConfirmedAccountEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 575_412_375_267_190L; + + /** + * Newly confirmed user + */ + private final User confirmedUser; + + /** + * Constructor with newly confirmed confirmedUser + *

+ * @param confirmedUser Newly confirmed confirmedUser + */ + public UserConfirmedAccountEvent (final User confirmedUser) { + // Is the confirmed user instance valid? + if (null == confirmedUser) { + // Throw NPE + throw new NullPointerException("confirmedUser is null"); //NOI18N + } else if (confirmedUser.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("confirmedUser.userId is null"); //NOI18N + } else if (confirmedUser.getUserId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("confirmedUser.userId={0} is invalid.", confirmedUser.getUserId())); //NOI18N + } + + // Set it here + this.confirmedUser = confirmedUser; + } + + @Override + public User getConfirmedUser () { + return this.confirmedUser; + } + +} diff --git a/src/org/mxchange/juserlogincore/events/login/ObservableUserLoggedInEvent.java b/src/org/mxchange/juserlogincore/events/login/ObservableUserLoggedInEvent.java new file mode 100644 index 0000000..e3b89cf --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/login/ObservableUserLoggedInEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.events.login; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.User; + +/** + * An interface for events after the user has logged in + *

+ * @author Roland Häder + */ +public interface ObservableUserLoggedInEvent extends Serializable { + + /** + * Getter for user instance + *

+ * @return User instance + */ + User getLoggedInUser (); + +} diff --git a/src/org/mxchange/juserlogincore/events/login/UserLoggedInEvent.java b/src/org/mxchange/juserlogincore/events/login/UserLoggedInEvent.java new file mode 100644 index 0000000..40690af --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/login/UserLoggedInEvent.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.events.login; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * This event is fired when the loggedInUser has logged in + *

+ * @author Roland Häder + */ +public class UserLoggedInEvent implements ObservableUserLoggedInEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 163_294_958_817_560L; + + /** + * User instance + */ + private final User loggedInUser; + + /** + * Constructor with updated user instance + *

+ * @param loggedInUser Updated user instance + */ + public UserLoggedInEvent (final User loggedInUser) { + // Is the logged-in user instance valid? + if (null == loggedInUser) { + // Throw NPE + throw new NullPointerException("loggedInUser is null"); //NOI18N + } else if (loggedInUser.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("loggedInUser.userId is null"); //NOI18N + } else if (loggedInUser.getUserId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("loggedInUser.userId={0} is invalid.", loggedInUser.getUserId())); //NOI18N + } + + // Set loggedInUser + this.loggedInUser = loggedInUser; + } + + @Override + public User getLoggedInUser () { + return this.loggedInUser; + } + +} diff --git a/src/org/mxchange/juserlogincore/events/logout/ObservableUserLogoutEvent.java b/src/org/mxchange/juserlogincore/events/logout/ObservableUserLogoutEvent.java new file mode 100644 index 0000000..0dba693 --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/logout/ObservableUserLogoutEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.events.logout; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.User; + +/** + * An interface for events after the user has logged in + *

+ * @author Roland Häder + */ +public interface ObservableUserLogoutEvent extends Serializable { + + /** + * Getter for user instance + *

+ * @return User instance + */ + User getLoggedOutUser (); + +} diff --git a/src/org/mxchange/juserlogincore/events/logout/UserLogoutEvent.java b/src/org/mxchange/juserlogincore/events/logout/UserLogoutEvent.java new file mode 100644 index 0000000..22adc7a --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/logout/UserLogoutEvent.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.events.logout; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * This event is fired when the loggedOutUser has logged in + *

+ * @author Roland Häder + */ +public class UserLogoutEvent implements ObservableUserLogoutEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 58_617_641_290_620L; + + /** + * User instance + */ + private final User loggedOutUser; + + /** + * Constructor with updated loggedOutUser instance + *

+ * @param loggedOutUser Updated loggedOutUser instance + */ + public UserLogoutEvent (final User loggedOutUser) { + // Is the logged-in user instance valid? + if (null == loggedOutUser) { + // Throw NPE + throw new NullPointerException("loggedOutUser is null"); //NOI18N + } else if (loggedOutUser.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("loggedOutUser.userId is null"); //NOI18N + } else if (loggedOutUser.getUserId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("loggedOutUser.userId={0} is invalid.", loggedOutUser.getUserId())); //NOI18N + } + + // Set loggedOutUser + this.loggedOutUser = loggedOutUser; + } + + @Override + public User getLoggedOutUser () { + return this.loggedOutUser; + } + +} diff --git a/src/org/mxchange/juserlogincore/events/registration/ObservableUserRegisteredEvent.java b/src/org/mxchange/juserlogincore/events/registration/ObservableUserRegisteredEvent.java new file mode 100644 index 0000000..67f593f --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/registration/ObservableUserRegisteredEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.events.registration; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.User; + +/** + * An event interface, fired if a new user has registered + *

+ * @author Roland Häder + */ +public interface ObservableUserRegisteredEvent extends Serializable { + + /** + * Getter for user instance + *

+ * @return User instance + */ + User getRegisteredUser (); + +} diff --git a/src/org/mxchange/juserlogincore/events/registration/UserRegisteredEvent.java b/src/org/mxchange/juserlogincore/events/registration/UserRegisteredEvent.java new file mode 100644 index 0000000..daf11b1 --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/registration/UserRegisteredEvent.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.events.registration; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * An event, fired if a new registeredUser has registered + *

+ * @author Roland Häder + */ +public class UserRegisteredEvent implements ObservableUserRegisteredEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 186_956_974_127_691L; + + /** + * Newly registered registeredUser; + */ + private final User registeredUser; + + /** + * Constructor with newly registered registeredUser + *

+ * @param registeredUser Newly registered registeredUser + */ + public UserRegisteredEvent (final User registeredUser) { + // Is the registered user instance valid? + if (null == registeredUser) { + // Throw NPE + throw new NullPointerException("registeredUser is null"); //NOI18N + } else if (registeredUser.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("registeredUser.userId is null"); //NOI18N + } else if (registeredUser.getUserId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("registeredUser.userId={0} is invalid.", registeredUser.getUserId())); //NOI18N + } + + // Set it here + this.registeredUser = registeredUser; + } + + /** + * Getter for registeredUser instance + *

+ * @return User instance + */ + @Override + public User getRegisteredUser () { + return this.registeredUser; + } + +} diff --git a/src/org/mxchange/juserlogincore/events/resendlink/ObservableUserResendLinkAccountEvent.java b/src/org/mxchange/juserlogincore/events/resendlink/ObservableUserResendLinkAccountEvent.java new file mode 100644 index 0000000..dc13837 --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/resendlink/ObservableUserResendLinkAccountEvent.java @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.events.resendlink; + +import java.io.Serializable; +import org.mxchange.jusercore.model.user.User; + +/** + * An event interface, fired if a user has resend confirmation link + *

+ * @author Roland Häder + */ +public interface ObservableUserResendLinkAccountEvent extends Serializable { + + /** + * Getter for user instance + *

+ * @return User instance + */ + User getResendLinkUser (); + +} diff --git a/src/org/mxchange/juserlogincore/events/resendlink/UserResendLinkAccountEvent.java b/src/org/mxchange/juserlogincore/events/resendlink/UserResendLinkAccountEvent.java new file mode 100644 index 0000000..d79fef1 --- /dev/null +++ b/src/org/mxchange/juserlogincore/events/resendlink/UserResendLinkAccountEvent.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.events.resendlink; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * An event, fired if a user has resend confirmation link + *

+ * @author Roland Häder + */ +public class UserResendLinkAccountEvent implements ObservableUserResendLinkAccountEvent { + + /** + * Serial number + */ + private static final long serialVersionUID = 575_412_375_267_190L; + + /** + * user resend confirmation link + */ + private final User resendLinkUser; + + /** + * Constructor with user resend confirmation link + *

+ * @param resendLinkUser User resend confirmation link + */ + public UserResendLinkAccountEvent (final User resendLinkUser) { + // Is the confirmed user instance valid? + if (null == resendLinkUser) { + // Throw NPE + throw new NullPointerException("resendLinkUser is null"); //NOI18N + } else if (resendLinkUser.getUserId() == null) { + // Throw NPE again + throw new NullPointerException("resendLinkUser.userId is null"); //NOI18N + } else if (resendLinkUser.getUserId() < 1) { + // Invalid id number + throw new IllegalArgumentException(MessageFormat.format("resendLinkUser.userId={0} is invalid.", resendLinkUser.getUserId())); //NOI18N + } + + // Set it here + this.resendLinkUser = resendLinkUser; + } + + @Override + public User getResendLinkUser () { + return this.resendLinkUser; + } + +} diff --git a/src/org/mxchange/juserlogincore/exceptions/UserNotFoundException.java b/src/org/mxchange/juserlogincore/exceptions/UserNotFoundException.java new file mode 100644 index 0000000..39ff631 --- /dev/null +++ b/src/org/mxchange/juserlogincore/exceptions/UserNotFoundException.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.exceptions; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * An exception thrown when the user's account was not found + *

+ * @author Roland Häder + */ +public class UserNotFoundException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 42_895_928_956_718_956L; + + /** + * Constructor with already registered user instance + *

+ * @param user User instance + */ + public UserNotFoundException (final User user) { + // Call super contructor + super(MessageFormat.format("User name {0} not found.", user.getUserName())); //NOI18N + } + + /** + * Constructor with user id + *

+ * @param userId User id + */ + public UserNotFoundException (final Long userId) { + super(MessageFormat.format("User id {0} not found.", userId)); //NOI18N + } + +} diff --git a/src/org/mxchange/juserlogincore/exceptions/UserPasswordMismatchException.java b/src/org/mxchange/juserlogincore/exceptions/UserPasswordMismatchException.java new file mode 100644 index 0000000..8d19b4f --- /dev/null +++ b/src/org/mxchange/juserlogincore/exceptions/UserPasswordMismatchException.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.exceptions; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * An exception thrown when the entered password did not match the stored + * password. + *

+ * @author Roland Häder + */ +public class UserPasswordMismatchException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 97_283_567_871_569_401L; + + /** + * Creates an exception with given user instance + *

+ * @param user User instance + */ + public UserPasswordMismatchException (final User user) { + super(MessageFormat.format("Password for user {0} does not match stored password.", user)); + } + +} diff --git a/src/org/mxchange/juserlogincore/exceptions/UserPasswordRepeatMismatchException.java b/src/org/mxchange/juserlogincore/exceptions/UserPasswordRepeatMismatchException.java new file mode 100644 index 0000000..78deecf --- /dev/null +++ b/src/org/mxchange/juserlogincore/exceptions/UserPasswordRepeatMismatchException.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.exceptions; + +import java.text.MessageFormat; +import org.mxchange.jusercore.model.user.User; + +/** + * An exception thrown when the entered password did not match the stored + * password. + *

+ * @author Roland Häder + */ +public class UserPasswordRepeatMismatchException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 51_782_450_671_256_594L; + + /** + * Creates an exception with given user instance + *

+ * @param user User instance + */ + public UserPasswordRepeatMismatchException (final User user) { + super(MessageFormat.format("Passwords don't match, userId={0}", user.getUserId())); + } + +} diff --git a/src/org/mxchange/juserlogincore/login/UserLoginUtils.java b/src/org/mxchange/juserlogincore/login/UserLoginUtils.java new file mode 100644 index 0000000..119425b --- /dev/null +++ b/src/org/mxchange/juserlogincore/login/UserLoginUtils.java @@ -0,0 +1,428 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.juserlogincore.login; + +import java.io.Serializable; +import java.security.SecureRandom; +import java.text.MessageFormat; +import java.util.Random; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.codec.digest.Crypt; +import org.apache.commons.codec.digest.DigestUtils; +import org.mxchange.jcontacts.contact.Contact; +import org.mxchange.jusercore.model.user.User; +import org.mxchange.jusercore.model.user.UserUtils; +import org.mxchange.juserlogincore.container.login.LoginContainer; + +/** + * An utilities class for user logins + *

+ * @author Roland Häder + */ +public class UserLoginUtils implements Serializable { + + /** + * Password alphabet + */ + private static final String PASSWORD_ALPHABET; + + /** + * Password alphabet parts + */ + private static final String[] PASSWORD_ALPHABET_PARTS = { + // lower-case + "abcdefghijklmnopqrstuvwxyz", //NOI18N + + // upper-case + "ABCDEFGHIJKLMNOPQRSTUVWXYZ", //NOI18N + + // numbers + "0123456789", //NOI18N + + // characters + "~^!$%&/()=?{[]}@+*#-_,.;:<|>" //NOI18N + }; + + /** + * Hard-coded minimum password length + */ + private static final Integer PASSWORD_MINIMUM_LENGTH = 5; + + /** + * Random number generator + */ + private static final Random RANDOM_NUMBER_GENERATOR; + + /** + * Serial number + */ + private static final long serialVersionUID = 18_356_847_120_972L; + + /** + * Static initializer + */ + static { + // Init RNG + RANDOM_NUMBER_GENERATOR = new SecureRandom(); + + // Init alphabet + PASSWORD_ALPHABET = UserLoginUtils.PASSWORD_ALPHABET_PARTS[0] + + UserLoginUtils.PASSWORD_ALPHABET_PARTS[1] + + UserLoginUtils.PASSWORD_ALPHABET_PARTS[2] + + UserLoginUtils.PASSWORD_ALPHABET_PARTS[3]; + } + + /** + * Calculates entropy value for given password, higher means better. This + * method is based on + * http://stackoverflow.com/questions/14591701/how-to-check-password-strength-in-vaadin + *

+ * @param password Clear text password + *

+ * @return Entropy factor + */ + public static double calculateEntropyFactor (final String password) { + // Should not be null + if (null == password) { + // Throw NPE + throw new NullPointerException("password is null"); //NOI18N + } + + // Calculate it + double entropyFactor = password.length() * Math.log10(PASSWORD_ALPHABET.length()) / Math.log10(2); + + // Return it + return entropyFactor; + } + + /** + * Determines given password's strength: 0 = worst, 100 = best. This method + * is based on + * http://stackoverflow.com/questions/1614811/how-do-i-measure-the-strength-of-a-password + *

+ * @param password Clear-text password + *

+ * @return Strength of password + */ + public static double calculatePasswordScore (final String password) { + // Should not be null + if (null == password) { + // Throw NPE + throw new NullPointerException("password is null"); //NOI18N + } else if (password.isEmpty()) { + // Is empty + return 0.0f; + } + + // Init score + double score = 0.0f; + + // Password length + score += password.length() * calculateEntropyFactor(password) / 100; + + // Password has 3 numbers + if (ifRegExFoundInString("(.*[0-9].*[0-9].*[0-9].*)+", password)) { //NOI18N + score += 5; + } + + // Password has 2 symbols + if (ifRegExFoundInString("(.*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*)+", password)) { //NOI18N + score += 5; + } + + // Password has Upper and Lower chars + if (ifRegExFoundInString("(.*[a-z].*[A-Z])|([A-Z].*[a-z].*)+", password)) { //NOI18N + score += 10; + } + + // Password has number and chars + if (ifRegExFoundInString("(.*[a-zA-Z].*)+", password) && ifRegExFoundInString("(.*[0-9].*)+", password)) { //NOI18N + score += 15; + } + + // Password has number and symbol + if (ifRegExFoundInString("(.*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*)+", password) && ifRegExFoundInString("(.*[0-9].*)+", password)) { //NOI18N + score += 15; + } + + // Password has char and symbol + if (ifRegExFoundInString("(.*[!,@,#,$,%,^,&,*,/,?,_,~,=,.,-,;,:].*)+", password) && ifRegExFoundInString("(.*[a-zA-Z].*)+", password)) { //NOI18N + score += 15; + } + + // Password is just numbers or chars + if (ifRegExFoundInString("^[a-zA-Z]+$", password) || ifRegExFoundInString("^[0-9]+$", password)) { //NOI18N + score -= 10; + } + + // Larger than 100 is not allowed + score = Math.max(Math.min(score, 100.0f), 0.0f); + + // Return it + return score; + } + + /** + * Creates a pseudo-random password with given length + *

+ * @param length Length of the password + *

+ * @return Pseudo-random password + */ + public static String createRandomPassword (final Integer length) { + // Parameter should be valid + if (null == length) { + // Throw NPE + throw new NullPointerException("length is null"); //NOI18N + } else if (length < PASSWORD_MINIMUM_LENGTH) { + // To weak passwords + throw new IllegalArgumentException(MessageFormat.format("Password length {0} is to short, minimum: {1}", length, PASSWORD_MINIMUM_LENGTH)); //NOI18N + } + + // Init variable + StringBuilder password = new StringBuilder(length); + + // Start creating it + for (int i = 0; i < length; i++) { + // Take random part + String alphabet = PASSWORD_ALPHABET_PARTS[RANDOM_NUMBER_GENERATOR.nextInt(PASSWORD_ALPHABET_PARTS.length)]; + + // Generate random number + int pos = RANDOM_NUMBER_GENERATOR.nextInt(alphabet.length()); + + // Get char at this position and add it to the final password + password.append(String.valueOf(alphabet.charAt(pos))); + } + + // Should have the wanted length + assert (password.length() == length) : MessageFormat.format("Password length {0} doesn't match requested: {1}", password.length(), length); //NOI18N + + // Return it + return password.toString(); + } + + /** + * Hashes given user password and adds a salt to it + *

+ * @param userPassword User password to be hashed + *

+ * @return Hashed user password + */ + public static String encryptPassword (final String userPassword) { + // Is it null or empty? + if (null == userPassword) { + // Throw NPE + throw new NullPointerException("userPassword is null"); //NOI18N + } else if (userPassword.isEmpty()) { + // Empty passwords are hardcoded not allowed due to security risks + throw new IllegalArgumentException("userPassword is empty"); //NOI18N + } + + // Generate large number + String number = Long.toString(RANDOM_NUMBER_GENERATOR.nextLong() * 10_000_000_000L); + + // Generate salt + String salt = Crypt.crypt(number); + + // First encrypt password + String encryptedPassword = Crypt.crypt(userPassword, salt); + + // Return it + return encryptedPassword; + } + + /** + * Generate a key suitable for confirmation. This is basicly a large and + * strong hash with a lop entropy. + *

+ * @param user User instance to use as additional entropy source + *

+ * @return Generated key + */ + public static String generatedConfirmationKey (final User user) { + /** + * Generates random string by creating a random, encrypted password + * which gives nice entropy to start with. + */ + StringBuilder key = new StringBuilder(encryptPassword(UserUtils.generateRandomUserName())); + + // Is user set? + if (user instanceof User) { + // Add it's name, too + key.append(":").append(user); //NOI18N + + // Is user name set? + if (user.getUserName() instanceof String) { + // Add it + key.append(":").append(user.getUserName()); //NOI18N + } + + // Is password set? + if (user.getUserEncryptedPassword() instanceof String) { + // Add it, too + key.append(":").append(user.getUserEncryptedPassword()); //NOI18N + } + + // Get contact instance + Contact contact = user.getUserContact(); + + // Is contact set? + if (contact instanceof Contact) { + // Add it, too + key.append(":").append(contact); //NOI18N + + // Is email address set? + if (contact.getContactEmailAddress() instanceof String) { + // Add it, too + key.append(":").append(contact.getContactEmailAddress()); //NOI18N + } + } + } + + // Hash key + String hash = DigestUtils.sha256Hex(key.toString()); + + // Return it + return hash; + } + + /** + * Checks if password from container matches the updatedUser's password + *

+ * @param container Container holding user instance and clear-text + * password + * @param updatedUser Updated user instance from database + *

+ * @return Whether the password matches + */ + public static boolean ifPasswordMatches (final LoginContainer container, final User updatedUser) { + // Validate parameters + if (null == container) { + // Throw NPE + throw new NullPointerException("container is null"); //NOI18N + } else if (null == updatedUser) { + // And again NPE ... + throw new NullPointerException("updatedUser is null"); //NOI18N + } else if (container.getUser() == null) { + // NPE for user in container + throw new NullPointerException("container.user is null"); //NOI18N + } else if (container.getUserPassword() == null) { + // NPE for user password in container + throw new NullPointerException("container.userPassword is null"); //NOI18N + } else if (container.getUserPassword().isEmpty()) { + // Empty password in container + throw new IllegalArgumentException("container.userPassword is empty"); //NOI18N + } + + // Call below method + return ifPasswordMatches(container.getUserPassword(), updatedUser); + } + + /** + * Checks if direct password the updatedUser's password + *

+ * @param clearTextPassword Clear-text (direct) password + * @param updatedUser Updated user instance from database + *

+ * @return Whether the password matches + */ + public static boolean ifPasswordMatches (final String clearTextPassword, final User updatedUser) { + // Validate parameters + if (null == clearTextPassword) { + // Throw NPE + throw new NullPointerException("clearTextPassword is null"); //NOI18N + } else if (clearTextPassword.isEmpty()) { + // NPE for user in container + throw new NullPointerException("clearTextPassword is empty."); //NOI18N + } else if (null == updatedUser) { + // And again NPE ... + throw new NullPointerException("updatedUser is null"); //NOI18N + } + + // First encrypt password + String encryptedPassword = Crypt.crypt(clearTextPassword, updatedUser.getUserEncryptedPassword()); + + // Is it matching? + return encryptedPassword.equals(updatedUser.getUserEncryptedPassword()); + } + + /** + * Checks if password from container matches with from user instance. + *

+ * @param container Container holding user instance and clear-text password + *

+ * @return Whether it maches + */ + public static boolean ifPasswordMatches (final LoginContainer container) { + // Validate parameters + if (null == container) { + // Throw NPE + throw new NullPointerException("container is null"); //NOI18N + } else if (container.getUser() == null) { + // NPE for user in container + throw new NullPointerException("container.user is null"); //NOI18N + } else if (container.getUserPassword() == null) { + // NPE for user password in container + throw new NullPointerException("container.userPassword is null"); //NOI18N + } else if (container.getUserPassword().isEmpty()) { + // Empty password in container + throw new IllegalArgumentException("container.userPassword is empty"); //NOI18N + } + + // Call other method + return ifPasswordMatches(container.getUserPassword(), container.getUser()); + } + + /** + * Checks if the regular expression is found in given string + *

+ * @param pattern Regular expression + * @param str String + *

+ * @return Whether it is found + */ + private static boolean ifRegExFoundInString (final String pattern, final String str) { + // Mus be valid parameters + if (null == pattern) { + // Throw NPE + throw new NullPointerException("pattern is null"); //NOI18N + } else if (pattern.isEmpty()) { + // Is empty + throw new IllegalArgumentException("pattern is empty"); //NOI18N + } else if (null == str) { + // Throw NPE + throw new NullPointerException("str is null"); //NOI18N + } + + // Compile pattern + Pattern r = Pattern.compile(pattern); + + // Get matcher + Matcher m = r.matcher(str); + + // Check if it is found + return m.find(); + } + + /** + * No instance from this class + */ + private UserLoginUtils () { + } + +}