KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > policyframework > Permission


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.policyframework;
21
22 import java.io.Serializable JavaDoc;
23
24 /**
25  * Every {@link com.sslexplorer.policyframework.AccessRights} defined
26  * by the super user or delegated administrator has attached to it a
27  * list of {@link com.sslexplorer.policyframework.AccessRight}
28  * objects that defines what permissions the users in the selected policies
29  * have. Each <code>AccessRight</code> consists of a single
30  * {@link ResourceType} and an instance of this class.
31  *
32  * @author Brett Smith
33  * @see com.sslexplorer.policyframework.PolicyConstants for a list of standard permissions
34  */

35
36 public class Permission implements Comparable JavaDoc, Serializable JavaDoc {
37
38     private int id;
39     private String JavaDoc bundle;
40
41     /**
42      * Constructor
43      *
44      * @param id unique ID of the permission
45      * @param bundle the key of the message resource bundle that contains the title and description keys for this permission
46      */

47     public Permission(int id, String JavaDoc bundle) {
48         this.id = id;
49         this.bundle = bundle;
50     }
51     
52     /**
53      * Get the name of the bundle that contains the title and description keys for this permission
54      * @return
55      */

56     public String JavaDoc getBundle() {
57         return bundle;
58     }
59     
60     /**
61      * Get the unique ID of this permission
62      *
63      * @return unique ID
64      */

65     public int getId() {
66         return id;
67     }
68     
69     /* (non-Javadoc)
70      * @see java.lang.Object#equals(java.lang.Object)
71      */

72     public boolean equals(Object JavaDoc o) {
73         return o instanceof Permission &&
74             getId() == ((Permission)o).getId();
75     }
76
77     /**
78      * Compare this permission with another using the ID for comparison
79      * @param o other object
80      * @return comparison
81      */

82     public int compareTo(Object JavaDoc o) {
83         return o instanceof Permission ? new Integer JavaDoc(getId()).compareTo(new Integer JavaDoc(((Permission)o).getId())) : 1;
84     }
85 }
Popular Tags