/** * Authenticate ourselves against the server. * * @return * identity of the server represented as a public key. * @deprecated Specific to {@link Mode#REMOTING}. */ @Deprecated public PublicKey authenticate(Iterable<KeyPair> privateKeys) throws IOException, GeneralSecurityException { Pipe c2s = Pipe.createLocalToRemote(); Pipe s2c = Pipe.createRemoteToLocal(); entryPoint.authenticate("ssh",c2s, s2c); Connection c = new Connection(s2c.getIn(), c2s.getOut()); try { byte[] sharedSecret = c.diffieHellman(false).generateSecret(); PublicKey serverIdentity = c.verifyIdentity(sharedSecret); // try all the public keys for (KeyPair key : privateKeys) { c.proveIdentity(sharedSecret,key); if (c.readBoolean()) return serverIdentity; // succeeded } if (privateKeys.iterator().hasNext()) throw new GeneralSecurityException("Authentication failed. No private key accepted."); else throw new GeneralSecurityException("No private key is available for use in authentication"); } finally { c.close(); } }
if(this.channel==null) { final Pipe pipe = Pipe.createLocalToRemote();
private Object writeReplace() { Pipe p = Pipe.createLocalToRemote(); // the thread will terminate when there's nothing more to read. new StreamCopyThread("Stream reader: maven process at "+socket,in,p.getOut(),true).start(); return new Connection(p,new RemoteOutputStream(out)); }
Pipe pipe = Pipe.createLocalToRemote(); final InputStream i = core; final OutputStream o = pipe.getOut();
public void testLocalWrite2() throws Exception { Pipe p = Pipe.createLocalToRemote(); Future<Integer> f = channel.callAsync(new ReadingCallable(p)); Thread.sleep(2000); // wait for remote to connect to local. write(p); int r = f.get(); System.out.println("result=" + r); assertEquals(5,r); }
public static void main(String[] args) throws Exception { byte[] payload = getRandomSequence(); byte[] digest = digest(new ByteArrayInputStream(payload)); while (true) { Socket s = new Socket("127.0.0.2",Receiver.PORT); s.setTcpNoDelay(true); Channel ch = new Channel("bogus", Executors.newCachedThreadPool(), new BufferedInputStream(SocketChannelStream.in(s)), new BufferedOutputStream(SocketChannelStream.out(s))); final Pipe p = Pipe.createLocalToRemote(); Future<byte[]> f = ch.callAsync(new DigestCallable(p)); System.out.println("Started"); long start = System.nanoTime(); IOUtils.copy(new ByteArrayInputStream(payload),p.getOut()); p.getOut().close(); f.get(); System.out.println("Done: "+ TimeUnit.NANOSECONDS.toMillis(System.nanoTime()-start)); assertArrayEquals(digest, f.get()); // verify the correctness of the result ch.close(); ch.join(); s.close(); } }
/** * Writer end closes even before the remote computation kicks in. */ public void testQuickBurstWrite() throws Exception { final Pipe p = Pipe.createLocalToRemote(); Future<Integer> f = channel.callAsync(new QuickBurstCallable(p)); OutputStream os = p.getOut(); os.write(1); os.close(); // at this point the async executable kicks in. // TODO: introduce a lock to ensure the ordering. assertEquals(1,(int)f.get()); }
/** * Test the "local-write remote-read" pipe. */ public void testLocalWrite() throws Exception { Pipe p = Pipe.createLocalToRemote(); Future<Integer> f = channel.callAsync(new ReadingCallable(p)); write(p); int r = f.get(); System.out.println("result=" + r); assertEquals(5,r); }
if(this.channel==null) { final Pipe pipe = Pipe.createLocalToRemote();
return; // can't do this test without the throttling support. final Pipe p = Pipe.createLocalToRemote();
final Pipe pipe = Pipe.createLocalToRemote();
final hudson.remoting.Pipe p = hudson.remoting.Pipe.createLocalToRemote();
} else if (this.channel == null) { final Pipe pipe = Pipe.createLocalToRemote();
} else if (this.channel == null) { final Pipe pipe = Pipe.createLocalToRemote();
} else if (this.channel == null) { final Pipe pipe = Pipe.createLocalToRemote();
} else if (this.channel == null) { final Pipe pipe = Pipe.createLocalToRemote(); final NativeUtils nativeUtils = NativeUtils.getInstance(); Future<Void> future = target.actAsync(new FileCallable<Void>() {
final hudson.remoting.Pipe p = hudson.remoting.Pipe.createLocalToRemote();