1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.intercept.web;
17
18 import org.acegisecurity.ConfigAttributeDefinition;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22
23
24 /***
25 * Abstract implementation of <Code>FilterInvocationDefinitionSource</code>.
26 *
27 * @author Ben Alex
28 * @version $Id: AbstractFilterInvocationDefinitionSource.java,v 1.3 2005/11/17 00:55:50 benalex Exp $
29 */
30 public abstract class AbstractFilterInvocationDefinitionSource
31 implements FilterInvocationDefinitionSource {
32
33
34 private static final Log logger = LogFactory.getLog(AbstractFilterInvocationDefinitionSource.class);
35
36
37
38 public ConfigAttributeDefinition getAttributes(Object object)
39 throws IllegalArgumentException {
40 if ((object == null) || !this.supports(object.getClass())) {
41 throw new IllegalArgumentException(
42 "Object must be a FilterInvocation");
43 }
44
45 String url = ((FilterInvocation) object).getRequestUrl();
46
47 return this.lookupAttributes(url);
48 }
49
50 /***
51 * Performs the actual lookup of the relevant
52 * <code>ConfigAttributeDefinition</code> for the specified
53 * <code>FilterInvocation</code>.
54 *
55 * <P>
56 * Provided so subclasses need only to provide one basic method to properly
57 * interface with the <code>FilterInvocationDefinitionSource</code>.
58 * </p>
59 *
60 * <P>
61 * Public visiblity so that tablibs or other view helper classes can access
62 * the <code>ConfigAttributeDefinition</code> applying to a given URI
63 * pattern without needing to construct a mock
64 * <code>FilterInvocation</code> and retrieving the attibutes via the
65 * {@link #getAttributes(Object)} method.
66 * </p>
67 *
68 * @param url the URI to retrieve configuration attributes for
69 *
70 * @return the <code>ConfigAttributeDefinition</code> that applies to the
71 * specified <code>FilterInvocation</code>
72 */
73 public abstract ConfigAttributeDefinition lookupAttributes(String url);
74
75 public boolean supports(Class clazz) {
76 if (FilterInvocation.class.isAssignableFrom(clazz)) {
77 return true;
78 } else {
79 return false;
80 }
81 }
82 }