From: Roland Häder Date: Wed, 12 Jul 2017 19:00:05 +0000 (+0200) Subject: swapped out to new project juser-login-core X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d28268aa20c1ca1f002d6b895b54b914946863df;p=juser-core.git swapped out to new project juser-login-core Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jusercore/container/login/LoginContainer.java b/src/org/mxchange/jusercore/container/login/LoginContainer.java deleted file mode 100644 index dfbc476..0000000 --- a/src/org/mxchange/jusercore/container/login/LoginContainer.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.container.login; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * A container for login data - *

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

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

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

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

- * @param userPassword User password - */ - void setUserPassword (final String userPassword); - -} diff --git a/src/org/mxchange/jusercore/container/login/UserLoginContainer.java b/src/org/mxchange/jusercore/container/login/UserLoginContainer.java deleted file mode 100644 index 1077a15..0000000 --- a/src/org/mxchange/jusercore/container/login/UserLoginContainer.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.container.login; - -import org.mxchange.jusercore.model.user.User; - -/** - * A user login container - *

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

- * @param user User instance - * @param userPassword Clear-text password - */ - public UserLoginContainer (final User user, final String userPassword) { - // Is both set? - if (null == user) { - // Throw NPE - throw new NullPointerException("user is null"); //NOI18N - } else if (null == userPassword) { - // Throw NPE again - throw new NullPointerException("userPassword is null"); //NOI18N - } else if (userPassword.isEmpty()) { - // Empty password - throw new IllegalArgumentException("user password is empty."); //NOI18N - } - - // Set both - this.user = user; - this.userPassword = userPassword; - } - - @Override - public User getUser () { - return this.user; - } - - @Override - public void setUser (final User user) { - this.user = user; - } - - @Override - public String getUserPassword () { - return this.userPassword; - } - - @Override - public void setUserPassword (final String userPassword) { - this.userPassword = userPassword; - } - -} diff --git a/src/org/mxchange/jusercore/events/confirmation/ObservableUserConfirmedAccountEvent.java b/src/org/mxchange/jusercore/events/confirmation/ObservableUserConfirmedAccountEvent.java deleted file mode 100644 index d96067b..0000000 --- a/src/org/mxchange/jusercore/events/confirmation/ObservableUserConfirmedAccountEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.confirmation; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An event interface, fired if a new user has registered - *

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

- * @return User instance - */ - User getConfirmedUser (); - -} diff --git a/src/org/mxchange/jusercore/events/confirmation/UserConfirmedAccountEvent.java b/src/org/mxchange/jusercore/events/confirmation/UserConfirmedAccountEvent.java deleted file mode 100644 index f1771fc..0000000 --- a/src/org/mxchange/jusercore/events/confirmation/UserConfirmedAccountEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.confirmation; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event, fired if a new confirmedUser has confirmed - *

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

- * @param confirmedUser Newly confirmed confirmedUser - */ - public UserConfirmedAccountEvent (final User confirmedUser) { - // Is the confirmed user instance valid? - if (null == confirmedUser) { - // Throw NPE - throw new NullPointerException("confirmedUser is null"); //NOI18N - } else if (confirmedUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("confirmedUser.userId is null"); //NOI18N - } else if (confirmedUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("confirmedUser.userId={0} is invalid.", confirmedUser.getUserId())); //NOI18N - } - - // Set it here - this.confirmedUser = confirmedUser; - } - - @Override - public User getConfirmedUser () { - return this.confirmedUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/login/ObservableUserLoggedInEvent.java b/src/org/mxchange/jusercore/events/login/ObservableUserLoggedInEvent.java deleted file mode 100644 index ba77094..0000000 --- a/src/org/mxchange/jusercore/events/login/ObservableUserLoggedInEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.login; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events after the user has logged in - *

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

- * @return User instance - */ - User getLoggedInUser (); - -} diff --git a/src/org/mxchange/jusercore/events/login/UserLoggedInEvent.java b/src/org/mxchange/jusercore/events/login/UserLoggedInEvent.java deleted file mode 100644 index b69e302..0000000 --- a/src/org/mxchange/jusercore/events/login/UserLoggedInEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.login; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * This event is fired when the loggedInUser has logged in - *

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

