public CliManagerImpl(Channel channel) { this.channel = channel; channel.addLocalExecutionInterceptor(authenticationFilter); }
public CliManagerImpl(Channel channel) { this.channel = channel; channel.addLocalExecutionInterceptor(authenticationFilter); }
/** * @deprecated * use {@link #addLocalExecutionInterceptor(CallableDecorator)} */ @Deprecated public void addLocalExecutionInterceptor(CallableFilter filter) { addLocalExecutionInterceptor(new CallableDecoratorAdapter(filter)); }
public void testFilter() throws Exception { channel.addLocalExecutionInterceptor(new CallableFilter() { public <V> V call(Callable<V> callable) throws Exception { Object old = STORE.get(); STORE.set("x"); try { return callable.call(); } finally { STORE.set(old); } } }); Callable<Object> t = new Callable<Object>() { public Object call() throws Exception { return STORE.get(); } }; final Callable c = channel.export(Callable.class, t); assertEquals("x", channel.call(new CallableCallable(c))); }
public void testBlacklisting() throws Exception { channel.addLocalExecutionInterceptor(new CallableDecorator() { @Override public <V, T extends Throwable> hudson.remoting.Callable<V, T> userRequest(hudson.remoting.Callable<V, T> op, hudson.remoting.Callable<V, T> stem) { if (op instanceof ShadyBusiness) throw new SecurityException("Rejecting "+op.getClass().getName()); return stem; } }); // this direction is unrestricted assertEquals("gun",channel.call(new GunImporter())); // the other direction should be rejected try { channel.call(new ReverseGunImporter()); fail("should have failed"); } catch (Exception e) { assertEquals("Rejecting "+GunImporter.class.getName(), findSecurityException(e).getMessage()); // e.printStackTrace(); } } private static SecurityException findSecurityException(Throwable x) {