1 21 22 package com.jaspersoft.jasperserver.api.metadata.user.domain.client; 23 24 import java.io.Serializable ; 25 import java.util.HashSet ; 26 import java.util.List ; 27 import java.util.Set ; 28 29 import org.apache.commons.collections.CollectionUtils; 30 import org.apache.commons.collections.Predicate; 31 import org.apache.commons.lang.builder.EqualsBuilder; 32 import org.apache.commons.lang.builder.HashCodeBuilder; 33 import org.apache.commons.lang.builder.ToStringBuilder; 34 35 import com.jaspersoft.jasperserver.api.metadata.user.domain.Role; 36 import com.jaspersoft.jasperserver.api.metadata.user.domain.User; 37 38 42 public class UserImpl implements User, Serializable { 43 44 private Set roleSet = new HashSet (); 45 private String username = null; 46 private String fullName = null; 47 private String password = null; 48 private String emailAddress = null; 49 private boolean externallyDefined = false; 50 private boolean enabled = false; 51 52 58 public String getUsername() { 59 return username; 60 } 61 62 public void setUsername(String newUsername) { 63 if (newUsername == null || newUsername.trim().length() == 0) { 64 throw new RuntimeException ("No user name"); 65 } 66 username = newUsername; 67 } 68 69 75 public String getFullName() { 76 return fullName; 77 } 78 79 82 public void setFullName(String fullName) { 83 this.fullName = fullName; 84 } 85 86 90 public String getPassword() { 91 return password; 92 } 93 94 97 public void setPassword(String password) { 98 this.password = password; 99 } 100 101 104 public String getEmailAddress() { 105 return emailAddress; 106 } 107 108 111 public void setEmailAddress(String emailAddress) { 112 this.emailAddress = emailAddress; 113 } 114 115 119 public Set getRoles() { 120 return roleSet; 121 } 122 123 public void setRoles(Set newRoleSet) { 124 roleSet = newRoleSet; 125 } 126 127 public void addRole(final Role newRole) { 128 140 if (newRole != null && !getRoles().contains(newRole)) { 141 getRoles().add(newRole); 142 } 144 } 145 146 public void removeRole(final Role removedRole) { 147 getRoles().remove(removedRole); 148 } 150 151 154 public List getAttributes() { 155 return null; 157 } 158 159 162 public boolean isExternallyDefined() { 163 return externallyDefined; 164 } 165 166 169 public void setExternallyDefined(boolean externallyDefined) { 170 this.externallyDefined = externallyDefined; 171 } 172 173 177 public boolean isEnabled() { 178 return enabled; 179 } 180 181 184 public void setEnabled(boolean enabled) { 185 this.enabled = enabled; 186 } 187 188 public String toString() { 189 return new ToStringBuilder(this) 190 .append("username", getUsername()) 191 .toString(); 192 } 193 194 public boolean equals(Object other) { 195 if ( !(other instanceof UserImpl) ) return false; 196 UserImpl castOther = (UserImpl) other; 197 return new EqualsBuilder() 198 .append(this.getUsername(), castOther.getUsername()) 199 .isEquals(); 200 } 201 202 public int hashCode() { 203 return new HashCodeBuilder() 204 .append(getUsername()) 205 .toHashCode(); 206 } 207 208 } 209 | Popular Tags |