- * @param loggedInUser Updated user instance - */ - public UserLoggedInEvent (final User loggedInUser) { - // Is the logged-in user instance valid? - if (null == loggedInUser) { - // Throw NPE - throw new NullPointerException("loggedInUser is null"); //NOI18N - } else if (loggedInUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("loggedInUser.userId is null"); //NOI18N - } else if (loggedInUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("loggedInUser.userId={0} is invalid.", loggedInUser.getUserId())); //NOI18N - } - - // Set loggedInUser - this.loggedInUser = loggedInUser; - } - - @Override - public User getLoggedInUser () { - return this.loggedInUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/logout/ObservableUserLogoutEvent.java b/src/org/mxchange/jusercore/events/logout/ObservableUserLogoutEvent.java deleted file mode 100644 index 32fc8c8..0000000 --- a/src/org/mxchange/jusercore/events/logout/ObservableUserLogoutEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.logout; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An interface for events after the user has logged in - *

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

- * @return User instance - */ - User getLoggedOutUser (); - -} diff --git a/src/org/mxchange/jusercore/events/logout/UserLogoutEvent.java b/src/org/mxchange/jusercore/events/logout/UserLogoutEvent.java deleted file mode 100644 index 9f80042..0000000 --- a/src/org/mxchange/jusercore/events/logout/UserLogoutEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.logout; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * This event is fired when the loggedOutUser has logged in - *

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

- * @param loggedOutUser Updated loggedOutUser instance - */ - public UserLogoutEvent (final User loggedOutUser) { - // Is the logged-in user instance valid? - if (null == loggedOutUser) { - // Throw NPE - throw new NullPointerException("loggedOutUser is null"); //NOI18N - } else if (loggedOutUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("loggedOutUser.userId is null"); //NOI18N - } else if (loggedOutUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("loggedOutUser.userId={0} is invalid.", loggedOutUser.getUserId())); //NOI18N - } - - // Set loggedOutUser - this.loggedOutUser = loggedOutUser; - } - - @Override - public User getLoggedOutUser () { - return this.loggedOutUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/registration/ObservableUserRegisteredEvent.java b/src/org/mxchange/jusercore/events/registration/ObservableUserRegisteredEvent.java deleted file mode 100644 index cd8af04..0000000 --- a/src/org/mxchange/jusercore/events/registration/ObservableUserRegisteredEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.registration; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An event interface, fired if a new user has registered - *

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

- * @return User instance - */ - User getRegisteredUser (); - -} diff --git a/src/org/mxchange/jusercore/events/registration/UserRegisteredEvent.java b/src/org/mxchange/jusercore/events/registration/UserRegisteredEvent.java deleted file mode 100644 index dffb067..0000000 --- a/src/org/mxchange/jusercore/events/registration/UserRegisteredEvent.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.registration; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event, fired if a new registeredUser has registered - *

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

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

- * @return User instance - */ - @Override - public User getRegisteredUser () { - return this.registeredUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/resendlink/ObservableUserResendLinkAccountEvent.java b/src/org/mxchange/jusercore/events/resendlink/ObservableUserResendLinkAccountEvent.java deleted file mode 100644 index 3aa8450..0000000 --- a/src/org/mxchange/jusercore/events/resendlink/ObservableUserResendLinkAccountEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.resendlink; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.User; - -/** - * An event interface, fired if a user has resend confirmation link - *

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

- * @return User instance - */ - User getResendLinkUser (); - -} diff --git a/src/org/mxchange/jusercore/events/resendlink/UserResendLinkAccountEvent.java b/src/org/mxchange/jusercore/events/resendlink/UserResendLinkAccountEvent.java deleted file mode 100644 index 3916936..0000000 --- a/src/org/mxchange/jusercore/events/resendlink/UserResendLinkAccountEvent.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.resendlink; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An event, fired if a user has resend confirmation link - *

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

