1 17 package org.alfresco.filesys.server.auth; 18 19 import org.alfresco.filesys.util.StringList; 20 21 26 public class UserAccount 27 { 28 29 31 private String m_userName; 32 private String m_password; 33 34 36 private String m_realName; 37 private String m_comment; 38 39 41 private StringList m_shares; 42 43 45 private boolean m_admin; 46 47 49 private String m_homeDir; 50 51 54 public UserAccount() 55 { 56 super(); 57 } 58 59 65 public UserAccount(String user, String pwd) 66 { 67 setUserName(user); 68 setPassword(pwd); 69 } 70 71 76 public final void addShare(String shr) 77 { 78 if (m_shares == null) 79 m_shares = new StringList(); 80 m_shares.addString(shr); 81 } 82 83 89 public final boolean allowsShare(String shr) 90 { 91 if (m_shares == null) 92 return true; 93 else if (m_shares.containsString(shr)) 94 return true; 95 return false; 96 } 97 98 103 public final boolean hasHomeDirectory() 104 { 105 return m_homeDir != null ? true : false; 106 } 107 108 113 public final String getHomeDirectory() 114 { 115 return m_homeDir; 116 } 117 118 123 public final String getPassword() 124 { 125 return m_password; 126 } 127 128 133 public final String getUserName() 134 { 135 return m_userName; 136 } 137 138 143 public final String getRealName() 144 { 145 return m_realName; 146 } 147 148 153 public final String getComment() 154 { 155 return m_comment; 156 } 157 158 164 public final boolean hasShare(String shr) 165 { 166 if (m_shares != null && m_shares.containsString(shr) == false) 167 return false; 168 return true; 169 } 170 171 176 public final boolean hasShareRestrictions() 177 { 178 return m_shares == null ? false : true; 179 } 180 181 186 public final StringList getShareList() 187 { 188 return m_shares; 189 } 190 191 196 public final boolean isAdministrator() 197 { 198 return m_admin; 199 } 200 201 204 public final void removeAllShares() 205 { 206 m_shares = null; 207 } 208 209 214 public final void removeShare(String shr) 215 { 216 217 219 if (m_shares != null) 220 { 221 222 224 m_shares.removeString(shr); 225 226 228 if (m_shares.numberOfStrings() == 0) 229 m_shares = null; 230 } 231 } 232 233 238 public final void setAdministrator(boolean admin) 239 { 240 m_admin = admin; 241 } 242 243 248 public final void setHomeDirectory(String home) 249 { 250 m_homeDir = home; 251 } 252 253 258 public final void setPassword(String pwd) 259 { 260 m_password = pwd; 261 } 262 263 268 public final void setUserName(String user) 269 { 270 m_userName = user; 271 } 272 273 278 public final void setRealName(String name) 279 { 280 m_realName = name; 281 } 282 283 288 public final void setComment(String comment) 289 { 290 m_comment = comment; 291 } 292 293 298 public String toString() 299 { 300 StringBuffer str = new StringBuffer (); 301 302 str.append("["); 303 str.append(getUserName()); 304 str.append(":"); 305 str.append(getPassword()); 306 307 if (isAdministrator()) 308 str.append("(ADMIN)"); 309 310 str.append(",Real="); 311 312 str.append(getRealName()); 313 str.append(",Comment="); 314 str.append(getComment()); 315 str.append(",Allow="); 316 317 if (m_shares == null) 318 str.append("<ALL>"); 319 else 320 str.append(m_shares); 321 str.append("]"); 322 323 str.append(",Home="); 324 if (hasHomeDirectory()) 325 str.append(getHomeDirectory()); 326 else 327 str.append("None"); 328 329 return str.toString(); 330 } 331 } | Popular Tags |