KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.Collection JavaDoc;
23
24 import com.sslexplorer.security.SessionInfo;
25
26 /**
27  * SSL-Explorer has the concept of resources. Resources are generally things
28  * that may be assigned to a user to allow them to perform some action.
29  * <p>
30  * All resources must specify their type, and this object describes that type.
31  * The resource type must be registered with the system using
32  * {@link com.sslexplorer.policyframework.PolicyDatabase#registerResourceType(ResourceType)},
33  * this allows extensions to define new resource types.
34  * <p>
35  * Each resource type contains a list of permissions of the specified
36  * <strong>class</strong>, current permission classes include
37  * {@link com.sslexplorer.policyframework.PolicyConstants#DELEGATION_CLASS},
38  * {@link com.sslexplorer.policyframework.PolicyConstants#SYSTEM_CLASS} or
39  * {@link com.sslexplorer.policyframework.PolicyConstants#PERSONAL_CLASS}.
40  * <p>
41  * To allow for internationalisation each defined resource type must provide the
42  * ID of the resource bundle that contains its title and description.
43  * <p>
44  * Method implementations are also required for getting a resource given its id,
45  * getting a resource given its name, deleting a resource and updating a resource
46  * For the update and delete, it is the implementations responspibility to
47  * throw appropriate events.
48  *
49  * @author Brett Smith <a HREF="mailto:brett@3sp.com">&lt;brett@3sp.com&gt;</a>
50  * @see com.sslexplorer.policyframework.PolicyConstants
51  */

52
53 public interface ResourceType extends Comparable JavaDoc<ResourceType> {
54     
55     /**
56      * Get if this resources of this type must be attached to a policy.
57      *
58      * @return must be attached to policy
59      */

60     public boolean isPolicyRequired();
61     
62     /**
63      * Get the unique ID of this resource type
64      * @return resource type id
65      */

66     public int getResourceTypeId();
67     
68     /**
69      * Get the ID of the message resource bundle that contains the title
70      * and description of this resource type
71      *
72      * @return bundle ID
73      */

74     public String JavaDoc getBundle();
75     
76     /**
77      * Get the list of permissions that are appropriate for resources of
78      * this type.
79      *
80      * @return list of permission.
81      */

82     public Collection JavaDoc<Permission> getPermissions();
83     
84     /**
85      * Add a new permission to those that are approriate for resources of
86      * this type.
87      *
88      * @param permission permission to add
89      */

90     public void addPermission(Permission permission);
91     
92     /**
93      * Get a permission at the specified index from the list that are
94      * appropriate for resources of this type.
95      *
96      * @param idx index of permission to get
97      * @return permission at specified index
98      */

99     public Permission getPermission(int idx);
100
101     /**
102      * Get the permission class. May currently be one of {@link com.sslexplorer.policyframework.PolicyConstants#DELEGATION_CLASS},
103      * {@link com.sslexplorer.policyframework.PolicyConstants#SYSTEM_CLASS} or
104      * {@link com.sslexplorer.policyframework.PolicyConstants#PERSONAL_CLASS}.
105      *
106      * @return permission class
107      */

108     public String JavaDoc getPermissionClass();
109
110     /**
111      * Set the permission class. May currently be one of {@link com.sslexplorer.policyframework.PolicyConstants#DELEGATION_CLASS},
112      * {@link com.sslexplorer.policyframework.PolicyConstants#SYSTEM_CLASS} or
113      * {@link com.sslexplorer.policyframework.PolicyConstants#PERSONAL_CLASS}.
114      *
115      * @param permissionClass permission class to set
116      */

117     public void setPermissionClass(String JavaDoc permissionClass);
118     
119     /**
120      * Compare this resource type with another. Implementations of this
121      * should compare using the {@link #getResourceTypeId()}.
122      *
123      * @param o other resource type
124      * @return true if the IDs are equal
125      */

126     public boolean equals(Object JavaDoc o);
127     
128     /**
129      * Get an instance of the appropriate {@link Resource} implementation given
130      * its ID.
131      *
132      * @param resourceId resource ID
133      * @return resource instance
134      * @throws Exception on any error
135      */

136     public Resource getResourceById(int resourceId) throws Exception JavaDoc;
137     
138     /**
139      * Get an instance of the appropriate {@link Resource} implementation given
140      * its name.
141      *
142      * @param resourceName resource name
143      * @param session
144      * @return resource instance
145      * @throws Exception on any error
146      */

147     public Resource getResourceByName(String JavaDoc resourceName, SessionInfo session) throws Exception JavaDoc;
148     
149     /**
150      * Remove a {@link Resource} from its database given its ID and
151      * fire the appropriate event.
152      *
153      * @param resourceId resource to remove
154      * @param session originating session
155      * @return resource removed
156      * @throws Exception on any error
157      */

158     public Resource removeResource(int resourceId, SessionInfo session) throws Exception JavaDoc;
159     
160     /**
161      * Update {@link Resource} in its database and fire the appropriate
162      * event.
163      *
164      * @param resource resource to update
165      * @param session originating session
166      * @throws Exception on any error
167      */

168     public void updateResource(Resource resource, SessionInfo session) throws Exception JavaDoc;
169
170     /**
171      * Clone a resource. The resource name will automatically be adjust to
172      * <i>Copy of [resourceName]</i>. If a resource with this name already
173      * exists then a number index will be added to the name until no such
174      * named resource exists. E.g. <i>Copy (2) of [resourceName]</i>.
175      *
176      * @param sourceResource source resonse
177      * @param session originating session
178      * @return cloned resource
179      * @throws CloneNotSupportedException
180      */

181     public Resource cloneResource(Resource sourceResource, SessionInfo session) throws CloneNotSupportedException JavaDoc;
182 }
183
Popular Tags