View Javadoc

1   package test.crispy.example.interceptor;
2   
3   import net.sf.crispy.InterceptorContext;
4   import net.sf.crispy.Modifier;
5   
6   public class AddSecurityTokenModifier implements Modifier {
7   
8   	public static final String SERCURITY_TEST_TOKEN = "MyTestSecurityToken 1";
9   	
10  	/**
11  	 * Set on the first position a security token. All args index are moved one position higher.
12  	 */
13  	public InterceptorContext modifyBeforeInvocation(InterceptorContext pvInterceptorContext) {
14  		int lvLengthArgs = pvInterceptorContext.getArgs().length;
15  		Object lvArgs[] = new Object[lvLengthArgs + 1];
16  		for (int i=0;i<lvLengthArgs; i++) {
17  			lvArgs[i+1] = pvInterceptorContext.getArgs()[i];
18  		}
19  		lvArgs[0] = SERCURITY_TEST_TOKEN;
20  		pvInterceptorContext.setArgs(lvArgs);
21  		return pvInterceptorContext;
22  	}
23  
24  	public InterceptorContext modifyAfterInvocation(InterceptorContext pvInterceptorContext) {
25  		return pvInterceptorContext;
26  	}
27  
28  }