- * @param resendLinkUser User resend confirmation link - */ - public UserResendLinkAccountEvent (final User resendLinkUser) { - // Is the confirmed user instance valid? - if (null == resendLinkUser) { - // Throw NPE - throw new NullPointerException("resendLinkUser is null"); //NOI18N - } else if (resendLinkUser.getUserId() == null) { - // Throw NPE again - throw new NullPointerException("resendLinkUser.userId is null"); //NOI18N - } else if (resendLinkUser.getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("resendLinkUser.userId={0} is invalid.", resendLinkUser.getUserId())); //NOI18N - } - - // Set it here - this.resendLinkUser = resendLinkUser; - } - - @Override - public User getResendLinkUser () { - return this.resendLinkUser; - } - -} diff --git a/src/org/mxchange/jusercore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java b/src/org/mxchange/jusercore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java deleted file mode 100644 index 6ae3c4f..0000000 --- a/src/org/mxchange/jusercore/events/user/password_change/ObservableUpdatedUserPasswordEvent.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.password_change; - -import java.io.Serializable; -import org.mxchange.jusercore.model.user.password_history.PasswordHistory; - -/** - * An interface for events being fired when a user updates personal data. - *

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

- * @return Password history entry - */ - PasswordHistory getPasswordHistory (); - -} diff --git a/src/org/mxchange/jusercore/events/user/password_change/UpdatedUserPasswordEvent.java b/src/org/mxchange/jusercore/events/user/password_change/UpdatedUserPasswordEvent.java deleted file mode 100644 index 42a5524..0000000 --- a/src/org/mxchange/jusercore/events/user/password_change/UpdatedUserPasswordEvent.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.events.user.password_change; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.password_history.PasswordHistory; - -/** - * An event being fired when the user has updated personal data - *

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

- * @param passwordHistory Updated user instance - */ - public UpdatedUserPasswordEvent (final PasswordHistory passwordHistory) { - // Is the user instance valid? - if (null == passwordHistory) { - // Throw NPE - throw new NullPointerException("passwordHistory is null"); //NOI18N - } else if (passwordHistory.getUserPasswordHistoryUser() == null) { - // Throw NPE again - throw new NullPointerException("passwordHistory.userPasswordHistoryUser is null"); //NOI18N - } else if (passwordHistory.getUserPasswordHistoryUser().getUserId() == null) { - // Throw NPE again - throw new NullPointerException("passwordHistory.userPasswordHistoryUser.userId is null"); //NOI18N - } else if (passwordHistory.getUserPasswordHistoryUser().getUserId() < 1) { - // Invalid id number - throw new IllegalArgumentException(MessageFormat.format("passwordHistory.userPasswordHistoryUser.userId={0} is invalid.", passwordHistory.getUserPasswordHistoryUser().getUserId())); //NOI18N - } - - // Set it here - this.passwordHistory = passwordHistory; - } - - @Override - public PasswordHistory getPasswordHistory () { - return this.passwordHistory; - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/UserPasswordMismatchException.java b/src/org/mxchange/jusercore/exceptions/UserPasswordMismatchException.java deleted file mode 100644 index 58f7a94..0000000 --- a/src/org/mxchange/jusercore/exceptions/UserPasswordMismatchException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An exception thrown when the entered password did not match the stored - * password. - *

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

- * @param user User instance - */ - public UserPasswordMismatchException (final User user) { - super(MessageFormat.format("Password for user {0} does not match stored password.", user)); - } - -} diff --git a/src/org/mxchange/jusercore/exceptions/UserPasswordRepeatMismatchException.java b/src/org/mxchange/jusercore/exceptions/UserPasswordRepeatMismatchException.java deleted file mode 100644 index 41f5bb0..0000000 --- a/src/org/mxchange/jusercore/exceptions/UserPasswordRepeatMismatchException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.mxchange.jusercore.exceptions; - -import java.text.MessageFormat; -import org.mxchange.jusercore.model.user.User; - -/** - * An exception thrown when the entered password did not match the stored - * password. - *

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

- * @param user User instance - */ - public UserPasswordRepeatMismatchException (final User user) { - super(MessageFormat.format("Passwords don't match, userId={0}", user.getUserId())); - } - -} diff --git a/src/org/mxchange/jusercore/model/user/UserUtils.java b/src/org/mxchange/jusercore/model/user/UserUtils.java index 3562caa..13a643b 100644 --- a/src/org/mxchange/jusercore/model/user/UserUtils.java +++ b/src/org/mxchange/jusercore/model/user/UserUtils.java @@ -23,13 +23,8 @@ 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 @@ -89,96 +84,6 @@ public class UserUtils implements Serializable { UserUtils.PASSWORD_ALPHABET_PARTS[3]; } - /** - * Calculates entropy value for given password, higher means better. This - * method is based on - * http://stackoverflow.com/questions/14591701/how-to-check-password-strength-in-vaadin - *

- * @param password Clear text password - *

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

- * @param password Clear-text password - *

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

@@ -215,75 +120,6 @@ public class UserUtils implements Serializable { targetUser.setUserMustChangePassword(sourceUser.getUserMustChangePassword()); } - /** - * Creates a pseudo-random password with given length - *

- * @param length Length of the password - *

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

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

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

@@ -297,61 +133,6 @@ public class UserUtils implements Serializable { return userName; } - /** - * Generate a key suitable for confirmation. This is basicly a large and - * strong hash with a lop entropy. - *

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

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

@@ -483,124 +264,6 @@ public class UserUtils implements Serializable { return dateTime; } - /** - * Checks if password from container matches the updatedUser's password - *

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

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

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

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

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

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

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

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