01: package de.webman.acl.resolver;
02:
03: import java.util.Hashtable;
04: import com.teamkonzept.lib.TKException;
05: import com.teamkonzept.lib.TKVector;
06: import de.webman.acl.Login;
07: import de.webman.acl.PolicyFactory;
08: import com.teamkonzept.webman.mainint.WebmanExceptionHandler;
09:
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 extends ResolverBase implements Resolver {
19:
20: // $Header: /cvsroot/webman-cms/source/webman/de/webman/acl/resolver/GenericResolver.java,v 1.1 2001/08/20 08:25:09 mischa Exp $
21:
22: // Constructors
23:
24: /**
25: * Provide instantion only to package classes or subclasses.
26: *
27: * @param login the initial login object.
28: */
29: protected GenericResolver(Login login) {
30: super (login);
31: }
32:
33: // Implementation of 'com.teamkonzept.webman.accesscontrol.resolver.Resolver'.
34:
35: /**
36: * Implements the resolution of generic access rights, i.e.
37: * inheritable access rights.
38: *
39: * @param collection the distinct collection of permitted events.
40: * @param context the ID if the current context (<I>required</I>).
41: * @param type the current object type (<I>required</I>).
42: * @param reference the current object reference (<I>required</I>).
43: * @exception com.teamkonzept.lib.TKException if an error occured during
44: * access right resolution.
45: */
46: public final void resolve(Hashtable collection, Integer context,
47: Integer type, Integer reference) throws TKException {
48: try {
49: // 1. Retrieve events from resolved policies.
50: processPolicies(collection, resolvePolicies(context, type,
51: reference));
52: } catch (Exception x) {
53: throw WebmanExceptionHandler.getException(x);
54: }
55: }
56:
57: // Convenience methods
58:
59: /**
60: * Performs cache - and in case of failure - database lookup.
61: *
62: * @param context the ID if the current context (<I>required</I>).
63: * @param type the current object type (<I>required</I>).
64: * @param reference the current object reference (<I>required</I>).
65: * @return the IDs of the resolved policies.
66: * @exception com.teamkonzept.lib.TKException if an error occured during
67: * policy retrieval.
68: */
69: private final TKVector resolvePolicies(Integer context,
70: Integer type, Integer reference) throws TKException {
71: TKVector proxies = null;
72:
73: try {
74: proxies = resolutionCacheRead(context, type, reference,
75: null);
76:
77: if (proxies == null) {
78: proxies = PolicyFactory.getInstance().getPolicyProxies(
79: getLogin().getID(), context, type, reference);
80:
81: resolutionCacheWrite(context, type, reference, null,
82: proxies);
83: }
84: } catch (Exception x) {
85: throw WebmanExceptionHandler.getException(x);
86: }
87:
88: return proxies;
89: }
90:
91: }
|