KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > identity > User


1 package org.jbpm.identity;
2
3 import java.security.*;
4 import java.util.*;
5
6 /**
7  * user or a system.
8  */

9 public class User extends Entity implements Principal {
10
11   private static final long serialVersionUID = 1L;
12   
13   protected String JavaDoc password = null;
14   protected String JavaDoc email = null;
15   protected Set memberships = null;
16  
17   public User() {
18   }
19
20   public User(String JavaDoc name) {
21     super(name);
22   }
23
24   public void addMembership(Membership membership) {
25     if (memberships==null) memberships = new HashSet();
26     memberships.add(membership);
27     membership.setUser(this);
28   }
29   
30   public Set getGroupsForGroupType(String JavaDoc groupType) {
31     Set groups = new HashSet();
32     if(memberships!=null) {
33       Iterator iter = memberships.iterator();
34       while (iter.hasNext()) {
35         Membership membership = (Membership) iter.next();
36         if (groupType.equals(membership.getGroup().getType())) {
37           groups.add(membership.getGroup());
38         }
39       }
40     }
41     return groups;
42   }
43
44   public Set getGroupsForMembershipName(String JavaDoc membershipName) {
45     Set groups = new HashSet();
46     if(memberships!=null) {
47       Iterator iter = memberships.iterator();
48       while (iter.hasNext()) {
49         Membership membership = (Membership) iter.next();
50         if (membershipName.equals(membership.getName())) {
51           groups.add(membership.getGroup());
52         }
53       }
54     }
55     return groups;
56   }
57
58   public void setPassword(String JavaDoc password) {
59     this.password = password;
60   }
61   public String JavaDoc getPassword() {
62     return password;
63   }
64   public Set getMemberships() {
65     return memberships;
66   }
67   public String JavaDoc getEmail() {
68     return email;
69   }
70   public void setEmail(String JavaDoc email) {
71     this.email = email;
72   }
73 }
74
Popular Tags