<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
-<project name="juser-core" default="default" basedir=".">
- <description>Builds, tests, and runs the project juser-core.</description>
+<project name="juser-login-core" default="default" basedir=".">
+ <description>Builds, tests, and runs the project juser-login-core.</description>
<import file="nbproject/build-impl.xml"/>
<!--
An example of overriding the target for project execution could look like this:
- <target name="run" depends="juser-core-impl.jar">
+ <target name="run" depends="juser-login-core-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
- cleanup
-->
-<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="juser-core-impl">
+<project xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:jaxrpc="http://www.netbeans.org/ns/j2se-project/jax-rpc" basedir=".." default="default" name="juser-login-core-impl">
<fail message="Please build using Ant 1.8.0 or higher.">
<condition>
<not>
</fileset>
</union>
<taskdef classname="org.testng.TestNGAntTask" classpath="${run.test.classpath}" name="testng"/>
- <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="juser-core" testname="TestNG tests" workingDir="${work.dir}">
+ <testng classfilesetref="test.set" failureProperty="tests.failed" listeners="org.testng.reporters.VerboseReporter" methods="${testng.methods.arg}" mode="${testng.mode}" outputdir="${build.test.results.dir}" suitename="juser-login-core" testname="TestNG tests" workingDir="${work.dir}">
<xmlfileset dir="${build.test.classes.dir}" includes="@{testincludes}"/>
<propertyset>
<propertyref prefix="test-sys-prop."/>
<condition else="-testclass @{testClass}" property="test.class.or.method" value="-methods @{testClass}.@{testMethod}">
<isset property="test.method"/>
</condition>
- <condition else="-suitename juser-core -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
+ <condition else="-suitename juser-login-core -testname @{testClass} ${test.class.or.method}" property="testng.cmd.args" value="@{testClass}">
<matches pattern=".*\.xml" string="@{testClass}"/>
</condition>
<delete dir="${build.test.results.dir}" quiet="true"/>
<delete file="${built-jar.properties}" quiet="true"/>
</target>
<target if="already.built.jar.${basedir}" name="-warn-already-built-jar">
- <echo level="warn" message="Cycle detected: juser-core was already built"/>
+ <echo level="warn" message="Cycle detected: juser-login-core was already built"/>
</target>
<target depends="init,-deps-jar-init" name="deps-jar" unless="no.deps">
<mkdir dir="${build.dir}"/>
<delete file="${built-clean.properties}" quiet="true"/>
</target>
<target if="already.built.clean.${basedir}" name="-warn-already-built-clean">
- <echo level="warn" message="Cycle detected: juser-core was already built"/>
+ <echo level="warn" message="Cycle detected: juser-login-core was already built"/>
</target>
<target depends="init,-deps-clean-init" name="deps-clean" unless="no.deps">
<mkdir dir="${build.dir}"/>
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
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
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
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
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
- <name>juser-core</name>
+ <name>juser-login-core</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jusercore.container.login;
-
-import java.io.Serializable;
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A container for login data
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface LoginContainer extends Serializable {
-
- /**
- * Getter for user instance
- * <p>
- * @return User instance
- */
- User getUser ();
-
- /**
- * Setter for user instance
- * <p>
- * @param user User instance
- */
- void setUser (final User user);
-
- /**
- * Getter for user password
- * <p>
- * @return User password
- */
- String getUserPassword ();
-
- /**
- * Setter for user password
- * <p>
- * @param userPassword User password
- */
- void setUserPassword (final String userPassword);
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jusercore.container.login;
-
-import org.mxchange.jusercore.model.user.User;
-
-/**
- * A user login container
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableUserConfirmedAccountEvent extends Serializable {
-
- /**
- * Getter for user instance
- * <p>
- * @return User instance
- */
- User getConfirmedUser ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableUserLoggedInEvent extends Serializable {
-
- /**
- * Getter for user instance
- * <p>
- * @return User instance
- */
- User getLoggedInUser ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableUserLogoutEvent extends Serializable {
-
- /**
- * Getter for user instance
- * <p>
- * @return User instance
- */
- User getLoggedOutUser ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableUserRegisteredEvent extends Serializable {
-
- /**
- * Getter for user instance
- * <p>
- * @return User instance
- */
- User getRegisteredUser ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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
- * <p>
- * @return User instance
- */
- @Override
- public User getRegisteredUser () {
- return this.registeredUser;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableUserResendLinkAccountEvent extends Serializable {
-
- /**
- * Getter for user instance
- * <p>
- * @return User instance
- */
- User getResendLinkUser ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*\r
- * Copyright (C) 2016, 2017 Roland Häder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jusercore.events.user.add;\r
-\r
-import java.text.MessageFormat;\r
-import org.mxchange.jusercore.model.user.User;\r
-\r
-/**\r
- * An event being fired when the administrator has added a new user account\r
- * <p>\r
- * @author Roland Häder<roland@mxchange.org>\r
- */\r
-public class AdminAddedUserEvent implements ObservableAdminAddedUserEvent {\r
-\r
- /**\r
- * Serial number\r
- */\r
- private static final long serialVersionUID = 14_785_787_174_676_290L;\r
-\r
- /**\r
- * Added user instance\r
- */\r
- private final User addedUser;\r
-\r
- /**\r
- * Constructor with added user instance\r
- * <p>\r
- * @param addedUser Added user instance\r
- */\r
- public AdminAddedUserEvent (final User addedUser) {\r
- // Is the user instance valid?\r
- if (null == addedUser) {\r
- // Throw NPE\r
- throw new NullPointerException("addedUser is null"); //NOI18N\r
- } else if (addedUser.getUserId() == null) {\r
- // Throw NPE again\r
- throw new NullPointerException("addedUser.userId is null"); //NOI18N\r
- } else if (addedUser.getUserId() < 1) {\r
- // Invalid id number\r
- throw new IllegalArgumentException(MessageFormat.format("addedUser.userId={0} is invalid.", addedUser.getUserId())); //NOI18N\r
- }\r
-\r
- // Set it here\r
- this.addedUser = addedUser;\r
- }\r
-\r
- @Override\r
- public User getAddedUser () {\r
- return this.addedUser;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2016, 2017 Roland Häder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jusercore.events.user.add;\r
-\r
-import java.io.Serializable;\r
-import org.mxchange.jusercore.model.user.User;\r
-\r
-/**\r
- * An interface for events being fired when an administrator added a new user\r
- * account.\r
- * <p>\r
- * @author Roland Häder<roland@mxchange.org>\r
- */\r
-public interface ObservableAdminAddedUserEvent extends Serializable {\r
-\r
- /**\r
- * Getter for added user instance\r
- * <p>\r
- * @return Added user instance\r
- */\r
- User getAddedUser ();\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2016, 2017 Roland Häder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jusercore.events.user.delete;\r
-\r
-import java.text.MessageFormat;\r
-import org.mxchange.jusercore.model.user.User;\r
-\r
-/**\r
- * An event being fired when the administrator has deleted a user account\r
- * <p>\r
- * @author Roland Häder<roland@mxchange.org>\r
- */\r
-public class AdminDeletedUserEvent implements ObservableAdminDeletedUserEvent {\r
-\r
- /**\r
- * Serial number\r
- */\r
- private static final long serialVersionUID = 14_785_787_174_676_290L;\r
-\r
- /**\r
- * Deleted user instance\r
- */\r
- private final User deletedUser;\r
-\r
- /**\r
- * Delete reason\r
- */\r
- private final String userDeleteReason;\r
-\r
- /**\r
- * Constructor with deleted user instance\r
- * <p>\r
- * @param deletedUser Deleted user instance\r
- * @param userDeleteReason Delete reason\r
- */\r
- public AdminDeletedUserEvent (final User deletedUser, final String userDeleteReason) {\r
- // Is the user instance valid?\r
- if (null == deletedUser) {\r
- // Throw NPE\r
- throw new NullPointerException("deletedUser is null"); //NOI18N\r
- } else if (deletedUser.getUserId() == null) {\r
- // Throw NPE again\r
- throw new NullPointerException("deletedUser.userId is null"); //NOI18N\r
- } else if (deletedUser.getUserId() < 1) {\r
- // Invalid id number\r
- throw new IllegalArgumentException(MessageFormat.format("deletedUser.userId={0} is invalid.", deletedUser.getUserId())); //NOI18N\r
- }\r
-\r
- // Set it here\r
- this.deletedUser = deletedUser;\r
- this.userDeleteReason = userDeleteReason;\r
- }\r
-\r
- @Override\r
- public User getDeletedUser () {\r
- return this.deletedUser;\r
- }\r
-\r
- @Override\r
- public String getUserDeleteReason () {\r
- return this.userDeleteReason;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2016, 2017 Roland Häder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jusercore.events.user.delete;\r
-\r
-import java.io.Serializable;\r
-import org.mxchange.jusercore.model.user.User;\r
-\r
-/**\r
- * An interface for events being fired when an administrator added a new user\r
- * account.\r
- * <p>\r
- * @author Roland Häder<roland@mxchange.org>\r
- */\r
-public interface ObservableAdminDeletedUserEvent extends Serializable {\r
-\r
- /**\r
- * Getter for deleted user instance\r
- * <p>\r
- * @return Deleted user instance\r
- */\r
- User getDeletedUser ();\r
-\r
- /**\r
- * Getter for user delete reason\r
- * <p>\r
- * @return User delete reason\r
- */\r
- String getUserDeleteReason ();\r
-\r
-}\r
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableAdminLinkedUserEvent extends Serializable {
-
- /**
- * Getter for linked user instance
- * <p>
- * @return linked user instance
- */
- User getLinkedUser ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableAdminLockedUserEvent extends Serializable {
-
- /**
- * Getter for locked user instance
- * <p>
- * @return locked user instance
- */
- User getLockedUser ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableUpdatedUserPasswordEvent extends Serializable {
-
- /**
- * Getter for password history entry
- * <p>
- * @return Password history entry
- */
- PasswordHistory getPasswordHistory ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ObservableAdminUnlockedUserEvent extends Serializable {
-
- /**
- * Getter for unlocked user instance
- * <p>
- * @return Unlocked user instance
- */
- User getUnlockedUser ();
-
-}
+++ /dev/null
-/*\r
- * Copyright (C) 2016, 2017 Roland Häder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jusercore.events.user.update;\r
-\r
-import java.text.MessageFormat;\r
-import org.mxchange.jusercore.model.user.User;\r
-\r
-/**\r
- * An event being fired when the administrator has updated user data\r
- * <p>\r
- * @author Roland Häder<roland@mxchange.org>\r
- */\r
-public class AdminUpdatedUserDataEvent implements ObservableAdminUpdatedUserDataEvent {\r
-\r
- /**\r
- * Serial number\r
- */\r
- private static final long serialVersionUID = 14_785_787_174_676_290L;\r
-\r
- /**\r
- * Updated user instance\r
- */\r
- private final User updatedUser;\r
-\r
- /**\r
- * Constructor with updated user instance\r
- * <p>\r
- * @param updatedUser Updated user instance\r
- */\r
- public AdminUpdatedUserDataEvent (final User updatedUser) {\r
- // Is the user instance valid?\r
- if (null == updatedUser) {\r
- // Throw NPE\r
- throw new NullPointerException("updatedUser is null"); //NOI18N\r
- } else if (updatedUser.getUserId() == null) {\r
- // Throw NPE again\r
- throw new NullPointerException("updatedUser.userId is null"); //NOI18N\r
- } else if (updatedUser.getUserId() < 1) {\r
- // Invalid id number\r
- throw new IllegalArgumentException(MessageFormat.format("updatedUser.userId={0} is invalid.", updatedUser.getUserId())); //NOI18N\r
- }\r
-\r
- // Set it here\r
- this.updatedUser = updatedUser;\r
- }\r
-\r
- @Override\r
- public User getUpdatedUser () {\r
- return this.updatedUser;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2016, 2017 Roland Häder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jusercore.events.user.update;\r
-\r
-import java.io.Serializable;\r
-import org.mxchange.jusercore.model.user.User;\r
-\r
-/**\r
- * An interface for events being fired when an administrator updated user data.\r
- * <p>\r
- * @author Roland Häder<roland@mxchange.org>\r
- */\r
-public interface ObservableAdminUpdatedUserDataEvent extends Serializable {\r
-\r
- /**\r
- * Getter for updated user instance\r
- * <p>\r
- * @return Added user instance\r
- */\r
- User getUpdatedUser ();\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2016, 2017 Roland Häder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jusercore.events.user.update;\r
-\r
-import java.io.Serializable;\r
-import org.mxchange.jusercore.model.user.User;\r
-\r
-/**\r
- * An interface for events being fired when a user updates personal data.\r
- * <p>\r
- * @author Roland Häder<roland@mxchange.org>\r
- */\r
-public interface ObservableUpdatedUserPersonalDataEvent extends Serializable {\r
-\r
- /**\r
- * Getter for updated user instance\r
- * <p>\r
- * @return Added user instance\r
- */\r
- User getUpdatedUser ();\r
-\r
-}\r
+++ /dev/null
-/*\r
- * Copyright (C) 2016, 2017 Roland Häder\r
- *\r
- * This program is free software: you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation, either version 3 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program. If not, see <http://www.gnu.org/licenses/>.\r
- */\r
-package org.mxchange.jusercore.events.user.update;\r
-\r
-import java.text.MessageFormat;\r
-import org.mxchange.jusercore.model.user.User;\r
-\r
-/**\r
- * An event being fired when the user has updated personal data\r
- * <p>\r
- * @author Roland Häder<roland@mxchange.org>\r
- */\r
-public class UpdatedUserPersonalDataEvent implements ObservableUpdatedUserPersonalDataEvent {\r
-\r
- /**\r
- * Serial number\r
- */\r
- private static final long serialVersionUID = 14_785_787_174_676_290L;\r
-\r
- /**\r
- * Updated user instance\r
- */\r
- private final User updatedUser;\r
-\r
- /**\r
- * Constructor with updated user instance\r
- * <p>\r
- * @param updatedUser Updated user instance\r
- */\r
- public UpdatedUserPersonalDataEvent (final User updatedUser) {\r
- // Is the user instance valid?\r
- if (null == updatedUser) {\r
- // Throw NPE\r
- throw new NullPointerException("updatedUser is null"); //NOI18N\r
- } else if (updatedUser.getUserId() == null) {\r
- // Throw NPE again\r
- throw new NullPointerException("updatedUser.userId is null"); //NOI18N\r
- } else if (updatedUser.getUserId() < 1) {\r
- // Invalid id number\r
- throw new IllegalArgumentException(MessageFormat.format("updatedUser.userId={0} is invalid.", updatedUser.getUserId())); //NOI18N\r
- }\r
-\r
- // Set it here\r
- this.updatedUser = updatedUser;\r
- }\r
-\r
- @Override\r
- public User getUpdatedUser () {\r
- return this.updatedUser;\r
- }\r
-\r
-}\r
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jusercore.exceptions;
-
-/**
- * An exception thrown when the user has not entered same email addresses
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class DataRepeatMismatchException extends Exception {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 12_857_813_986_248_156L;
-
- /**
- * Constructor with message
- * <p>
- * @param message Message to show
- */
- public DataRepeatMismatchException (final String message) {
- super(message);
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class EmailAddressAlreadyRegisteredException extends Exception {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 16_435_892_878_271L;
-
- /**
- * Constructor with already registered user instance
- * <p>
- * @param user User instance
- */
- public EmailAddressAlreadyRegisteredException (final User user) {
- // Call super contructor
- super(MessageFormat.format("Email address {0} already registered.", user.getUserContact().getContactEmailAddress())); //NOI18N
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jusercore.exceptions;
-
-import java.text.MessageFormat;
-
-/**
- * An exception thrown when an user email address was not found.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class UserEmailAddressNotFoundException extends Exception {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 50_375_271_856_714_906L;
-
- /**
- * Constructor with email address
- * <p>
- * @param emailAddress Email address
- */
- public UserEmailAddressNotFoundException (final String emailAddress) {
- super(MessageFormat.format("User email address {0} not found.", emailAddress)); //NOI18N
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class UserNameAlreadyRegisteredException extends Exception {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 16_435_892_878_271L;
-
- /**
- * Constructor with already registered user instance
- * <p>
- * @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
- * <p>
- * @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));
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class UserNotFoundException extends Exception {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 42_895_928_956_718_956L;
-
- /**
- * Constructor with already registered user instance
- * <p>
- * @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
- * <p>
- * @param userId User id
- */
- public UserNotFoundException (final Long userId) {
- super(MessageFormat.format("User id {0} not found.", userId)); //NOI18N
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @param user User instance
- */
- public UserPasswordMismatchException (final User user) {
- super(MessageFormat.format("Password for user {0} does not match stored password.", user));
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @param user User instance
- */
- public UserPasswordRepeatMismatchException (final User user) {
- super(MessageFormat.format("Passwords don't match, userId={0}", user.getUserId()));
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class UserStatusConfirmedException extends Exception {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 541_378_578_296_710L;
-
- /**
- * Constructor with already registered user instance
- * <p>
- * @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()));
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class UserStatusLockedException extends Exception {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 438_395_891_288_681L;
-
- /**
- * Constructor with already registered user instance
- * <p>
- * @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()));
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class UserStatusUnconfirmedException extends Exception {
-
- /**
- * Serial number
- */
- private static final long serialVersionUID = 438_395_891_288_681L;
-
- /**
- * Constructor with already registered user instance
- * <p>
- * @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()));
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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).
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface ChangeableEmailAddress extends Serializable {
-
- /**
- * Getter for email change id
- * <p>
- * @return Email change id
- */
- Long getEmailChangeId ();
-
- /**
- * Setter for email change id
- * <p>
- * @param emailChangeId Email change id
- */
- void setEmailChangeId (final Long emailChangeId);
-
- /**
- * Getter for email address to change to
- * <p>
- * @return Email address to change to
- */
- String getEmailAddress ();
-
- /**
- * Setter for email address to change to
- * <p>
- * @param emailAddress Email address to change to
- */
- void setEmailAddress (final String emailAddress);
-
- /**
- * Getter for created "email change" timestamp
- * <p>
- * @return Created "email change" timestamp
- */
- Calendar getEmailChangeCreated ();
-
- /**
- * Setter for created "email change" timestamp
- * <p>
- * @param emailChangeCreated Created "email change" timestamp
- */
- void setEmailChangeCreated (final Calendar emailChangeCreated);
-
- /**
- * Getter for user initiating the email change
- * <p>
- * @return User initiating the email change
- */
- User getEmailChangeUser ();
-
- /**
- * Setter for user initiating the email change
- * <p>
- * @param emailChangeUser User initiating the email change
- */
- void setEmailChangeUser (final User emailChangeUser);
-
- /**
- * Getter for email change done/undone
- * <p>
- * @return Email change done/undone
- */
- Calendar getEmailChangeDone ();
-
- /**
- * Setter for email change done/undone
- * <p>
- * @param emailChangeDone Email change done/undone
- */
- void setEmailChangeDone (final Calendar emailChangeDone);
-
- /**
- * Getter for email change status
- * <p>
- * @return Email change status
- */
- EmailChangeStatus getEmailChangeStatus ();
-
- /**
- * Setter for email change status
- * <p>
- * @param emailChangeStatus Email change status
- */
- void setEmailChangeStatus (final EmailChangeStatus emailChangeStatus);
-
- /**
- * Getter for email change hash
- * <p>
- * @return Email change hash
- */
- String getEmailChangeHash ();
-
- /**
- * Getter for email change hash
- * <p>
- * @param emailChangeHash Email change hash
- */
- void setEmailChangeHash (final String emailChangeHash);
-
- @Override
- boolean equals (final Object object);
-
- @Override
- int hashCode ();
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@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
- * <p>
- * @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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jusercore.model.email_address.status;
-
-import java.io.Serializable;
-
-/**
- * An enumeration for email changing
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @param messageKey Message key (i18n)
- */
- private EmailChangeStatus (final String messageKey) {
- // Set it here
- this.messageKey = messageKey;
- }
-
- /**
- * Output value (for messages)
- * <p>
- * @return the messageKey
- */
- public String getMessageKey () {
- return this.messageKey;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface User extends Serializable {
-
- /**
- * Getter for account status
- * <p>
- * @return Account status
- */
- UserAccountStatus getUserAccountStatus ();
-
- /**
- * Setter for account status
- * <p>
- * @param userStatus Account status
- */
- void setUserAccountStatus (final UserAccountStatus userStatus);
-
- /**
- * Getter for confirmation key
- * <p>
- * @return Confirmation key
- */
- String getUserConfirmKey ();
-
- /**
- * Setter for confirmation key
- * <p>
- * @param userConfirmKey Confirmation key
- */
- void setUserConfirmKey (final String userConfirmKey);
-
- /**
- * Getter for contact instance
- * <p>
- * @return Contact id number
- */
- Contact getUserContact ();
-
- /**
- * Setter for contact instance
- * <p>
- * @param contact Contact instance
- */
- void setUserContact (final Contact contact);
-
- /**
- * Getter for "created" timestamp
- * <p>
- * @return "created" timestamp
- */
- Calendar getUserCreated ();
-
- /**
- * Setter for "created" timestamp
- * <p>
- * @param userCreated "created" timestamp
- */
- void setUserCreated (final Calendar userCreated);
-
- /**
- * Getter for encrypted password
- * <p>
- * @return Encrypted password
- */
- String getUserEncryptedPassword ();
-
- /**
- * Setter for password hash
- * <p>
- * @param userEncryptedPassword Encrypted password
- */
- void setUserEncryptedPassword (final String userEncryptedPassword);
-
- /**
- * Getter for customer id number
- * <p>
- * @return User id number
- */
- Long getUserId ();
-
- /**
- * Settte for customer id number
- * <p>
- * @param customerId User id number
- */
- void setUserId (final Long customerId);
-
- /**
- * Getter for "locked" timestamp
- * <p>
- * @return "locked" timestamp
- */
- Calendar getUserLastLocked ();
-
- /**
- * Getter for "locked" timestamp
- * <p>
- * @param userLocked "locked" timestamp
- */
- void setUserLastLocked (final Calendar userLocked);
-
- /**
- * Getter for reason of last locked
- * <p>
- * @return Reason of last locked
- */
- String getUserLastLockedReason ();
-
- /**
- * Setter for reason of last locked
- * <p>
- * @param lastLockedReason Reason of last locked
- */
- void setUserLastLockedReason (final String lastLockedReason);
-
- /**
- * Getter for user name
- * <p>
- * @return User name
- */
- String getUserName ();
-
- /**
- * Setter for user name
- * <p>
- * @param userName User name
- */
- void setUserName (final String userName);
-
- /**
- * Getter for public user profile flag
- * <p>
- * @return Whether the user has a public profile
- */
- ProfileMode getUserProfileMode ();
-
- /**
- * Setter for public user profile flag
- * <p>
- * @param userPublicProfile Whether the user has a public profile
- */
- void setUserProfileMode (final ProfileMode userPublicProfile);
-
- /**
- * Getter for updated timestamp
- * <p>
- * @return Updated timestamp
- */
- Calendar getUserUpdated ();
-
- /**
- * Setter for updated timestamp
- * <p>
- * @param userUpdated Updated timestamp
- */
- void setUserUpdated (final Calendar userUpdated);
-
- /**
- * Getter for user's locale
- * <p>
- * @return User's locale
- */
- Locale getUserLocale ();
-
- /**
- * Setteror user's locale
- * <p>
- * @param userLocale User's locale
- */
- void setUserLocale (final Locale userLocale);
-
- /**
- * Getter for flag if user needs to change password
- * <p>
- * @return Flag if user needs to change password
- */
- Boolean getUserMustChangePassword ();
-
- /**
- * Setter for flag if user needs to change password
- * <p>
- * @param userMustChangePassword Flag if user needs to change password
- */
- void setUserMustChangePassword (final Boolean userMustChangePassword);
-
- @Override
- boolean equals (final Object object);
-
- @Override
- int hashCode ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @param password Clear text password
- * <p>
- * @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
- * <p>
- * @param password Clear-text password
- * <p>
- * @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
- * <p>
- * @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
- * <p>
- * @param length Length of the password
- * <p>
- * @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
- * <p>
- * @param userPassword User password to be hashed
- * <p>
- * @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
- * <p>
- * @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.
- * <p>
- * @param user User instance to use as additional entropy source
- * <p>
- * @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.
- * <p>
- * @param user User instance to get all fields from
- * <p>
- * @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
- * <p>
- * @param user User instance
- * @param calendar Calendar instance
- * <p>
- * @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
- * <p>
- * @param container Container holding user instance and clear-text
- * password
- * @param updatedUser Updated user instance from database
- * <p>
- * @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
- * <p>
- * @param clearTextPassword Clear-text (direct) password
- * @param updatedUser Updated user instance from database
- * <p>
- * @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.
- * <p>
- * @param container Container holding user instance and clear-text password
- * <p>
- * @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
- * <p>
- * @param pattern Regular expression
- * @param str String
- * <p>
- * @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 () {
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public interface PasswordHistory extends Serializable {
-
- /**
- * Getter for timestamp this history entry has been created (usually in
- * EJB).
- * <p>
- * @return Timestamp when this history entry has been created
- */
- Calendar getUserPasswordHistoryCreated ();
-
- /**
- * Setter for timestamp this history entry has been created (usually in
- * EJB).
- * <p>
- * @param userPasswordHistoryCreated Timestamp when this history entry has
- * been created
- */
- void setUserPasswordHistoryCreated (final Calendar userPasswordHistoryCreated);
-
- /**
- * Getter for history entry id (primary key)
- * <p>
- * @return History entry id (primary key)
- */
- Long getUserPasswordHistoryId ();
-
- /**
- * Setter for history entry id (primary key)
- * <p>
- * @param userPasswordHistoryId History entry id (primary key)
- */
- void setUserPasswordHistoryId (final Long userPasswordHistoryId);
-
- /**
- * Getter for user's password hash
- * <p>
- * @return User's password hash
- */
- String getUserPasswordHistoryPasswordHash ();
-
- /**
- * Setter for user's password hash
- * <p>
- * @param userPasswordHistoryPasswordHash User's password hash
- */
- void setUserPasswordHistoryPasswordHash (final String userPasswordHistoryPasswordHash);
-
- /**
- * Getter for user instance
- * <p>
- * @return User instance
- */
- User getUserPasswordHistoryUser ();
-
- /**
- * Setter for user instance
- * <p>
- * @param userPasswordHistoryUser User instance
- */
- void setUserPasswordHistoryUser (final User userPasswordHistoryUser);
-
- @Override
- boolean equals (final Object object);
-
- @Override
- int hashCode ();
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-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
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-@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
- * <p>
- * @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;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jusercore.model.user.profilemodes;
-
-import java.io.Serializable;
-
-/**
- * User profile modes
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @param messageKey Message key
- */
- private ProfileMode (final String messageKey) {
- this.messageKey = messageKey;
- }
-
- /**
- * Getter for message key (i18n)
- * <p>
- * @return Message key
- */
- public String getMessageKey () {
- return this.messageKey;
- }
-
-}
+++ /dev/null
-/*
- * 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 <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jusercore.model.user.status;
-
-import java.io.Serializable;
-
-/**
- * An enumeration for user's account status like confirmed, locked, etc.
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-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
- * <p>
- * @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
- * <p>
- * @return Message key (i18n)
- */
- public String getMessageKey () {
- return this.messageKey;
- }
-
- /**
- * Getter for CSS style class
- * <p>
- * @return CSS style class
- */
- public String getStyleClass () {
- return this.styleClass;
- }
-
-}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.juserlogincore.container.login;
+
+import java.io.Serializable;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A container for login data
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface LoginContainer extends Serializable {
+
+ /**
+ * Getter for user instance
+ * <p>
+ * @return User instance
+ */
+ User getUser ();
+
+ /**
+ * Setter for user instance
+ * <p>
+ * @param user User instance
+ */
+ void setUser (final User user);
+
+ /**
+ * Getter for user password
+ * <p>
+ * @return User password
+ */
+ String getUserPassword ();
+
+ /**
+ * Setter for user password
+ * <p>
+ * @param userPassword User password
+ */
+ void setUserPassword (final String userPassword);
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.juserlogincore.container.login;
+
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A user login container
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+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
+ * <p>
+ * @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;
+ }
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableUserConfirmedAccountEvent extends Serializable {
+
+ /**
+ * Getter for user instance
+ * <p>
+ * @return User instance
+ */
+ User getConfirmedUser ();
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+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
+ * <p>
+ * @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;
+ }
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableUserLoggedInEvent extends Serializable {
+
+ /**
+ * Getter for user instance
+ * <p>
+ * @return User instance
+ */
+ User getLoggedInUser ();
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+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
+ * <p>
+ * @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;
+ }
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableUserLogoutEvent extends Serializable {
+
+ /**
+ * Getter for user instance
+ * <p>
+ * @return User instance
+ */
+ User getLoggedOutUser ();
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+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
+ * <p>
+ * @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;
+ }
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableUserRegisteredEvent extends Serializable {
+
+ /**
+ * Getter for user instance
+ * <p>
+ * @return User instance
+ */
+ User getRegisteredUser ();
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+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
+ * <p>
+ * @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
+ * <p>
+ * @return User instance
+ */
+ @Override
+ public User getRegisteredUser () {
+ return this.registeredUser;
+ }
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface ObservableUserResendLinkAccountEvent extends Serializable {
+
+ /**
+ * Getter for user instance
+ * <p>
+ * @return User instance
+ */
+ User getResendLinkUser ();
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+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
+ * <p>
+ * @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;
+ }
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class UserNotFoundException extends Exception {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 42_895_928_956_718_956L;
+
+ /**
+ * Constructor with already registered user instance
+ * <p>
+ * @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
+ * <p>
+ * @param userId User id
+ */
+ public UserNotFoundException (final Long userId) {
+ super(MessageFormat.format("User id {0} not found.", userId)); //NOI18N
+ }
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+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
+ * <p>
+ * @param user User instance
+ */
+ public UserPasswordMismatchException (final User user) {
+ super(MessageFormat.format("Password for user {0} does not match stored password.", user));
+ }
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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.
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+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
+ * <p>
+ * @param user User instance
+ */
+ public UserPasswordRepeatMismatchException (final User user) {
+ super(MessageFormat.format("Passwords don't match, userId={0}", user.getUserId()));
+ }
+
+}
--- /dev/null
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+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
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+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
+ * <p>
+ * @param password Clear text password
+ * <p>
+ * @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
+ * <p>
+ * @param password Clear-text password
+ * <p>
+ * @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
+ * <p>
+ * @param length Length of the password
+ * <p>
+ * @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
+ * <p>
+ * @param userPassword User password to be hashed
+ * <p>
+ * @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.
+ * <p>
+ * @param user User instance to use as additional entropy source
+ * <p>
+ * @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
+ * <p>
+ * @param container Container holding user instance and clear-text
+ * password
+ * @param updatedUser Updated user instance from database
+ * <p>
+ * @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
+ * <p>
+ * @param clearTextPassword Clear-text (direct) password
+ * @param updatedUser Updated user instance from database
+ * <p>
+ * @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.
+ * <p>
+ * @param container Container holding user instance and clear-text password
+ * <p>
+ * @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
+ * <p>
+ * @param pattern Regular expression
+ * @param str String
+ * <p>
+ * @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 () {
+ }
+
+}