1 /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * 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.springframework.security.intercept;
17
18 import org.springframework.security.ConfigAttributeDefinition;
19
20 import java.util.Collection;
21
22
23 /**
24 * Implemented by classes that store and can identify the {@link
25 * ConfigAttributeDefinition} that applies to a given secure object
26 * invocation.
27 *
28 * @author Ben Alex
29 * @version $Id: ObjectDefinitionSource.java 2748 2008-03-17 14:10:22Z luke_t $
30 */
31 public interface ObjectDefinitionSource {
32 //~ Methods ========================================================================================================
33
34 /**
35 * Accesses the <code>ConfigAttributeDefinition</code> that applies to a given secure object.<P>Returns
36 * <code>null</code> if no <code>ConfigAttribiteDefinition</code> applies.</p>
37 *
38 * @param object the object being secured
39 *
40 * @return the <code>ConfigAttributeDefinition</code> that applies to the passed object
41 *
42 * @throws IllegalArgumentException if the passed object is not of a type supported by the
43 * <code>ObjectDefinitionSource</code> implementation
44 */
45 ConfigAttributeDefinition getAttributes(Object object) throws IllegalArgumentException;
46
47 /**
48 * If available, returns all of the <code>ConfigAttributeDefinition</code>s defined by the implementing class.
49 * <p>
50 * This is used by the {@link AbstractSecurityInterceptor} to perform startup time validation of each
51 * <code>ConfigAttribute</code> configured against it.
52 *
53 * @return the <code>ConfigAttributeDefinition</code>s or <code>null</code> if unsupported
54 */
55 Collection getConfigAttributeDefinitions();
56
57 /**
58 * Indicates whether the <code>ObjectDefinitionSource</code> implementation is able to provide
59 * <code>ConfigAttributeDefinition</code>s for the indicated secure object type.
60 *
61 * @param clazz the class that is being queried
62 *
63 * @return true if the implementation can process the indicated class
64 */
65 boolean supports(Class clazz);
66 }