From 8cea05e149703aea5b712ff88e9a409f164e776c Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 13 Oct 2015 09:25:34 +0200 Subject: [PATCH] =?utf8?q?added=20container=20class=20for=20transfering=20?= =?utf8?q?user=20instance=20and=20unencrypted=20password=20Signed-off-by:R?= =?utf8?q?oland=20H=C3=A4der=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../container/login/LoginContainer.java | 56 ++++++++++++ .../container/login/UserLoginContainer.java | 87 +++++++++++++++++++ 2 files changed, 143 insertions(+) create mode 100644 src/org/mxchange/jusercore/container/login/LoginContainer.java create mode 100644 src/org/mxchange/jusercore/container/login/UserLoginContainer.java diff --git a/src/org/mxchange/jusercore/container/login/LoginContainer.java b/src/org/mxchange/jusercore/container/login/LoginContainer.java new file mode 100644 index 0000000..1d0d320 --- /dev/null +++ b/src/org/mxchange/jusercore/container/login/LoginContainer.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * 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 Haeder + */ +public interface LoginContainer extends Serializable { + + /** + * Getter for user instance + *

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

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

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

+ * @param userPassword User password + */ + public 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 new file mode 100644 index 0000000..a8220d6 --- /dev/null +++ b/src/org/mxchange/jusercore/container/login/UserLoginContainer.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2015 Roland Haeder + * + * 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 Haeder + */ +public class UserLoginContainer implements LoginContainer { + + /** + * Serial number + */ + private static final long serialVersionUID = 158_768_718_689_760_186L; + + /** + * User instance + */ + private User user; + + /** + * Unencrypted password + */ + private String userPassword; + + /** + * Constructot with user instance and unencrypted password + *

+ * @param user User instance + * @param userPassword Unencrypted password + */ + public UserLoginContainer (final User user, final String userPassword) { + // Is both set? + if (null == user) { + // Throw NPE + throw new NullPointerException("user is null"); + } else if (null == userPassword) { + // Throw NPE again + throw new NullPointerException("userPassword is null"); + } else if (userPassword.isEmpty()) { + // Empty password + throw new IllegalArgumentException("user password is empty."); + } + + // 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; + } + +} -- 2.39.5