KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > test > core > security > RolePrincipal


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.test.core.security;
10
11 import java.security.Principal JavaDoc;
12
13 /**
14  * A principal containing a group name.
15  *
16  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
17  * @version $Revision: 1.1 $
18  */

19 public class RolePrincipal implements Principal JavaDoc
20 {
21
22    private final String JavaDoc name;
23
24    public RolePrincipal(String JavaDoc name)
25    {
26       if (name == null)
27       {
28          throw new IllegalArgumentException JavaDoc("Name cannot be null");
29       }
30       this.name = name;
31    }
32
33    public String JavaDoc getName()
34    {
35       return name;
36    }
37
38    public boolean equals(Object JavaDoc obj)
39    {
40       if (obj == this)
41       {
42          return true;
43       }
44       if (obj instanceof RolePrincipal)
45       {
46          RolePrincipal other = (RolePrincipal)obj;
47          return other.name.equals(name);
48       }
49       return false;
50    }
51
52    public int hashCode()
53    {
54       return name.hashCode();
55    }
56
57 }
58
Popular Tags