]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
b096117b94a722052958717d5994c84516933315
[tmp/jakarta-migration.git] /
1 /**
2  *  This document is a part of the source code and related artifacts
3  *  for CollectionSpace, an open source collections management system
4  *  for museums and related institutions:
5
6  *  http://www.collectionspace.org
7  *  http://wiki.collectionspace.org
8
9  *  Copyright 2009 University of California at Berkeley
10
11  *  Licensed under the Educational Community License (ECL), Version 2.0.
12  *  You may not use this file except in compliance with this License.
13
14  *  You may obtain a copy of the ECL 2.0 License at
15
16  *  https://source.collectionspace.org/collection-space/LICENSE.txt
17
18  *  Unless required by applicable law or agreed to in writing, software
19  *  distributed under the License is distributed on an "AS IS" BASIS,
20  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  *  See the License for the specific language governing permissions and
22  *  limitations under the License.
23  */
24 package org.collectionspace.authentication;
25
26 import java.security.Principal;
27
28 /**
29  * CSpacePrincipal provides additional tenant-specific context to application
30  * @author 
31  */
32 final public class CSpacePrincipal
33         implements Principal, java.io.Serializable {
34
35     private String name;
36     private String tenantId;
37
38     public CSpacePrincipal(String name) {
39         this.name = name;
40     }
41
42     public int hashCode() {
43         return name.hashCode();
44     }
45
46     public boolean equals(Object obj) {
47         Principal p = (Principal) obj;
48         return name.equals(p.getName());
49     }
50
51     public String toString() {
52         return name;
53     }
54
55     /**
56      * Returns the name of this principal.
57      *
58      * @return the name of this principal.
59      */
60     public String getName() {
61         return name;
62     }
63
64     /**
65      * Returns the id of the tenant this principal is associated with
66      * @return
67      */
68     public String getTenantId() {
69         return tenantId;
70     }
71
72     /**
73      * Set the id for the tenant to which princiapal is associated with
74      * The access to this method must be package private
75      * @param tenantId
76      */
77     void setTenantId(String tenantId) {
78         this.tenantId = tenantId;
79     }
80 }