KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jetspeed > services > security > JetspeedSecurityCache


1 /*
2  * Copyright 2000-2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17
18 package org.apache.jetspeed.services.security;
19
20 import java.util.Iterator JavaDoc;
21
22 import org.apache.jetspeed.om.security.Group;
23 import org.apache.jetspeed.om.security.Permission;
24 import org.apache.jetspeed.om.security.Role;
25 import org.apache.turbine.services.TurbineServices;
26
27 /**
28  * The Security Cache Service caches roles and permissions (ACLs)
29  *
30  * @author <a HREF="mailto:taylor@apache.org">David Sean Taylor</a>
31  * @version $Id: JetspeedSecurityCache.java,v 1.8 2004/02/23 03:58:11 jford Exp $
32  */

33
34
35 public abstract class JetspeedSecurityCache
36 {
37    /** The name of this service */
38    public String JavaDoc SERVICE_NAME = "SecurityCache";
39
40
41    /*
42     * Utility method for accessing the service
43     * implementation
44     *
45     * @return a SecurityCacheService implementation instance
46     */

47    protected static SecurityCacheService getService()
48    {
49        return (SecurityCacheService)TurbineServices
50        .getInstance().getService(SecurityCacheService.SERVICE_NAME);
51    }
52
53    /*
54     *
55     * The class that is created by the default JetspeedUserFactory is configured
56     * in the JetspeedSecurity properties:
57     *
58     * services.JetspeedSecurity.user.class=
59     * org.apache.jetspeed.om.security.BaseJetspeedUser
60     *
61     * @param JetspeedUser the user to cache all role and permission information for.
62     */

63     public static void load(String JavaDoc username)
64         throws JetspeedSecurityException
65     {
66         getService().load(username);
67     }
68
69     public static void unload(String JavaDoc username)
70     {
71         getService().unload(username);
72     }
73
74     public static void loadRolePermissions()
75     {
76         getService().loadRolePermissions();
77     }
78
79     public static Role getRole(String JavaDoc username, String JavaDoc roleName)
80     {
81         return getService().getRole(username, roleName);
82     }
83
84     public static Role getRole(String JavaDoc username, String JavaDoc roleName, String JavaDoc groupName)
85     {
86         return getService().getRole(username, roleName, groupName);
87     }
88     
89     public static void addRole(Role role)
90     {
91         getService().addRole(role);
92     }
93
94     public static void addRole(String JavaDoc username, Role role)
95     {
96         getService().addRole(username, role);
97     }
98
99     public static void addRole(String JavaDoc username, Role role, Group group)
100     {
101         getService().addRole(username, role, group);
102     }
103
104     public static boolean hasRole(String JavaDoc username, String JavaDoc roleName)
105     {
106         return getService().hasRole(username, roleName);
107     }
108
109     public static boolean hasRole(String JavaDoc username, String JavaDoc roleName, String JavaDoc groupName)
110     {
111         return getService().hasRole(username, roleName, groupName);
112     }
113
114     public static void removeRole(String JavaDoc username, String JavaDoc roleName)
115     {
116         getService().removeRole(username, roleName);
117     }
118
119     public static void removeRole(String JavaDoc username, String JavaDoc roleName, String JavaDoc groupName)
120     {
121         getService().removeRole(username, roleName, groupName);
122     }
123
124     public static Iterator JavaDoc getRoles(String JavaDoc username)
125     {
126         return getService().getRoles(username);
127     }
128
129     public static CachedAcl getAcl(String JavaDoc username)
130     {
131         return getService().getAcl(username);
132     }
133
134     public static void removeAllRoles(String JavaDoc rolename)
135     {
136         getService().removeAllRoles(rolename);
137     }
138
139     public static void removeAllPermissions(String JavaDoc permissionName)
140     {
141         getService().removeAllPermissions(permissionName);
142     }
143
144     public static Permission getPermission(String JavaDoc roleName, String JavaDoc permissionName)
145     {
146         return getService().getPermission(roleName, permissionName);
147     }
148     
149     public static void addPermission(String JavaDoc roleName, Permission permission)
150     {
151         getService().addPermission(roleName, permission);
152     }
153
154     public static boolean hasPermission(String JavaDoc roleName, String JavaDoc permissionName)
155     {
156         return getService().hasPermission(roleName, permissionName);
157     }
158
159     public static void removePermission(String JavaDoc roleName, String JavaDoc permissionName)
160     {
161         getService().removePermission(roleName, permissionName);
162     }
163
164     public static Iterator JavaDoc getPermissions(String JavaDoc roleName)
165     {
166         return getService().getPermissions(roleName);
167     }
168
169 }
170
171
172
173
Popular Tags