KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > security > InfoGluePrincipal


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.security;
25
26 import java.io.Serializable JavaDoc;
27 import java.security.Principal JavaDoc;
28 import java.util.List JavaDoc;
29
30
31 /**
32  * This class represents an generic InfoGluePrincipal in InfoGlue. It is used to identify a user no matter what source it was defined in.
33  *
34  * @author Mattias Bogeblad
35  */

36
37 public class InfoGluePrincipal implements Principal JavaDoc, Serializable JavaDoc
38 {
39     private static final long serialVersionUID = 7252014421006767620L;
40     
41     private final String JavaDoc name;
42     private final String JavaDoc firstName;
43     private final String JavaDoc lastName;
44     private final String JavaDoc email;
45     private final List JavaDoc roles;
46     private final List JavaDoc groups;
47     private final boolean isAdministrator;
48     private final AuthorizationModule autorizationModule;
49     
50     public InfoGluePrincipal(String JavaDoc name, String JavaDoc firstName, String JavaDoc lastName, String JavaDoc email, List JavaDoc roles, List JavaDoc groups, boolean isAdministrator, AuthorizationModule autorizationModule)
51     {
52         this.name = name;
53         this.firstName = firstName;
54         this.lastName = lastName;
55         this.email = email;
56         this.roles = roles;
57         this.groups = groups;
58         this.isAdministrator = isAdministrator;
59         this.autorizationModule = autorizationModule;
60     }
61
62     public String JavaDoc getName()
63     {
64         return name;
65     }
66
67     public String JavaDoc getFirstName()
68     {
69         return firstName;
70     }
71     
72     public String JavaDoc getLastName()
73     {
74         return lastName;
75     }
76
77     public String JavaDoc getEmail()
78     {
79         return email;
80     }
81
82     public List JavaDoc getRoles()
83     {
84         return roles;
85     }
86     
87     public List JavaDoc getGroups()
88     {
89         return groups;
90     }
91
92     public boolean getIsAdministrator()
93     {
94         return isAdministrator;
95     }
96     
97     public String JavaDoc toString()
98     {
99         return name;
100         /*
101         StringBuffer sb = new StringBuffer("InfoGluePrincipal: " + name + ":" + email + ":" + isAdministrator + '\n');
102         for(Iterator i=roles.iterator(); i.hasNext();)
103         {
104             InfoGlueRole role = (InfoGlueRole)i.next();
105             sb.append("" + role.getName() + ",");
106         }
107         sb.append("]");
108         
109         return sb.toString();
110         */

111     }
112
113     public boolean equals(Object JavaDoc obj)
114     {
115         if (obj == null)
116             return false;
117         if (obj == this)
118             return true;
119         if (!(obj instanceof InfoGluePrincipal))
120             return false;
121         
122         InfoGluePrincipal another = (InfoGluePrincipal)obj;
123         return name.equals(another.getName());
124     }
125
126     public int hasCode()
127     {
128         return name.hashCode();
129     }
130
131     public AuthorizationModule getAutorizationModule()
132     {
133         return autorizationModule;
134     }
135 }
136
137
Popular Tags