]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
122adb1a17b059d7745dd7b3d6a4d4a7a5ae46a0
[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     /**
36          * 
37          */
38         private static final long serialVersionUID = -1357683611240908638L;
39         private String name;
40     private String tenantId;
41
42     public CSpacePrincipal(String name) {
43         this.name = name;
44     }
45
46     public int hashCode() {
47         return name.hashCode();
48     }
49
50     public boolean equals(Object obj) {
51         Principal p = (Principal) obj;
52         return name.equals(p.getName());
53     }
54
55     public String toString() {
56         return name;
57     }
58
59     /**
60      * Returns the name of this principal.
61      *
62      * @return the name of this principal.
63      */
64     public String getName() {
65         return name;
66     }
67
68     /**
69      * Returns the id of the tenant this principal is associated with
70      * @return
71      */
72     public String getTenantId() {
73         return tenantId;
74     }
75
76     /**
77      * Set the id for the tenant to which princiapal is associated with
78      * The access to this method must be package private
79      * @param tenantId
80      */
81     void setTenantId(String tenantId) {
82         this.tenantId = tenantId;
83     }
84 }