01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.security;
06:
07: import org.acegisecurity.intercept.AbstractSecurityInterceptor;
08: import org.acegisecurity.intercept.InterceptorStatusToken;
09: import org.acegisecurity.intercept.ObjectDefinitionSource;
10: import org.geoserver.ows.security.OperationInterceptor;
11: import org.geoserver.platform.Operation;
12: import java.lang.reflect.InvocationTargetException;
13: import java.lang.reflect.Method;
14:
15: public class OperationSecurityInterceptor extends
16: AbstractSecurityInterceptor implements OperationInterceptor {
17: private OperationDefinitionSource objectDefinitionSource;
18:
19: public Class getSecureObjectClass() {
20: return Operation.class;
21: }
22:
23: public ObjectDefinitionSource obtainObjectDefinitionSource() {
24: return this .objectDefinitionSource;
25: }
26:
27: public void setObjectDefinitionSource(
28: OperationDefinitionSource newSource) {
29: this .objectDefinitionSource = newSource;
30: }
31:
32: protected InterceptorStatusToken beforeInvocation(Object object) {
33: return super .beforeInvocation(object);
34: }
35:
36: public Object invoke(Operation operation, Method method,
37: Object serviceBean, Object[] parameters)
38: throws InvocationTargetException, IllegalArgumentException,
39: IllegalAccessException {
40: InterceptorStatusToken token = super
41: .beforeInvocation(operation);
42:
43: try {
44: return method.invoke(serviceBean, parameters);
45: } finally {
46: super.afterInvocation(token, null);
47: }
48: }
49: }
|