From: Roland Haeder Date: Tue, 13 Oct 2015 07:25:34 +0000 (+0200) Subject: added container class for transfering user instance and unencrypted password X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8cea05e149703aea5b712ff88e9a409f164e776c;p=juser-core.git added container class for transfering user instance and unencrypted password 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 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; + } + +}