001 /****************************************************************
002 * Licensed to the Apache Software Foundation (ASF) under one *
003 * or more contributor license agreements. See the NOTICE file *
004 * distributed with this work for additional information *
005 * regarding copyright ownership. The ASF licenses this file *
006 * to you under the Apache License, Version 2.0 (the *
007 * "License"); you may not use this file except in compliance *
008 * with the License. You may obtain a copy of the License at *
009 * *
010 * http://www.apache.org/licenses/LICENSE-2.0 *
011 * *
012 * Unless required by applicable law or agreed to in writing, *
013 * software distributed under the License is distributed on an *
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
015 * KIND, either express or implied. See the License for the *
016 * specific language governing permissions and limitations *
017 * under the License. *
018 ****************************************************************/
019
020 package org.apache.hupa.shared.data;
021
022 import java.io.Serializable;
023 import java.util.Date;
024
025 /**
026 * User which will get used for login to the IMAP and SMTP account
027 *
028 *
029 */
030 public class User implements Serializable{
031
032 private static final long serialVersionUID = -573674209289821920L;
033 private String name;
034 private String password;
035 private Date loginDate;
036 private boolean auth;
037 private Settings settings;
038
039
040 /**
041 * The name of the User
042 *
043 * @param name
044 */
045 public void setName(String name) {
046 this.name = name;
047 }
048
049 /**
050 * Get name of the User
051 *
052 * @return name
053 */
054 public String getName() {
055 return name;
056 }
057
058 /**
059 * Set the Password of the User
060 *
061 * @param password
062 */
063 public void setPassword(String password) {
064 this.password = password;
065 }
066
067 /**
068 * Get the Password of the User
069 *
070 * @return password
071 */
072 public String getPassword() {
073 return password;
074 }
075
076 /*
077 * (non-Javadoc)
078 * @see java.lang.Object#toString()
079 */
080 public String toString() {
081 return getName();
082 }
083
084 /*
085 * (non-Javadoc)
086 * @see java.lang.Object#equals(java.lang.Object)
087 */
088 public boolean equals(Object object) {
089 if (object instanceof User) {
090 if (((User) object).getName().equals(getName())) {
091 return true;
092 }
093 }
094 return false;
095 }
096
097 public int hashCode() {
098 return getName().hashCode();
099 }
100 /**
101 * Get the Date on which the User was logged in the last time
102 *
103 * @return loginDate
104 */
105 public Date getLoginDate() {
106 return loginDate;
107 }
108
109 /**
110 * Set if the User was successful authenticated
111 *
112 * @param auth
113 */
114 public void setAuthenticated(boolean auth) {
115 this.auth = auth;
116 if (auth) {
117 loginDate = new Date();
118 }
119 }
120
121 /**
122 * Get if the User was successful authenticated
123 *
124 * @return auth
125 */
126 public boolean getAuthenticated() {
127 return auth;
128 }
129
130 public void setSettings(Settings settings) {
131 this.settings = settings;
132 }
133
134 public Settings getSettings() {
135 return settings;
136 }
137
138
139 }