2 * Copyright (C) 2016 Roland Haeder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jusercore.container.login;
19 import java.text.MessageFormat;
20 import org.mxchange.jusercore.model.user.User;
23 * A user login container
25 * @author Roland Haeder<roland@mxchange.org>
27 public class UserLoginContainer implements LoginContainer {
32 private static final long serialVersionUID = 158_768_718_689_760_186L;
40 * Unencrypted password
42 private String userPassword;
45 * Constructor with user instance and unencrypted password
47 * @param user User instance
48 * @param userPassword Unencrypted password
50 public UserLoginContainer (final User user, final String userPassword) {
54 throw new NullPointerException("user is null"); //NOI18N
55 } else if (user.getUserId() == null) {
57 throw new NullPointerException("user.userId is null"); //NOI18N
58 } else if (user.getUserId() < 1) {
60 throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
61 } else if (user.getUserContact() == null) {
62 // Throw NPE again ...
63 throw new NullPointerException("user.userContact is null"); //NOI18N
64 } else if (user.getUserContact().getContactId() == null) {
65 // Throw NPE again ...
66 throw new NullPointerException("user.userContact.contactId is null"); //NOI18N
67 } else if (user.getUserContact().getContactId() < 1) {
69 throw new IllegalArgumentException(MessageFormat.format("user.userContact.contactId={0} is not valid", user.getUserContact().getContactId())); //NOI18N
70 } else if (null == userPassword) {
72 throw new NullPointerException("userPassword is null"); //NOI18N
73 } else if (userPassword.isEmpty()) {
75 throw new IllegalArgumentException("user password is empty."); //NOI18N
80 this.userPassword = userPassword;
84 public User getUser () {
89 public void setUser (final User user) {
94 public String getUserPassword () {
95 return this.userPassword;
99 public void setUserPassword (final String userPassword) {
100 this.userPassword = userPassword;