/** * Copyright (c) 2011-2014, OpenIoT * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public * License version 2.1 as published by the Free Software Foundation * (the "LGPL"). If you do not alter this * notice, a recipient may use your version of this file under the LGPL. * * You should have received a copy of the LGPL along with this library * in the file COPYING-LGPL-2.1; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY * OF ANY KIND, either express or implied. See the LGPL for * the specific language governing rights and limitations. * * Contact: OpenIoT mailto: info@openiot.eu */ package org.openiot.lsm.security.oauth.mgmt; import java.util.ArrayList; import java.util.List; public class User implements java.io.Serializable { private static final long serialVersionUID = 1205297655561481894L; private long id = -1; private String username; private String email; private String name; private String password; private boolean approved = false; private List<Role> roles; public User() { roles = new ArrayList<>(); } public long getId() { return id; } public void setId(long id) { this.id = id; } public List<Role> getRoles() { return roles; } public void setRoles(List<Role> roles) { this.roles = roles; } public void addRole(Role role) { if (roles == null) roles = new ArrayList<Role>(); if (!roles.contains(role)) roles.add(role); } public String getUsername() { return username; } public void setUsername(String username) { if (username == null) throw new IllegalArgumentException("username cannot be null"); this.username = username; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public boolean isApproved() { return approved; } public void setApproved(boolean approved) { this.approved = approved; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((username == null) ? 0 : username.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; User other = (User) obj; if (username == null) { if (other.username != null) return false; } else if (!username.equals(other.username)) return false; return true; } @Override public String toString() { return "User [username=" + username + ", email=" + email + ", name=" + name + ", approved=" + approved + "]"; } }