1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.springframework.extensions.webscripts.connector;
20
21 import java.io.Serializable;
22 import java.util.HashMap;
23 import java.util.Map;
24
25 import org.springframework.extensions.webscripts.ui.common.StringUtils;
26
27
28
29
30
31
32
33 public class User implements java.security.Principal, Serializable
34 {
35 public static String PROP_ID = "id";
36 public static String PROP_FIRST_NAME = "firstName";
37 public static String PROP_MIDDLE_NAME = "middleName";
38 public static String PROP_LAST_NAME = "lastName";
39 public static String PROP_EMAIL = "email";
40 public static String PROP_ORGANIZATION = "organization";
41 public static String PROP_JOB_TITLE = "jobtitle";
42 public static String PROP_LOCATION = "location";
43 public static String PROP_BIOGRAPHY = "persondescription";
44 public static String PROP_TELEPHONE = "telephone";
45 public static String PROP_MOBILE_PHONE = "mobile";
46 public static String PROP_SKYPE = "skype";
47 public static String PROP_INSTANTMSG = "instantmsg";
48 public static String PROP_COMPANY_ADDRESS1 = "companyaddress1";
49 public static String PROP_COMPANY_ADDRESS2 = "companyaddress2";
50 public static String PROP_COMPANY_ADDRESS3 = "companyaddress3";
51 public static String PROP_COMPANY_POSTCODE = "companypostcode";
52 public static String PROP_COMPANY_TELEPHONE = "companytelephone";
53 public static String PROP_COMPANY_FAX = "companyfax";
54 public static String PROP_COMPANY_EMAIL = "companyemail";
55
56 protected String fullName = null;
57 protected boolean isAdmin = false;
58 protected boolean isGuest = false;
59 protected Map<String, Serializable> map = null;
60
61
62
63
64
65
66 public User(String id)
67 {
68 this.map = new HashMap<String, Serializable>(32);
69 setProperty(PROP_ID, id);
70 }
71
72
73
74
75
76
77
78 public User(String id, boolean isAdmin, boolean isGuest)
79 {
80 this(id);
81 this.isAdmin = isAdmin;
82 this.isGuest = isGuest;
83 }
84
85
86
87
88 public String getName()
89 {
90 return getId();
91 }
92
93
94
95
96
97
98 public String getId()
99 {
100 return getStringProperty(PROP_ID);
101 }
102
103
104
105
106
107
108
109
110
111
112 public String getFirstName()
113 {
114 return getStringProperty(PROP_FIRST_NAME);
115 }
116
117
118
119
120
121
122 public void setFirstName(String value)
123 {
124 setProperty(PROP_FIRST_NAME, value);
125 }
126
127
128
129
130
131
132 public String getLastName()
133 {
134 return getStringProperty(PROP_LAST_NAME);
135 }
136
137
138
139
140
141
142 public void setLastName(String value)
143 {
144 setProperty(PROP_LAST_NAME, value);
145 }
146
147
148
149
150
151
152 public String getMiddleName()
153 {
154 return getStringProperty(PROP_MIDDLE_NAME);
155 }
156
157
158
159
160
161
162 public void setMiddleName(String value)
163 {
164 setProperty(PROP_MIDDLE_NAME, value);
165 }
166
167
168
169
170
171
172 public String getEmail()
173 {
174 return getStringProperty(PROP_EMAIL);
175 }
176
177
178
179
180
181
182 public void setEmail(String value)
183 {
184 setProperty(PROP_EMAIL, value);
185 }
186
187
188
189
190
191
192 public String getOrganization()
193 {
194 return getStringProperty(PROP_ORGANIZATION);
195 }
196
197
198
199
200
201
202 public void setOrganization(String value)
203 {
204 setProperty(PROP_ORGANIZATION, value);
205 }
206
207
208
209
210
211
212 public String getJobTitle()
213 {
214 return getStringProperty(PROP_JOB_TITLE);
215 }
216
217
218
219
220
221
222 public void setJobTitle(String value)
223 {
224 setProperty(PROP_JOB_TITLE, value);
225 }
226
227
228
229
230
231
232 public String getLocation()
233 {
234 return getStringProperty(PROP_LOCATION);
235 }
236
237
238
239
240
241
242 public void setLocation(String value)
243 {
244 setProperty(PROP_LOCATION, value);
245 }
246
247
248
249
250
251
252 public String getBiography()
253 {
254 return getStringProperty(PROP_BIOGRAPHY);
255 }
256
257
258
259
260
261
262 public void setBiography(String value)
263 {
264 if (value != null)
265 {
266 value = StringUtils.stripUnsafeHTMLTags(value);
267 }
268 setProperty(PROP_BIOGRAPHY, value);
269 }
270
271
272
273
274
275
276 public String getTelephone()
277 {
278 return getStringProperty(PROP_TELEPHONE);
279 }
280
281
282
283
284
285
286 public void setTelephone(String value)
287 {
288 setProperty(PROP_TELEPHONE, value);
289 }
290
291
292
293
294
295
296 public String getMobilePhone()
297 {
298 return getStringProperty(PROP_MOBILE_PHONE);
299 }
300
301
302
303
304
305
306 public void setMobilePhone(String value)
307 {
308 setProperty(PROP_MOBILE_PHONE, value);
309 }
310
311
312
313
314
315
316 public String getSkype()
317 {
318 return getStringProperty(PROP_SKYPE);
319 }
320
321
322
323
324
325
326 public void setSkype(String value)
327 {
328 setProperty(PROP_SKYPE, value);
329 }
330
331
332
333
334
335
336 public String getInstantMsg()
337 {
338 return getStringProperty(PROP_INSTANTMSG);
339 }
340
341
342
343
344
345
346 public void setInstantMsg(String value)
347 {
348 setProperty(PROP_INSTANTMSG, value);
349 }
350
351
352
353
354
355
356 public String getCompanyAddress1()
357 {
358 return getStringProperty(PROP_COMPANY_ADDRESS1);
359 }
360
361
362
363
364
365
366 public void setCompanyAddress1(String value)
367 {
368 setProperty(PROP_COMPANY_ADDRESS1, value);
369 }
370
371
372
373
374
375
376 public String getCompanyAddress2()
377 {
378 return getStringProperty(PROP_COMPANY_ADDRESS2);
379 }
380
381
382
383
384
385
386 public void setCompanyAddress2(String value)
387 {
388 setProperty(PROP_COMPANY_ADDRESS2, value);
389 }
390
391
392
393
394
395
396 public String getCompanyAddress3()
397 {
398 return getStringProperty(PROP_COMPANY_ADDRESS3);
399 }
400
401
402
403
404
405
406 public void setCompanyAddress3(String value)
407 {
408 setProperty(PROP_COMPANY_ADDRESS3, value);
409 }
410
411
412
413
414
415
416 public String getCompanyPostcode()
417 {
418 return getStringProperty(PROP_COMPANY_POSTCODE);
419 }
420
421
422
423
424
425
426 public void setCompanyPostcode(String value)
427 {
428 setProperty(PROP_COMPANY_POSTCODE, value);
429 }
430
431
432
433
434
435
436 public String getCompanyTelephone()
437 {
438 return getStringProperty(PROP_COMPANY_TELEPHONE);
439 }
440
441
442
443
444
445
446 public void setCompanyTelephone(String value)
447 {
448 setProperty(PROP_COMPANY_TELEPHONE, value);
449 }
450
451
452
453
454
455
456 public String getCompanyFax()
457 {
458 return getStringProperty(PROP_COMPANY_FAX);
459 }
460
461
462
463
464
465
466 public void setCompanyFax(String value)
467 {
468 setProperty(PROP_COMPANY_FAX, value);
469 }
470
471
472
473
474
475
476 public String getCompanyEmail()
477 {
478 return getStringProperty(PROP_COMPANY_EMAIL);
479 }
480
481
482
483
484
485
486 public void setCompanyEmail(String value)
487 {
488 setProperty(PROP_COMPANY_EMAIL, value);
489 }
490
491
492
493
494
495
496
497
498
499 public Object getProperty(String key)
500 {
501 return (Object) map.get(key);
502 }
503
504
505
506
507
508
509
510
511 public String getStringProperty(String key)
512 {
513 return (String) map.get(key);
514 }
515
516
517
518
519
520
521
522 public void setProperty(String key, Serializable value)
523 {
524 map.put(key, value);
525 }
526
527
528
529
530
531
532 public Map<String, Serializable> getProperties()
533 {
534 return map;
535 }
536
537
538
539
540
541
542 public boolean isAdmin()
543 {
544 return this.isAdmin;
545 }
546
547
548
549
550
551
552 public boolean isGuest()
553 {
554 return this.isGuest;
555 }
556
557
558
559
560 @Override
561 public String toString()
562 {
563 return map.toString();
564 }
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587 public String getFullName()
588 {
589 if (this.fullName == null)
590 {
591 boolean hasFirstName = (getFirstName() != null && getFirstName().length() != 0);
592 boolean hasMiddleName = (getMiddleName() != null && getMiddleName().length() != 0);
593 boolean hasLastName = (getLastName() != null && getLastName().length() != 0);
594
595
596 this.fullName = getId();
597 if (hasFirstName)
598 {
599 this.fullName = getFirstName();
600
601 if (hasMiddleName)
602 {
603 this.fullName += " " + getMiddleName();
604 }
605
606 if (hasLastName)
607 {
608 this.fullName += " " + getLastName();
609 }
610 }
611 }
612
613 return this.fullName;
614 }
615
616
617
618
619 public void save()
620 {
621 }
622 }