KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > acl > resolver > GenericResolver


1 package de.webman.acl.resolver;
2
3 import java.util.Hashtable JavaDoc;
4 import com.teamkonzept.lib.TKException;
5 import com.teamkonzept.lib.TKVector;
6 import de.webman.acl.Login;
7 import de.webman.acl.PolicyFactory;
8 import com.teamkonzept.webman.mainint.WebmanExceptionHandler;
9
10 /**
11  * Resolves access rights for a given login object in a strictly
12  * sequential manner.
13  *
14  * @version 1.0
15  * @since 1.0
16  * @author © 2001 Webman AG
17  */

18 public class GenericResolver
19     extends ResolverBase
20     implements Resolver
21 {
22
23     // $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/resolver/GenericResolver.java,v 1.1 2001/08/20 08:25:09 mischa Exp $
24

25     // Constructors
26

27     /**
28      * Provide instantion only to package classes or subclasses.
29      *
30      * @param login the initial login object.
31      */

32     protected GenericResolver (Login login)
33     {
34         super(login);
35     }
36
37
38     // Implementation of 'com.teamkonzept.webman.accesscontrol.resolver.Resolver'.
39

40     /**
41      * Implements the resolution of generic access rights, i.e.
42      * inheritable access rights.
43      *
44      * @param collection the distinct collection of permitted events.
45      * @param context the ID if the current context (<I>required</I>).
46      * @param type the current object type (<I>required</I>).
47      * @param reference the current object reference (<I>required</I>).
48      * @exception com.teamkonzept.lib.TKException if an error occured during
49      * access right resolution.
50      */

51     public final void resolve (Hashtable JavaDoc collection,
52                                Integer JavaDoc context,
53                                Integer JavaDoc type,
54                                Integer JavaDoc reference)
55         throws TKException
56     {
57         try
58         {
59             // 1. Retrieve events from resolved policies.
60
processPolicies(collection, resolvePolicies(context, type, reference));
61         }
62         catch (Exception JavaDoc x)
63         {
64             throw WebmanExceptionHandler.getException(x);
65         }
66     }
67
68
69     // Convenience methods
70

71     /**
72      * Performs cache - and in case of failure - database lookup.
73      *
74      * @param context the ID if the current context (<I>required</I>).
75      * @param type the current object type (<I>required</I>).
76      * @param reference the current object reference (<I>required</I>).
77      * @return the IDs of the resolved policies.
78      * @exception com.teamkonzept.lib.TKException if an error occured during
79      * policy retrieval.
80      */

81     private final TKVector resolvePolicies (Integer JavaDoc context,
82                                             Integer JavaDoc type,
83                                             Integer JavaDoc reference)
84         throws TKException
85     {
86         TKVector proxies = null;
87
88         try
89         {
90             proxies = resolutionCacheRead(context,
91                                           type,
92                                           reference,
93                                           null);
94
95             if (proxies == null)
96             {
97                 proxies = PolicyFactory.getInstance()
98                                          .getPolicyProxies(getLogin().getID(),
99                                                            context,
100                                                            type,
101                                                            reference);
102
103                 resolutionCacheWrite(context,
104                                      type,
105                                      reference,
106                                      null,
107                                      proxies);
108             }
109         }
110         catch (Exception JavaDoc x)
111         {
112             throw WebmanExceptionHandler.getException(x);
113         }
114
115         return proxies;
116     }
117
118 }
119
Popular Tags