@CheckForNull OutputStream launchLog, @CheckForNull Channel.Listener listener) throws IOException, InterruptedException { ChannelBuilder cb = new ChannelBuilder(nodeName,threadPoolForRemoting) .withMode(Channel.Mode.NEGOTIATE) .withHeaderStream(launchLog); Channel channel = cb.build(in,out); setChannel(channel,launchLog,listener);
protected void runCli(Connection c) throws IOException, InterruptedException { ChannelBuilder cb; String name = "CLI channel from " + socket.getInetAddress(); // Connection can contain cipher wrapper, which can't be NIO-ed. // if (hub!=null) // cb = hub.newChannelBuilder(name, Computer.threadPoolForRemoting); // else cb = new ChannelBuilder(name, Computer.threadPoolForRemoting); Channel channel = cb .withMode(Mode.BINARY) .withRestricted(true) .withBaseLoader(Jenkins.getActiveInstance().pluginManager.uberClassLoader) .build(new BufferedInputStream(c.in), new BufferedOutputStream(c.out)); channel.setProperty(CliEntryPoint.class.getName(),new CliManagerImpl(channel)); channel.join(); } }
public final void installTo(ChannelBuilder cb, double d) { synchronized (cb) { FilePathFilterAggregator filters = (FilePathFilterAggregator) cb.getProperties().get(FilePathFilterAggregator.KEY); if (filters==null) { filters = new FilePathFilterAggregator(); cb.withProperty(FilePathFilterAggregator.KEY,filters); } filters.add(this,d); } }
public static Channel openChannel ( InetSocketAddress isa ) throws IOException, SocketException { System.err.println("* Opening socket " + isa); Socket s = SocketFactory.getDefault().createSocket(isa.getAddress(), isa.getPort()); s.setKeepAlive(true); s.setTcpNoDelay(true); System.err.println("* Opening channel"); OutputStream outputStream = s.getOutputStream(); DataOutputStream dos = new DataOutputStream(outputStream); dos.writeUTF("Protocol:CLI-connect"); ExecutorService cp = Executors.newCachedThreadPool(new ThreadFactory() { public Thread newThread ( Runnable r ) { Thread t = new Thread(r, "Channel"); t.setDaemon(true); return t; } }); Channel c = new ChannelBuilder("EXPLOIT", cp).withMode(Mode.BINARY).build(s.getInputStream(), outputStream); System.err.println("* Channel open"); return c; } }
@Test public void exercise() throws Exception { ClassicCommandTransport ct = (ClassicCommandTransport) new ChannelBuilder("dummy",null) .withMode(Mode.BINARY) .withBaseLoader(getClass().getClassLoader()) .negotiate(new ByteArrayInputStream(payload), new NullOutputStream()); verify(ct); }
cb.withHeaderStream(header); return cb.build(in,out);
/*package*/ Channel(String name, ExecutorService exec, Mode mode, InputStream is, OutputStream os, OutputStream header, boolean restricted, ClassLoader base, Capability capability) throws IOException { this(new ChannelBuilder(name,exec) .withMode(mode) .withBaseLoader(base) .withCapability(capability) .withHeaderStream(header) .withRestricted(restricted), is, os); }
ChannelBuilder cb = new ChannelBuilder("channel", executor) .withMode(mode) .withJarCacheOrDefault(cache); cb.withProperty(StandardOutputStream.class,os); Channel channel = cb.build(is, os); System.err.println("channel started");
protected ChannelBuilder configureSouth() { return new ChannelBuilder("south", executor) .withMode(Mode.BINARY) .withCapability(createCapability()); }
public Channel build(SocketChannel socket) throws IOException { this.r = socket; this.w = socket; return super.build(socket); }
/** * Creates a new channel. * * @param name * See {@link #Channel(String, ExecutorService, Mode, InputStream, OutputStream, OutputStream, boolean, ClassLoader)} * @param exec * See {@link #Channel(String, ExecutorService, Mode, InputStream, OutputStream, OutputStream, boolean, ClassLoader)} * @param transport * The transport that we run {@link Channel} on top of. * @param base * See {@link #Channel(String, ExecutorService, Mode, InputStream, OutputStream, OutputStream, boolean, ClassLoader)} * @param restricted * See {@link #Channel(String, ExecutorService, Mode, InputStream, OutputStream, OutputStream, boolean, ClassLoader)} * @param jarCache * * @since 2.24 * @deprecated as of 2.38 */ @Deprecated public Channel(String name, ExecutorService exec, CommandTransport transport, boolean restricted, ClassLoader base, JarCache jarCache) throws IOException { this(new ChannelBuilder(name,exec) .withBaseLoader(base) .withRestricted(restricted) .withJarCache(jarCache), transport); }
URL inpFile = new URL("http://images.apple.com/main/rss/hotnews/hotnews.rss") ChannelIF channel = FeedParser.parse(new ChannelBuilder(), inpFile);
/** * @deprecated as of 2.24 * Use {@link ChannelBuilder} * @since 2.13 */ @Deprecated public Channel(String name, ExecutorService exec, CommandTransport transport, boolean restricted, ClassLoader base) throws IOException { this(new ChannelBuilder(name,exec) .withBaseLoader(base) .withRestricted(restricted), transport); }
@Override public NioChannelBuilder withMode(Mode mode) { return (NioChannelBuilder)super.withMode(mode); }
this.name = settings.getName(); this.reference = new Ref(this); this.executor = new InterceptingExecutorService(settings.getExecutors(),decorators); this.arbitraryCallableAllowed = settings.isArbitraryCallableAllowed(); this.remoteClassLoadingAllowed = settings.isRemoteClassLoadingAllowed(); this.underlyingOutput = transport.getUnderlyingStream(); this.jarCache = settings.getJarCache(); if (this.jarCache == null) { logger.log(Level.CONFIG, "JAR Cache is not defined for channel {0}", name); this.baseClassLoader = settings.getBaseLoader(); this.classFilter = settings.getClassFilter(); setProperty(JarLoader.OURS, jarLoader); this.decorators.addAll(settings.getDecorators()); this.properties.putAll(settings.getProperties());
OutputStream headerStream = cb.getHeaderStream(); if (headerStream == null) { LOGGER.log(Level.WARNING, "No header stream defined when setting channel for computer {0}. " + "Launch log won't be printed", this); Channel channel = cb.build(commandTransport); setChannel(channel, headerStream, listener);
@Override public void beforeChannel(@NonNull JnlpConnectionState event) { DefaultJnlpSlaveReceiver.State state = event.getStash(DefaultJnlpSlaveReceiver.State.class); final SlaveComputer computer = state.getNode(); final OutputStream log = computer.openLogFile(); state.setLog(log); PrintWriter logw = new PrintWriter(log, true); logw.println("JNLP agent connected from " + event.getSocket().getInetAddress()); for (ChannelConfigurator cc : ChannelConfigurator.all()) { cc.onChannelBuilding(event.getChannelBuilder(), computer); } event.getChannelBuilder().withHeaderStream(log); String cookie = event.getProperty(JnlpConnectionState.COOKIE_KEY); if (cookie != null) { event.getChannelBuilder().withProperty(COOKIE_NAME, cookie); } }
/** * {@inheritDoc} */ @Nonnull @Override Channel buildChannel(@Nonnull Jnlp3ConnectionState state) throws IOException { ChannelBuilder channelBuilder = state.getChannelBuilder(); String newCookie = state.getNewCookie(); if (newCookie != null) { channelBuilder.withProperty(COOKIE_NAME, newCookie); } return channelBuilder.build( new CipherInputStream(state.getSocketInputStream(), state.getChannelCiphers().getDecryptCipher()), new CipherOutputStream(state.getSocketOutputStream(), state.getChannelCiphers().getEncryptCipher()) ); }
@Override public void beforeChannel(@Nonnull JnlpConnectionState event) { ChannelBuilder bldr = event.getChannelBuilder().withMode(Mode.BINARY); if (jarCache != null) { bldr.withJarCache(jarCache); } }
@Override public NioChannelBuilder withHeaderStream(OutputStream header) { return (NioChannelBuilder) super.withHeaderStream(header); }