1 package org.splat.service.dto;
3 import java.security.Principal;
5 import org.splat.kernel.Name;
10 * @author <a href="mailto:roman.kozlov@opencascade.com">Roman Kozlov (RKV)</a>
12 public class UserDTO implements Principal, Name {
17 private String _password;
19 * User login name. Unique in the user directory.
21 private String _username;
25 private String _firstName;
31 * User name to be displayed. Optional.
33 private String _displayName;
35 * Roles as list (as stored in the database).
37 private RoleDTO _role = new RoleDTO();
41 private String _mailAddress;
45 private String _organizationName;
48 * Persistent id of the type.
52 // ==============================================================================================================================
53 // Public member functions
54 // ==============================================================================================================================
59 * @see java.lang.Object#equals(java.lang.Object)
62 public boolean equals(final Object item) {
63 boolean res = (item != null);
65 if (item instanceof String) {
66 res = this._username.equals(item); // Usernames are unique
67 } else if (item instanceof UserDTO) {
68 UserDTO given = (UserDTO) item;
69 res = given._username.equals(this._username); // Usernames are unique
76 * Get user display name.
78 * @return the user display name
80 public String getDisplayName() {
81 String res = _displayName;
83 res = _name + " " + _firstName;
89 * Get user first name.
91 * @return the user first name
93 public String getFirstName() {
98 * Set user first name.
101 * the first name to set
103 public void setFirstName(final String name) {
108 * Get user email address.
110 * @return the email address
112 public String getMailAddress() {
117 * Set user email address.
120 * the email address to set
122 public void setMailAddress(final String addr) {
129 * @see java.security.Principal#getName()
131 public String getName() {
139 * the user family to set
141 public void setName(final String name) {
146 * Get user's organization name.
148 * @return the user's organization name
150 public String getOrganizationName() {
151 return _organizationName;
155 * Set user's organization name.
158 * the user's organization name
160 public void setOrganizationName(final String name) {
161 _organizationName = name;
165 * Get user roles names separated by commas.
167 * @return the string containing roles names
169 public String getRoleNames() {
170 return _role.getName();
174 * Get users roles as an array of DTO.
176 * @return the array of roles DTO
178 public RoleDTO[] getRoles() {
179 return _role.toArray();
183 * Get user login name.
184 * @return the user login name
186 public String getUsername() {
192 * @see java.lang.Object#toString()
195 public String toString() {
196 return _name + " " + _firstName;
204 public long getIndex() {
214 public void setIndex(final long rid) {
221 * @return the password
223 public String getPassword() {
231 * the password to set
233 public void setPassword(final String password) {
234 this._password = password;
241 * the username to set
243 public void setUsername(final String username) {
244 this._username = username;
252 public RoleDTO getRole() {
262 public void setRole(final RoleDTO role) {
267 * Set the displayName.
270 * the displayName to set
272 public void setDisplayName(final String displayName) {
273 _displayName = displayName;