]> git.mxchange.org Git - juser-login-core.git/blob - src/org/mxchange/jusercore/container/login/UserLoginContainer.java
Don't do these checks on login phase as they are only available after login
[juser-login-core.git] / src / org / mxchange / jusercore / container / login / UserLoginContainer.java
1 /*
2  * Copyright (C) 2016 Roland Haeder
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jusercore.container.login;
18
19 import org.mxchange.jusercore.model.user.User;
20
21 /**
22  * A user login container
23  * <p>
24  * @author Roland Haeder<roland@mxchange.org>
25  */
26 public class UserLoginContainer implements LoginContainer {
27
28         /**
29          * Serial number
30          */
31         private static final long serialVersionUID = 158_768_718_689_760_186L;
32
33         /**
34          * User instance
35          */
36         private User user;
37
38         /**
39          * Unencrypted password
40          */
41         private String userPassword;
42
43         /**
44          * Constructor with user instance and unencrypted password
45          * <p>
46          * @param user         User instance
47          * @param userPassword Unencrypted password
48          */
49         public UserLoginContainer (final User user, final String userPassword) {
50                 // Is both set?
51                 if (null == user) {
52                         // Throw NPE
53                         throw new NullPointerException("user is null"); //NOI18N
54                 } else if (null == userPassword) {
55                         // Throw NPE again
56                         throw new NullPointerException("userPassword is null"); //NOI18N
57                 } else if (userPassword.isEmpty()) {
58                         // Empty password
59                         throw new IllegalArgumentException("user password is empty."); //NOI18N
60                 }
61
62                 // Set both
63                 this.user = user;
64                 this.userPassword = userPassword;
65         }
66
67         @Override
68         public User getUser () {
69                 return this.user;
70         }
71
72         @Override
73         public void setUser (final User user) {
74                 this.user = user;
75         }
76
77         @Override
78         public String getUserPassword () {
79                 return this.userPassword;
80         }
81
82         @Override
83         public void setUserPassword (final String userPassword) {
84                 this.userPassword = userPassword;
85         }
86
87 }