01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity.intercept.web;
17:
18: import org.acegisecurity.ConfigAttributeDefinition;
19:
20: /**
21: * Abstract implementation of <Code>FilterInvocationDefinitionSource</code>.
22: *
23: * @author Ben Alex
24: * @version $Id: AbstractFilterInvocationDefinitionSource.java 1877 2007-05-25 05:33:06Z benalex $
25: */
26: public abstract class AbstractFilterInvocationDefinitionSource
27: implements FilterInvocationDefinitionSource {
28:
29: //~ Methods ========================================================================================================
30:
31: public ConfigAttributeDefinition getAttributes(Object object)
32: throws IllegalArgumentException {
33: if ((object == null) || !this .supports(object.getClass())) {
34: throw new IllegalArgumentException(
35: "Object must be a FilterInvocation");
36: }
37:
38: String url = ((FilterInvocation) object).getRequestUrl();
39:
40: return this .lookupAttributes(url);
41: }
42:
43: /**
44: * Performs the actual lookup of the relevant <code>ConfigAttributeDefinition</code> for the specified
45: * <code>FilterInvocation</code>.
46: * <p>Provided so subclasses need only to provide one basic method to properly interface with the
47: * <code>FilterInvocationDefinitionSource</code>.
48: * </p>
49: * <p>Public visiblity so that tablibs or other view helper classes can access the
50: * <code>ConfigAttributeDefinition</code> applying to a given URI pattern without needing to construct a mock
51: * <code>FilterInvocation</code> and retrieving the attibutes via the {@link #getAttributes(Object)} method.</p>
52: *
53: * @param url the URI to retrieve configuration attributes for
54: *
55: * @return the <code>ConfigAttributeDefinition</code> that applies to the specified <code>FilterInvocation</code>
56: */
57: public abstract ConfigAttributeDefinition lookupAttributes(
58: String url);
59:
60: public boolean supports(Class clazz) {
61: return FilterInvocation.class.isAssignableFrom(clazz);
62: }
63: }
|