- Revision
- 843
- Author
- mauro
- Date
- 2008-09-15 12:54:28 -0500 (Mon, 15 Sep 2008)
Log Message
WAFFLE-96: Added I18N support to action method interceptors.
Modified Paths
Diff
Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/action/intercept/SecurityMethodInterceptor.java (842 => 843)
--- trunk/waffle-core/src/main/java/org/codehaus/waffle/action/intercept/SecurityMethodInterceptor.java 2008-09-15 17:46:57 UTC (rev 842) +++ trunk/waffle-core/src/main/java/org/codehaus/waffle/action/intercept/SecurityMethodInterceptor.java 2008-09-15 17:54:28 UTC (rev 843) @@ -3,44 +3,61 @@ */ package org.codehaus.waffle.action.intercept; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + import org.codehaus.waffle.action.ActionMethodInvocationException; import org.codehaus.waffle.action.annotation.ActionMethod; import org.codehaus.waffle.controller.ControllerDefinition; +import org.codehaus.waffle.i18n.DefaultMessageResources; +import org.codehaus.waffle.i18n.MessageResources; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - /** - * <p>This interceptor ensure that only [EMAIL PROTECTED] ActionMethod} annotated methods are invokable as [EMAIL PROTECTED] Actions}. - * Usage of this will help protect your application against malicious attacks. + * <p> + * This interceptor ensure that only [EMAIL PROTECTED] ActionMethod} annotated methods are invokable as [EMAIL PROTECTED] Actions}. Usage of + * this will help protect your application against malicious attacks. + * </p> + * + * @author Micheal Ward */ public class SecurityMethodInterceptor implements MethodInterceptor { + private final MessageResources messageResources; + + public SecurityMethodInterceptor() { + this(new DefaultMessageResources()); + } + + public SecurityMethodInterceptor(MessageResources messageResources) { + this.messageResources = messageResources; + } + /** - * Will always return true (intercepts ALL action methods) - * - * [EMAIL PROTECTED] + * Will always return true (intercepts ALL action methods) [EMAIL PROTECTED] */ public boolean accept(Method actionMethod) { return true; // intercept all!!!! } /** - * Ensure that the action method tobe invoked is annotated with the [EMAIL PROTECTED] ActionMethod} annotation. If no annotation - * is present a [EMAIL PROTECTED] ActionMethodInvocationException} will be thrown. - * + * <p> + * Ensure that the action method to be invoked is annotated with the [EMAIL PROTECTED] ActionMethod} annotation. If no + * annotation is present a [EMAIL PROTECTED] ActionMethodInvocationException} will be thrown. + * </p> + * <p> * [EMAIL PROTECTED] + * </p> */ - public Object intercept(ControllerDefinition controllerDefinition, - Method method, - InterceptorChain chain, - Object... arguments) throws IllegalAccessException, InvocationTargetException { + public Object intercept(ControllerDefinition controllerDefinition, Method method, InterceptorChain chain, + Object... arguments) throws IllegalAccessException, InvocationTargetException { if (method.isAnnotationPresent(ActionMethod.class)) { return chain.proceed(controllerDefinition, method, arguments); } // Only notify that the requested action could not invoked do NOT give any detailed information (Security Risk) - throw new ActionMethodInvocationException("Requested action method cannot be invoke remotely."); + String message = messageResources.getMessageWithDefault("actionMethodCannotBeInvoked", + "Action method cannot be invoked"); + throw new ActionMethodInvocationException(message); } }
Modified: trunk/waffle-core/src/main/resources/waffle-bundle.properties (842 => 843)
--- trunk/waffle-core/src/main/resources/waffle-bundle.properties 2008-09-15 17:46:57 UTC (rev 842) +++ trunk/waffle-core/src/main/resources/waffle-bundle.properties 2008-09-15 17:54:28 UTC (rev 843) @@ -1,3 +1,4 @@ +actionMethodCannotBeInvoked=Action method cannot be invoked. actionMethodInvocationFailed=Action method invocation failed for controller ''{0}'' ambiguousActionMethodSignature=Action method ''{0}'' has ambiguous signature among methods ''{1}'' noDefaultActionMethod=Method ''{0}'' is not annotated with @ActionMethod(asDefault=true)
To unsubscribe from this list please visit:
