/**
* Constructor with all fields to set
* <p>
- * @param emailChangeId Email change id
- * @param user User instance
- * @param emailAddress Email address
+ * @param emailChangeId Email change id
+ * @param user User instance
+ * @param emailAddress Email address
* @param emailChangeCreated Timestamp for creation
- * @param emailChangeStatus Email change status
- * @param emailChangeDone When this entry has been done
- * @param emailChangeHash Email change hash
+ * @param emailChangeStatus Email change status
+ * @param emailChangeDone When this entry has been done
+ * @param emailChangeHash Email change hash
*/
public EmailAddressChange (final Long emailChangeId, final User user, final String emailAddress, final Calendar emailChangeCreated, final EmailChangeStatus emailChangeStatus, final Calendar emailChangeDone, final String emailChangeHash) {
// Call other constructor
/**
* Constructor with user and email address
* <p>
- * @param user User instance
+ * @param user User instance
* @param emailAddress Email address
*/
public EmailAddressChange (final User user, final String emailAddress) {
return Objects.equals(this.getEmailChangeUser(), otherEmail.getEmailChangeUser());
}
- @Override
- public int hashCode () {
- int hash = 5;
- hash = 71 * hash + Objects.hashCode(this.getEmailAddress());
- hash = 71 * hash + Objects.hashCode(this.getEmailChangeUser());
- return hash;
- }
-
@Override
public String getEmailAddress () {
return this.emailAddress;
this.emailChangeUser = emailChangeUser;
}
+ @Override
+ public int hashCode () {
+ int hash = 5;
+ hash = 71 * hash + Objects.hashCode(this.getEmailAddress());
+ hash = 71 * hash + Objects.hashCode(this.getEmailChangeUser());
+ return hash;
+ }
+
}
--- /dev/null
+/*
+ * Copyright (C) 2016 Cho-Time GmbH
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.model.user.password_history;
+
+import java.io.Serializable;
+import java.util.Calendar;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A POJI for user password history
+ * <p>
+ * @author Roland Haeder<rhaeder@cho-time.de>
+ */
+public interface PasswordHistory extends Serializable {
+
+ /**
+ * Getter for timestamp this history entry has been created (usually in
+ * EJB).
+ * <p>
+ * @return Timestamp when this history entry has been created
+ */
+ Calendar getUserPasswordHistoryCreated ();
+
+ /**
+ * Setter for timestamp this history entry has been created (usually in
+ * EJB).
+ * <p>
+ * @param userPasswordHistoryCreated Timestamp when this history entry has
+ * been created
+ */
+ void setUserPasswordHistoryCreated (final Calendar userPasswordHistoryCreated);
+
+ /**
+ * Getter for history entry id (primary key)
+ * <p>
+ * @return History entry id (primary key)
+ */
+ Long getUserPasswordHistoryId ();
+
+ /**
+ * Setter for history entry id (primary key)
+ * <p>
+ * @param userPasswordHistoryId History entry id (primary key)
+ */
+ void setUserPasswordHistoryId (final Long userPasswordHistoryId);
+
+ /**
+ * Getter for user's password hash
+ * <p>
+ * @return User's password hash
+ */
+ String getUserPasswordHistoryPasswordHash ();
+
+ /**
+ * Setter for user's password hash
+ * <p>
+ * @param userPasswordHistoryPasswordHash User's password hash
+ */
+ void setUserPasswordHistoryPasswordHash (final String userPasswordHistoryPasswordHash);
+
+ /**
+ * Getter for user instance
+ * <p>
+ * @return User instance
+ */
+ User getUserPasswordHistoryUser ();
+
+ /**
+ * Setter for user instance
+ * <p>
+ * @param userPasswordHistoryUser User instance
+ */
+ void setUserPasswordHistoryUser (final User userPasswordHistoryUser);
+
+ @Override
+ boolean equals (final Object object);
+
+ @Override
+ int hashCode ();
+
+}
--- /dev/null
+/*
+ * Copyright (C) 2016 Cho-Time GmbH
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jusercore.model.user.password_history;
+
+import java.util.Calendar;
+import java.util.Objects;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+import org.mxchange.jusercore.model.user.LoginUser;
+import org.mxchange.jusercore.model.user.User;
+
+/**
+ * A POJO for user password history
+ * <p>
+ * @author Roland Haeder<rhaeder@cho-time.de>
+ */
+@Entity (name = "user_password_history")
+@Table (
+ name = "user_password_history"
+)
+@SuppressWarnings ("PersistenceUnitPresent")
+public class UserPasswordHistory implements PasswordHistory {
+
+ /**
+ * Serial number
+ */
+ @Transient
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Timestamp when this entry has been created
+ */
+ @Basic (optional = false)
+ @Column (name = "history_created", nullable = false, updatable = false)
+ @Temporal (TemporalType.TIMESTAMP)
+ private Calendar userPasswordHistoryCreated;
+
+ /**
+ * Id number (primary key)
+ */
+ @Id
+ @Column (name = "history_id", updatable = false)
+ @GeneratedValue (strategy = GenerationType.IDENTITY)
+ private Long userPasswordHistoryId;
+
+ /**
+ * Password hash being used
+ */
+ @Basic (optional = false)
+ @Column (name = "history_password_hash", nullable = false, updatable = false)
+ private String userPasswordHistoryPasswordHash;
+
+ /**
+ * User instance for this history entry
+ */
+ @JoinColumn (name = "history_user_id", nullable = true, updatable = false)
+ @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH)
+ private User userPasswordHistoryUser;
+
+ /**
+ * Default constructor
+ */
+ public UserPasswordHistory () {
+ }
+
+ /**
+ * Constructor with password hash and user instance
+ * <p>
+ * @param userPasswordHistoryPasswordHash Password hash
+ * @param userPasswordHistoryUser User instance
+ */
+ public UserPasswordHistory (final String userPasswordHistoryPasswordHash, final User userPasswordHistoryUser) {
+ // Set all
+ this.userPasswordHistoryPasswordHash = userPasswordHistoryPasswordHash;
+ this.userPasswordHistoryUser = userPasswordHistoryUser;
+ }
+
+ @Override
+ public boolean equals (final Object object) {
+ if (this == object) {
+ return true;
+ } else if (object == null) {
+ return false;
+ } else if (this.getClass() != object.getClass()) {
+ return false;
+ }
+
+ final PasswordHistory other = (PasswordHistory) object;
+
+ if (!Objects.equals(this.getUserPasswordHistoryPasswordHash(), other.getUserPasswordHistoryPasswordHash())) {
+ return false;
+ } else if (!Objects.equals(this.getUserPasswordHistoryId(), other.getUserPasswordHistoryId())) {
+ return false;
+ } else if (!Objects.equals(this.getUserPasswordHistoryUser(), other.getUserPasswordHistoryUser())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ @SuppressWarnings ("ReturnOfDateField")
+ public Calendar getUserPasswordHistoryCreated () {
+ return this.userPasswordHistoryCreated;
+ }
+
+ @Override
+ @SuppressWarnings ("AssignmentToDateFieldFromParameter")
+ public void setUserPasswordHistoryCreated (final Calendar userPasswordHistoryCreated) {
+ this.userPasswordHistoryCreated = userPasswordHistoryCreated;
+ }
+
+ @Override
+ public Long getUserPasswordHistoryId () {
+ return this.userPasswordHistoryId;
+ }
+
+ @Override
+ public void setUserPasswordHistoryId (final Long userPasswordHistoryId) {
+ this.userPasswordHistoryId = userPasswordHistoryId;
+ }
+
+ @Override
+ public String getUserPasswordHistoryPasswordHash () {
+ return this.userPasswordHistoryPasswordHash;
+ }
+
+ @Override
+ public void setUserPasswordHistoryPasswordHash (final String userPasswordHistoryPasswordHash) {
+ this.userPasswordHistoryPasswordHash = userPasswordHistoryPasswordHash;
+ }
+
+ @Override
+ public User getUserPasswordHistoryUser () {
+ return this.userPasswordHistoryUser;
+ }
+
+ @Override
+ public void setUserPasswordHistoryUser (final User userPasswordHistoryUser) {
+ this.userPasswordHistoryUser = userPasswordHistoryUser;
+ }
+
+ @Override
+ public int hashCode () {
+ int hash = 7;
+
+ hash = 79 * hash + Objects.hashCode(this.getUserPasswordHistoryId());
+ hash = 79 * hash + Objects.hashCode(this.getUserPasswordHistoryPasswordHash());
+ hash = 79 * hash + Objects.hashCode(this.getUserPasswordHistoryUser());
+
+ return hash;
+ }
+
+}