pax_global_header00006660000000000000000000000064122724320600014510gustar00rootroot0000000000000052 comment=a6f8649970bba355352cd416422802151fd7369a jsch-agent-proxy-0.0.7/000077500000000000000000000000001227243206000147165ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/.gitignore000066400000000000000000000006471227243206000167150ustar00rootroot00000000000000!.gitignore *.gz *.zip *.md5 *.sha1 bin/* build build.eclipse build.properties target dist lib nbproject/private share latest_source_cache docs/api *.orig *.rej *~ .debug.properties test/testapp/testapp glob_test spaces test .DS_Store *.so *.bundle *.[oa] dev_null .redcar /.externalToolBuilders/ /.settings/ .metadata .idea/workspace.xml shared.iml build_graph.png /.idea/ lib_managed/ project/build/target/ project/boot/ jsch-agent-proxy-0.0.7/LICENSE.txt000066400000000000000000000026621227243206000165470ustar00rootroot00000000000000Copyright (c) 2012 Atsuhiko Yamanaka, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. jsch-agent-proxy-0.0.7/README000066400000000000000000000077341227243206000156110ustar00rootroot00000000000000jsch-agent-proxy -- a proxy to ssh-agent and Pageant in Java. Description =========== jsch-agent-proxy is a proxy program to OpenSSH's ssh-agent and Pageant included Putty. It will be easily integrated into JSch, and users will be allowed to use those programs in authentications. This software has been developed for JSch, but it will be easily applicable to other ssh2 implementations in Java. This software is licensed under BSD style license. Build ===== $ git clone git://github.com/ymnk/jsch-agent-proxy.git $ cd jsch-agent-proxy $ mvn package $ mvn install Examples ======== * UsingPageant.java This sample demonstrates how to get accesses to Pageant. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.UsingPageant" * UsingSSHAent.java This sample demonstrates how to get accesses to ssh-agent. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.UsingSSHAgent" * JSchWithAgentProxy.java This sample demonstrates how to integrate jsch-agent-proxy into JSch. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.JSchWithAgentProxy" \ -Dexec.args="foo@bar.com" * SshjWithAgentProxy.java This sample demonstrates how to integrate jsch-agent-proxy into sshj. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.SshjWithAgentProxy" \ -Dexec.args="foo@bar.com" * TrileadWithAgentProxy.java This sample demonstrates how to integrate jsch-agent-proxy into Trilead SSH2 (SVNKit fork). $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.TrileadWithAgentProxy" \ -Dexec.args="foo@bar.com date" Dependencies ============ To work as a proxy to ssh-agent and Pageant, the current implementation depends on the following software * JNA: https://github.com/twall/jna licensed under the GNU LGPL * junixsocket: http://code.google.com/p/junixsocket/ licensed under the Apache License 2.0 * OpenBSD's netcat: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/nc/ As for connections to ssh-agent, unix domain sockets must be handled, and JNA or junixsocket have been used for that purpose. Refer to to following classes, * com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory[1] * com.jcraft.jsch.agentproxy.usocket.JUnixDomainSocketFactory[2] * com.jcraft.jsch.agentproxy.usocket.NCUSocketFactory[3] NCUSocketFactory expects the external command nc(OpenBSD's netcat), but you don't have to install other third party software. As for connections to Pageant, win32 APIs must be handled, and JNA has been used in the current implementation for that purpose. Refer to the following class, * com.jcraft.jsch.agentproxy.connector.PageantConnector[3] If you want to be free from JNA and junixsocket, implement following interfaces without them, * com.jcraft.jsch.agentproxy.Connector[4] * com.jcraft.jsch.agentproxy.USocketFactory[5] [1] https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-usocket-jna/src/main/java/com/jcraft/jsch/agentproxy/usocket/JNAUSocketFactory.java [2] https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-usocket-junixsocket/src/main/java/com/jcraft/jsch/agentproxy/usocket/JUnixDomainSocketFactory.java [3] https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-usocket-nc/src/main/java/com/jcraft/jsch/agentproxy/usocket/NCUSocketFactory.java [4] https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-pageant/src/main/java/com/jcraft/jsch/agentproxy/connector/PageantConnector.java [5] https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-sshagent/src/main/java/com/jcraft/jsch/agentproxy/Connector.java [6] https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-core/src/main/java/com/jcraft/jsch/agentproxy/USocketFactory.java jsch-agent-proxy-0.0.7/README.md000066400000000000000000000117601227243206000162020ustar00rootroot00000000000000# jsch-agent-proxy a proxy to ssh-agent and Pageant in Java. ## Description **jsch-agent-proxy** is a proxy program to [OpenSSH](http://www.openssh.com/)'s [ssh-agent](http://en.wikipedia.org/wiki/Ssh-agent) and [Pageant](http://en.wikipedia.org/wiki/PuTTY#Applications) included [Putty](http://www.chiark.greenend.org.uk/~sgtatham/putty/). It will be easily integrated into [JSch](http://www.jcraft.com/jsch/), and users will be allowed to use those programs in authentications. This software has been developed for JSch, but it will be easily applicable to other ssh2 implementations in Java. This software is licensed under [BSD style license](https://github.com/ymnk/jsch-agent-proxy/blob/master/LICENSE.txt). ## Build from Source $ git clone git://github.com/ymnk/jsch-agent-proxy.git $ cd jsch-agent-proxy $ mvn package $ mvn install ## Examples + [UsingPageant.java](https://github.com/ymnk/jsch-agent-proxy/blob/master/examples/src/main/java/com/jcraft/jsch/agentproxy/examples/UsingPageant.java) This sample demonstrates how to get accesses to Pageant. $ cd examples $ cd compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.UsingPageant" + [UsingSSHAent.java](https://github.com/ymnk/jsch-agent-proxy/blob/master/examples/src/main/java/com/jcraft/jsch/agentproxy/examples/UsingSSHAgent.java) This sample demonstrates how to get accesses to ssh-agent. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.UsingSSHAgent" + [JSchWithAgentProxy.java](https://github.com/ymnk/jsch-agent-proxy/blob/master/examples/src/main/java/com/jcraft/jsch/agentproxy/examples/JSchWithAgentProxy.java) This sample demonstrates how to integrate jsch-agent-proxy into JSch. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.JSchWithAgentProxy" \ -Dexec.args="foo@bar.com" + [SshjWithAgentProxy.java](https://github.com/ymnk/jsch-agent-proxy/blob/master/examples/src/main/java/com/jcraft/jsch/agentproxy/examples/SshjWithAgentProxy.java) This sample demonstrates how to integrate jsch-agent-proxy into sshj. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.SshjWithAgentProxy" \ -Dexec.args="foo@bar.com" + [TrileadWithAgentProxy.java](https://github.com/ymnk/jsch-agent-proxy/blob/master/examples/src/main/java/com/jcraft/jsch/agentproxy/examples/TrileadWithAgentProxy.java) This sample demonstrates how to integrate jsch-agent-proxy into Trilead SSH2 (SVNKit fork). $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.TrileadWithAgentProxy" \ -Dexec.args="foo@bar.com date" ## Dependencies To work as a proxy to ssh-agent and Pageant, the current implementation depends on the following software, + JNA: https://github.com/twall/jna licensed under the [GNU LGPL](https://github.com/twall/jna/blob/master/LICENSE) + junixsocket: http://code.google.com/p/junixsocket/ licensed under the [Apache License 2.0](http://code.google.com/p/junixsocket/source/browse/trunk/junixsocket/LICENSE.txt) + OpenBSD's netcat: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/nc/ As for connections to ssh-agent, unix domain sockets must be handled, and the current implementation has been using JNA or junixsocket for that purpose. Refer to following classes, + [com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory](https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-usocket-jna/src/main/java/com/jcraft/jsch/agentproxy/usocket/JNAUSocketFactory.java) + [com.jcraft.jsch.agentproxy.usocket.JUnixDomainSocketFactory](https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-usocket-junixsocket/src/main/java/com/jcraft/jsch/agentproxy/usocket/JUnixDomainSocketFactory.java) + [com.jcraft.jsch.agentproxy.usocket.NCUSocketFactory](https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-usocket-nc/src/main/java/com/jcraft/jsch/agentproxy/usocket/NCUSocketFactory.java) NCUSocketFactory expects the external command nc(OpenBSD's netcat), but you don't have to install other third party software. As for connections to Pageant, win32 APIs must be handled, and JNA has been used in the current implementation for that purpose. Refer to the following class, + [com.jcraft.jsch.agentproxy.connector.PageantConnector](https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-pageant/src/main/java/com/jcraft/jsch/agentproxy/connector/PageantConnector.java) If you want to be free from JNA and junixsocket, implement following interfaces without them, + [com.jcraft.jsch.agentproxy.Connector](https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-core/src/main/java/com/jcraft/jsch/agentproxy/Connector.java) + [com.jcraft.jsch.agentproxy.USocketFactory](https://github.com/ymnk/jsch-agent-proxy/blob/master/jsch-agent-proxy-core/src/main/java/com/jcraft/jsch/agentproxy/USocketFactory.java) jsch-agent-proxy-0.0.7/examples/000077500000000000000000000000001227243206000165345ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/README000066400000000000000000000023431227243206000174160ustar00rootroot00000000000000README * UsingPageant.java This sample demonstrates how to get accesses to Pageant. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.UsingPageant" * UsingSSHAent.java This sample demonstrates how to get accesses to ssh-agent. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.UsingSSHAgent" * JSchWithAgentProxy.java This sample demonstrates how to integrate jsch-agent-proxy into JSch. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.JSchWithAgentProxy" \ -Dexec.args="foo@bar.com" * SshjWithAgentProxy.java This sample demonstrates how to integrate jsch-agent-proxy into sshj. $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.SshjWithAgentProxy" \ -Dexec.args="foo@bar.com" * TrileadWithAgentProxy.java This sample demonstrates how to integrate jsch-agent-proxy into Trilead SSH2 (SVNKit fork). $ cd examples $ mvn compile $ mvn exec:java \ -Dexec.mainClass="com.jcraft.jsch.agentproxy.examples.TrileadWithAgentProxy" \ -Dexec.args="foo@bar.com date" jsch-agent-proxy-0.0.7/examples/pom.xml000066400000000000000000000056071227243206000200610ustar00rootroot00000000000000 4.0.0 com.jcraft jsch.agentproxy.examples 0.0.7 examples to demonstrate how to use jsch-agent-proxy com.jcraft jsch.agentproxy.core ${project.version} com.jcraft jsch.agentproxy.jsch ${project.version} com.jcraft jsch.agentproxy.pageant ${project.version} com.jcraft jsch.agentproxy.sshagent ${project.version} com.jcraft jsch.agentproxy.usocket-jna ${project.version} com.jcraft jsch.agentproxy.usocket-nc ${project.version} com.jcraft jsch.agentproxy.connector-factory ${project.version} com.jcraft jsch.agentproxy.sshj ${project.version} com.trilead trilead-ssh2 1.0.0-build217 com.jcraft jsch.agentproxy.svnkit-trilead-ssh2 ${project.version} org.apache.maven.plugins maven-jar-plugin 2.3.2 UTF-8 UTF-8 jsch-agent-proxy-0.0.7/examples/src/000077500000000000000000000000001227243206000173235ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/src/main/000077500000000000000000000000001227243206000202475ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/src/main/java/000077500000000000000000000000001227243206000211705ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/src/main/java/com/000077500000000000000000000000001227243206000217465ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/src/main/java/com/jcraft/000077500000000000000000000000001227243206000232175ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000241465ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/src/main/java/com/jcraft/jsch/agentproxy/000077500000000000000000000000001227243206000263465ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/src/main/java/com/jcraft/jsch/agentproxy/examples/000077500000000000000000000000001227243206000301645ustar00rootroot00000000000000JSchWithAgentProxy.java000066400000000000000000000052421227243206000344570ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/src/main/java/com/jcraft/jsch/agentproxy/examples/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ package com.jcraft.jsch.agentproxy.examples; import com.jcraft.jsch.*; import com.jcraft.jsch.agentproxy.Connector; import com.jcraft.jsch.agentproxy.AgentProxyException; import com.jcraft.jsch.agentproxy.RemoteIdentityRepository; import com.jcraft.jsch.agentproxy.ConnectorFactory; import java.io.*; import javax.swing.*; public class JSchWithAgentProxy { public static void main(String[] arg){ try{ JSch jsch=new JSch(); jsch.setConfig("PreferredAuthentications", "publickey"); Connector con = null; try { ConnectorFactory cf = ConnectorFactory.getDefault(); con = cf.createConnector(); } catch(AgentProxyException e){ System.out.println(e); } if(con != null ){ IdentityRepository irepo = new RemoteIdentityRepository(con); jsch.setIdentityRepository(irepo); } String host=null; if(arg.length>0){ host=arg[0]; } else{ host=JOptionPane.showInputDialog("Enter username@hostname", System.getProperty("user.name")+ "@localhost"); } String user=host.substring(0, host.indexOf('@')); host=host.substring(host.indexOf('@')+1); Session session=jsch.getSession(user, host, 22); // username and passphrase will be given via UserInfo interface. UserInfo ui=new MyUserInfo(); session.setUserInfo(ui); session.connect(); Channel channel=session.openChannel("shell"); ((ChannelShell)channel).setAgentForwarding(true); channel.setInputStream(System.in); channel.setOutputStream(System.out); channel.connect(); } catch(Exception e){ System.out.println(e); } } public static class MyUserInfo implements UserInfo, UIKeyboardInteractive{ public String getPassword(){ return passwd; } public boolean promptYesNo(String str){ return true; } String passwd=null; public String getPassphrase(){ return null; } public boolean promptPassphrase(String message){ return true; } public boolean promptPassword(String message){ return true; } public void showMessage(String message){ } public String[] promptKeyboardInteractive(String destination, String name, String instruction, String[] prompt, boolean[] echo){ String[] response=new String[prompt.length]; response[0] = passwd; return response; } } } SshjWithAgentProxy.java000066400000000000000000000051221227243206000345340ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/src/main/java/com/jcraft/jsch/agentproxy/examples/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ package com.jcraft.jsch.agentproxy.examples; import java.io.*; import java.util.*; import javax.swing.*; import com.jcraft.jsch.agentproxy.*; import com.jcraft.jsch.agentproxy.usocket.*; import com.jcraft.jsch.agentproxy.connector.*; import com.jcraft.jsch.agentproxy.sshj.*; import net.schmizz.sshj.*; import net.schmizz.sshj.connection.channel.direct.*; import net.schmizz.sshj.userauth.method.AuthMethod; public class SshjWithAgentProxy { public static void main(String[] args) throws Exception { String target = getTarget(args); String username = target.substring(0, target.indexOf('@')); String hostname = target.substring(target.indexOf('@') + 1); AgentProxy agentProxy = getAgentProxy(); if (agentProxy == null) { fail("Could not find or connect to an agent"); } SSHClient client = new SSHClient(); client.loadKnownHosts(); client.connect(hostname); client.auth(username, getAuthMethods(agentProxy)); Session session = client.startSession(); Session.Command command = session.exec("ls -l"); BufferedReader reader = new BufferedReader(new InputStreamReader(command.getInputStream())); String line; while ((line = reader.readLine()) != null) { System.out.println(line); } session.join(); client.close(); } private static String getTarget(String[] args) { if (args.length > 0) { return args[0]; } else { return JOptionPane.showInputDialog("Enter username@hostname", System.getProperty("user.name") + "@localhost"); } } private static void fail(String message) { System.err.println(message); System.exit(1); } private static AgentProxy getAgentProxy() { Connector connector = getAgentConnector(); if (connector != null) return new AgentProxy(connector); return null; } private static Connector getAgentConnector() { try { return ConnectorFactory.getDefault().createConnector(); } catch (AgentProxyException e) { System.err.println(e); } return null; } private static List getAuthMethods(AgentProxy agent) throws Exception { Identity[] identities = agent.getIdentities(); List result = new ArrayList(); for (Identity identity : identities) { result.add(new AuthAgent(agent, identity)); } return result; } }TrileadWithAgentProxy.java000066400000000000000000000043711227243206000352160ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/examples/src/main/java/com/jcraft/jsch/agentproxy/examplespackage com.jcraft.jsch.agentproxy.examples; import com.jcraft.jsch.agentproxy.AgentProxyException; import com.jcraft.jsch.agentproxy.Connector; import com.jcraft.jsch.agentproxy.ConnectorFactory; import com.jcraft.jsch.agentproxy.TrileadAgentProxy; import com.trilead.ssh2.Connection; import com.trilead.ssh2.Session; import com.trilead.ssh2.StreamGobbler; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class TrileadWithAgentProxy { public static void main(String[] arg) throws IOException { if(arg.length != 2) { System.err.println("Usage: test-ssh user@host command"); System.exit(1); } int splitPoint = arg[0].indexOf("@"); if(splitPoint <= 0) { System.err.println("Usage: test-ssh user@host command"); System.exit(1); } String user = arg[0].substring(0, splitPoint); String host = arg[0].substring(splitPoint + 1); com.trilead.ssh2.auth.AgentProxy agentProxy = getAgentProxy(); if(agentProxy == null) { System.err.println("ERROR: Unable to connect to SSH agent"); System.exit(1); } Connection conn = new Connection(host); conn.connect(); boolean isAuthenticated = conn.authenticateWithAgent(user, agentProxy); if(isAuthenticated == false) { System.err.println("ERROR: Agent authentication not accepted"); System.exit(1); } Session sess = conn.openSession(); sess.execCommand(arg[1]); BufferedReader br = new BufferedReader(new InputStreamReader(new StreamGobbler(sess.getStdout()))); while(true) { String line = br.readLine(); if(line == null) { break; } System.out.println(line); } Integer exitStatus = sess.getExitStatus(); sess.close(); conn.close(); System.exit(exitStatus == null ? 1 : exitStatus); } static TrileadAgentProxy getAgentProxy() { try { Connector con = ConnectorFactory.getDefault().createConnector(); return new TrileadAgentProxy(con); } catch(AgentProxyException e) { return null; } } } jsch-agent-proxy-0.0.7/examples/src/main/java/com/jcraft/jsch/agentproxy/examples/UsingPageant.java000066400000000000000000000024731227243206000334220ustar00rootroot00000000000000/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ package com.jcraft.jsch.agentproxy.examples; import com.jcraft.jsch.agentproxy.AgentProxy; import com.jcraft.jsch.agentproxy.AgentProxyException; import com.jcraft.jsch.agentproxy.Identity; import com.jcraft.jsch.agentproxy.connector.PageantConnector; public class UsingPageant { public static void main(String[] arg){ try{ AgentProxy ap = new AgentProxy(new PageantConnector()); Identity[] identities = ap.getIdentities(); System.out.println("count: "+identities.length); for(int i=0; i "); for(int j=0; j "); for(int j=0; j 4.0.0 com.jcraft jsch.agentproxy 0.0.7 jsch.agentproxy.connector-factory a connector factory bundle com.jcraft jsch.agentproxy.core ${project.version} com.jcraft jsch.agentproxy.usocket-jna ${project.version} com.jcraft jsch.agentproxy.usocket-nc ${project.version} com.jcraft jsch.agentproxy.sshagent ${project.version} com.jcraft jsch.agentproxy.pageant ${project.version} org.apache.maven.plugins maven-jar-plugin 2.3.2 jsch-agent-proxy-0.0.7/jsch-agent-proxy-connector-factory/src/000077500000000000000000000000001227243206000243445ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-connector-factory/src/main/000077500000000000000000000000001227243206000252705ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-connector-factory/src/main/java/000077500000000000000000000000001227243206000262115ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-connector-factory/src/main/java/com/000077500000000000000000000000001227243206000267675ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-connector-factory/src/main/java/com/jcraft/000077500000000000000000000000001227243206000302405ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-connector-factory/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000311675ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-connector-factory/src/main/java/com/jcraft/jsch/agentproxy/000077500000000000000000000000001227243206000333675ustar00rootroot00000000000000ConnectorFactory.java000066400000000000000000000110501227243206000374320ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-connector-factory/src/main/java/com/jcraft/jsch/agentproxy/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2013 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy; import com.jcraft.jsch.agentproxy.Connector; import com.jcraft.jsch.agentproxy.AgentProxyException; import com.jcraft.jsch.agentproxy.USocketFactory; import com.jcraft.jsch.agentproxy.connector.SSHAgentConnector; import com.jcraft.jsch.agentproxy.connector.PageantConnector; import com.jcraft.jsch.agentproxy.usocket.NCUSocketFactory; import com.jcraft.jsch.agentproxy.usocket.JNAUSocketFactory; import java.util.ArrayList; public abstract class ConnectorFactory { protected String connectors = "pageant,ssh-agent"; protected String usocketFactories = "nc,jna"; public void setPreferredConnectors(String connectors) { this.connectors = connectors; } public String getPreferredConnectors() { return connectors; } public void setPreferredUSocketFactories(String usocketFactories){ this.usocketFactories = usocketFactories; } public String getPreferredUSocketFactories() { return usocketFactories; } public Connector createConnector() throws AgentProxyException { ArrayList trials = new ArrayList(); String[] _connectors = connectors.split(","); for(int i = 0; i < _connectors.length; i++) { if(_connectors[i].trim().equals("pageant")) { if(PageantConnector.isConnectorAvailable()) { try { return new PageantConnector(); } catch(AgentProxyException e){ trials.add("pageant"); } } } else if(_connectors[i].trim().equals("ssh-agent")) { if(!SSHAgentConnector.isConnectorAvailable()) continue; String[] _usocketFactories = usocketFactories.split(","); for(int j = 0; j < _usocketFactories.length; j++) { if(_usocketFactories[j].trim().equals("nc")) { try { USocketFactory usf = new NCUSocketFactory(); return new SSHAgentConnector(usf); } catch(AgentProxyException e){ trials.add("ssh-agent:nc"); } } else if(_usocketFactories[j].trim().equals("jna")) { try { USocketFactory usf = new JNAUSocketFactory(); return new SSHAgentConnector(usf); } catch(AgentProxyException e){ trials.add("ssh-agent:jna"); } } } } } String message = "connector is not available: "; String foo = ""; for(int i = 0; i < trials.size(); i++){ message += (foo + trials.get(i)); foo = ","; } throw new AgentProxyException(message); } public static ConnectorFactory getDefault() { return new Default(); } static class Default extends ConnectorFactory { Default() { String osName = System.getProperty("os.name"); if(osName != null){ if(!osName.startsWith("Windows")){ setPreferredConnectors("ssh-agent"); } /* // NetBSD's nc must be available since Mac OS X Tiger. if(osName.startsWith("Mac")){ setUSocketFactories("nc"); } */ } } } } jsch-agent-proxy-0.0.7/jsch-agent-proxy-core/000077500000000000000000000000001227243206000210465ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-core/pom.xml000066400000000000000000000014441227243206000223660ustar00rootroot00000000000000 4.0.0 com.jcraft jsch.agentproxy 0.0.7 jsch.agentproxy.core jsch-agent-proxy core library bundle org.apache.maven.plugins maven-jar-plugin 2.3.2 jsch-agent-proxy-0.0.7/jsch-agent-proxy-core/src/000077500000000000000000000000001227243206000216355ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-core/src/main/000077500000000000000000000000001227243206000225615ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-core/src/main/java/000077500000000000000000000000001227243206000235025ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-core/src/main/java/com/000077500000000000000000000000001227243206000242605ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-core/src/main/java/com/jcraft/000077500000000000000000000000001227243206000255315ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-core/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000264605ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-core/src/main/java/com/jcraft/jsch/agentproxy/000077500000000000000000000000001227243206000306605ustar00rootroot00000000000000AgentProxy.java000066400000000000000000000156511227243206000335540ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-core/src/main/java/com/jcraft/jsch/agentproxy/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2012 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy; public class AgentProxy { private static final byte SSH_AGENTC_REQUEST_RSA_IDENTITIES = 1; private static final byte SSH_AGENT_RSA_IDENTITIES_ANSWER = 2; private static final byte SSH_AGENTC_RSA_CHALLENGE = 3; private static final byte SSH_AGENT_RSA_RESPONSE = 4; private static final byte SSH_AGENT_FAILURE = 5; private static final byte SSH_AGENT_SUCCESS = 6; private static final byte SSH_AGENTC_ADD_RSA_IDENTITY = 7; private static final byte SSH_AGENTC_REMOVE_RSA_IDENTITY = 8; private static final byte SSH_AGENTC_REMOVE_ALL_RSA_IDENTITIES = 9; private static final byte SSH2_AGENTC_REQUEST_IDENTITIES = 11; private static final byte SSH2_AGENT_IDENTITIES_ANSWER = 12; private static final byte SSH2_AGENTC_SIGN_REQUEST = 13; private static final byte SSH2_AGENT_SIGN_RESPONSE = 14; private static final byte SSH2_AGENTC_ADD_IDENTITY = 17; private static final byte SSH2_AGENTC_REMOVE_IDENTITY = 18; private static final byte SSH2_AGENTC_REMOVE_ALL_IDENTITIES = 19; private static final byte SSH_AGENTC_ADD_SMARTCARD_KEY = 20; private static final byte SSH_AGENTC_REMOVE_SMARTCARD_KEY = 21; private static final byte SSH_AGENTC_LOCK = 22; private static final byte SSH_AGENTC_UNLOCK = 23; private static final byte SSH_AGENTC_ADD_RSA_ID_CONSTRAINED = 24; private static final byte SSH2_AGENTC_ADD_ID_CONSTRAINED = 25; private static final byte SSH_AGENTC_ADD_SMARTCARD_KEY_CONSTRAINED = 26; private static final byte SSH_AGENT_CONSTRAIN_LIFETIME = 1; private static final byte SSH_AGENT_CONSTRAIN_CONFIRM = 2; private static final byte SSH2_AGENT_FAILURE = 30; private static final byte SSH_COM_AGENT2_FAILURE = 102; private static final byte SSH_AGENT_OLD_SIGNATURE = 0x01; private final byte[] buf = new byte[1024]; private final Buffer buffer = new Buffer(buf); private Connector connector; public AgentProxy(Connector connector){ this.connector = connector; } public synchronized Identity[] getIdentities() { Identity[] identities = null; byte code1 = SSH2_AGENTC_REQUEST_IDENTITIES; byte code2 = SSH2_AGENT_IDENTITIES_ANSWER; buffer.reset(); buffer.putByte(code1); buffer.insertLength(); try { connector.query(buffer); } catch(AgentProxyException e){ buffer.rewind(); buffer.putByte(SSH_AGENT_FAILURE); identities = new Identity[0]; return identities; } int rcode = buffer.getByte(); check_reply(rcode); //System.out.println(rcode == code2); int count = buffer.getInt(); //System.out.println(count); identities = new Identity[count]; for(int i=0; i>> 24); tmp[1]=(byte)(val >>> 16); tmp[2]=(byte)(val >>> 8); tmp[3]=(byte)(val); System.arraycopy(tmp, 0, buffer, index, 4); index+=4; } public void putLong(long val) { tmp[0]=(byte)(val >>> 56); tmp[1]=(byte)(val >>> 48); tmp[2]=(byte)(val >>> 40); tmp[3]=(byte)(val >>> 32); System.arraycopy(tmp, 0, buffer, index, 4); tmp[0]=(byte)(val >>> 24); tmp[1]=(byte)(val >>> 16); tmp[2]=(byte)(val >>> 8); tmp[3]=(byte)(val); System.arraycopy(tmp, 0, buffer, index+4, 4); index+=8; } void skip(int n) { index+=n; } void putPad(int n) { while(n>0){ buffer[index++]=(byte)0; n--; } } public void putMPInt(byte[] foo){ int i=foo.length; if((foo[0]&0x80)!=0){ i++; putInt(i); putByte((byte)0); } else{ putInt(i); } putByte(foo); } public int getLength(){ return index-s; } public int getOffSet(){ return s; } public void setOffSet(int s){ this.s=s; } public long getLong(){ long foo = getInt()&0xffffffffL; foo = ((foo<<32)) | (getInt()&0xffffffffL); return foo; } public int getInt(){ int foo = getShort(); foo = ((foo<<16)&0xffff0000) | (getShort()&0xffff); return foo; } public long getUInt(){ long foo = 0L; long bar = 0L; foo = getByte(); foo = ((foo<<8)&0xff00)|(getByte()&0xff); bar = getByte(); bar = ((bar<<8)&0xff00)|(getByte()&0xff); foo = ((foo<<16)&0xffff0000) | (bar&0xffff); return foo; } int getShort() { int foo = getByte(); foo = ((foo<<8)&0xff00)|(getByte()&0xff); return foo; } public int getByte() { return (buffer[s++]&0xff); } public void getByte(byte[] foo) { getByte(foo, 0, foo.length); } void getByte(byte[] foo, int start, int len) { System.arraycopy(buffer, s, foo, start, len); s+=len; } public int getByte(int len) { int foo=s; s+=len; return foo; } public byte[] getMPInt() { int i=getInt(); // uint32 if(i<0 || // bigger than 0x7fffffff i>8*1024){ // TODO: an exception should be thrown. i = 8*1024; // the session will be broken, but working around OOME. } byte[] foo=new byte[i]; getByte(foo, 0, i); return foo; } public byte[] getMPIntBits() { int bits=getInt(); int bytes=(bits+7)/8; byte[] foo=new byte[bytes]; getByte(foo, 0, bytes); if((foo[0]&0x80)!=0){ byte[] bar=new byte[foo.length+1]; bar[0]=0; // ?? System.arraycopy(foo, 0, bar, 1, foo.length); foo=bar; } return foo; } public byte[] getString() { int i = getInt(); // uint32 if(i<0 || // bigger than 0x7fffffff i>256*1024){ // TODO: an exception should be thrown. i = 256*1024; // the session will be broken, but working around OOME. } byte[] foo=new byte[i]; getByte(foo, 0, i); return foo; } byte[] getString(int[]start, int[]len) { int i=getInt(); start[0]=getByte(i); len[0]=i; return buffer; } public void reset(){ index=0; s=0; } public void shift(){ if(s==0)return; System.arraycopy(buffer, s, buffer, 0, index-s); index=index-s; s=0; } public void rewind(){ s=0; } byte getCommand(){ return buffer[5]; } public void checkFreeSize(int n){ if(buffer.length>>4)&0xf]); System.err.print(chars[foo&0xf]); if(i%16==15){ System.err.println(""); continue; } if(i>0 && i%2==1){ System.err.print(" "); } } System.err.println(""); } static void dump(byte[] b){ dump(b, 0, b.length); } static void dump(byte[] b, int s, int l){ for(int i=s; i 4.0.0 com.jcraft jsch.agentproxy 0.0.7 jsch.agentproxy.jsch a library to use jsch-agent-proxy with JSch com.jcraft jsch ${jsch.version} com.jcraft jsch.agentproxy.core ${project.version} org.apache.maven.plugins maven-jar-plugin 2.3.2 jsch-agent-proxy-0.0.7/jsch-agent-proxy-jsch/src/000077500000000000000000000000001227243206000216345ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-jsch/src/main/000077500000000000000000000000001227243206000225605ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-jsch/src/main/java/000077500000000000000000000000001227243206000235015ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-jsch/src/main/java/com/000077500000000000000000000000001227243206000242575ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-jsch/src/main/java/com/jcraft/000077500000000000000000000000001227243206000255305ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-jsch/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000264575ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-jsch/src/main/java/com/jcraft/jsch/agentproxy/000077500000000000000000000000001227243206000306575ustar00rootroot00000000000000RemoteIdentityRepository.java000066400000000000000000000065221227243206000365150ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-jsch/src/main/java/com/jcraft/jsch/agentproxy/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy; import java.util.Vector; import com.jcraft.jsch.IdentityRepository; import com.jcraft.jsch.JSchException; public class RemoteIdentityRepository implements IdentityRepository { private AgentProxy agent; public RemoteIdentityRepository(Connector connector) { this.agent = new AgentProxy(connector); } public Vector getIdentities() { Vector result = new Vector(); Identity[] identities = agent.getIdentities(); for(int i=0; i 4.0.0 com.jcraft jsch.agentproxy 0.0.7 jsch.agentproxy.pageant a connector for Pageant using JNA bundle com.jcraft jsch.agentproxy.core ${project.version} net.java.dev.jna jna ${jna.version} net.java.dev.jna platform ${jna.version} org.apache.maven.plugins maven-jar-plugin 2.3.2 jsch-agent-proxy-0.0.7/jsch-agent-proxy-pageant/src/000077500000000000000000000000001227243206000223245ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-pageant/src/main/000077500000000000000000000000001227243206000232505ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-pageant/src/main/java/000077500000000000000000000000001227243206000241715ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-pageant/src/main/java/com/000077500000000000000000000000001227243206000247475ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-pageant/src/main/java/com/jcraft/000077500000000000000000000000001227243206000262205ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-pageant/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000271475ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-pageant/src/main/java/com/jcraft/jsch/agentproxy/000077500000000000000000000000001227243206000313475ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-pageant/src/main/java/com/jcraft/jsch/agentproxy/connector/000077500000000000000000000000001227243206000333415ustar00rootroot00000000000000PageantConnector.java000066400000000000000000000152031227243206000373600ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-pageant/src/main/java/com/jcraft/jsch/agentproxy/connector/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy.connector; import com.jcraft.jsch.agentproxy.Connector; import com.jcraft.jsch.agentproxy.AgentProxyException; import com.jcraft.jsch.agentproxy.Buffer; import com.sun.jna.Platform; import com.sun.jna.Native; import com.sun.jna.Memory; import com.sun.jna.Pointer; import com.sun.jna.Structure; import com.sun.jna.win32.W32APIOptions; import com.sun.jna.platform.win32.WinNT.HANDLE; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinBase; import com.sun.jna.platform.win32.WinBase.SECURITY_ATTRIBUTES; import com.sun.jna.platform.win32.Kernel32; import com.sun.jna.platform.win32.WinNT; import java.util.Arrays; import java.util.List; public class PageantConnector implements Connector { private User32 libU = null; private Kernel32 libK = null; public PageantConnector() throws AgentProxyException { try { libU = User32.INSTANCE; libK = Kernel32.INSTANCE; } catch(java.lang.UnsatisfiedLinkError e){ throw new AgentProxyException(e.toString()); } catch(java.lang.NoClassDefFoundError e){ throw new AgentProxyException(e.toString()); } } public String getName(){ return "pageant"; } public static boolean isConnectorAvailable(){ return System.getProperty("os.name").startsWith("Windows"); } public boolean isAvailable(){ return isConnectorAvailable(); } public interface User32 extends com.sun.jna.platform.win32.User32 { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class, W32APIOptions.DEFAULT_OPTIONS); long SendMessage(HWND hWnd, int msg, WPARAM num1, byte[] num2); } public class COPYDATASTRUCT32 extends Structure { public int dwData; public int cbData; public Pointer lpData; protected List getFieldOrder() { return Arrays.asList(new String[] { "dwData", "cbData", "lpData" }); } } public class COPYDATASTRUCT64 extends Structure { public int dwData; public long cbData; public Pointer lpData; protected List getFieldOrder() { return Arrays.asList(new String[] { "dwData", "cbData", "lpData" }); } } public void query(Buffer buffer) throws AgentProxyException { HANDLE sharedFile = null; Pointer sharedMemory = null; HWND hwnd = libU.FindWindow("Pageant", "Pageant"); if(hwnd == null){ throw new AgentProxyException("Pageant is not runnning."); } String mapname = String.format("PageantRequest%08x", libK.GetCurrentThreadId()); // TODO SECURITY_ATTRIBUTES psa = null; sharedFile = libK.CreateFileMapping(WinBase.INVALID_HANDLE_VALUE, psa, WinNT.PAGE_READWRITE, 0, 8192, // AGENT_MAX_MSGLEN mapname); sharedMemory = Kernel32.INSTANCE.MapViewOfFile(sharedFile, WinNT.SECTION_MAP_WRITE, 0, 0, 0); byte[] data = null; long rcode = 0; try { sharedMemory.write(0, buffer.buffer, 0, buffer.getLength()); if(Platform.is64Bit()){ COPYDATASTRUCT64 cds64 = new COPYDATASTRUCT64(); data = install64(mapname, cds64); rcode = sendMessage(hwnd, data); } else { COPYDATASTRUCT32 cds32 = new COPYDATASTRUCT32(); data = install32(mapname, cds32); rcode = sendMessage(hwnd, data); } buffer.rewind(); if(rcode!=0){ sharedMemory.read(0, buffer.buffer, 0, 4); // length int i = buffer.getInt(); buffer.rewind(); buffer.checkFreeSize(i); sharedMemory.read(4, buffer.buffer, 0, i); } } finally { if(sharedMemory != null) libK.UnmapViewOfFile(sharedMemory); if(sharedFile != null) libK.CloseHandle(sharedFile); } } private byte[] install32(String mapname, COPYDATASTRUCT32 cds){ cds.dwData = 0x804e50ba; // AGENT_COPYDATA_ID cds.cbData = mapname.length()+1; cds.lpData = new Memory(mapname.length()+1); { byte[] foo = mapname.getBytes(); cds.lpData.write(0, foo, 0, foo.length); cds.lpData.setByte(foo.length, (byte)0); cds.write(); } byte[] data = new byte[12]; Pointer cdsp = cds.getPointer(); cdsp.read(0, data, 0, 12); return data; } private byte[] install64(String mapname, COPYDATASTRUCT64 cds){ cds.dwData = 0x804e50ba; // AGENT_COPYDATA_ID cds.cbData = mapname.length()+1; cds.lpData = new Memory(mapname.length()+1); { byte[] foo = mapname.getBytes(); cds.lpData.write(0, foo, 0, foo.length); cds.lpData.setByte(foo.length, (byte)0); cds.write(); } byte[] data = new byte[24]; Pointer cdsp = cds.getPointer(); cdsp.read(0, data, 0, 24); return data; } long sendMessage(HWND hwnd, byte[] data){ long rcode = libU.SendMessage(hwnd, 0x004A, //WM_COPYDATA null, data ); return rcode; } } jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/000077500000000000000000000000001227243206000217325ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/pom.xml000066400000000000000000000017131227243206000232510ustar00rootroot00000000000000 4.0.0 com.jcraft jsch.agentproxy 0.0.7 jsch.agentproxy.sshagent a connector for ssh-agent bundle com.jcraft jsch.agentproxy.core ${project.version} org.apache.maven.plugins maven-jar-plugin 2.3.2 jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/src/000077500000000000000000000000001227243206000225215ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/src/main/000077500000000000000000000000001227243206000234455ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/src/main/java/000077500000000000000000000000001227243206000243665ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/src/main/java/com/000077500000000000000000000000001227243206000251445ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/src/main/java/com/jcraft/000077500000000000000000000000001227243206000264155ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000273445ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/src/main/java/com/jcraft/jsch/agentproxy/000077500000000000000000000000001227243206000315445ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/src/main/java/com/jcraft/jsch/agentproxy/connector/000077500000000000000000000000001227243206000335365ustar00rootroot00000000000000SSHAgentConnector.java000066400000000000000000000070131227243206000376120ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshagent/src/main/java/com/jcraft/jsch/agentproxy/connector/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy.connector; import com.jcraft.jsch.agentproxy.Connector; import com.jcraft.jsch.agentproxy.Buffer; import com.jcraft.jsch.agentproxy.AgentProxyException; import com.jcraft.jsch.agentproxy.USocketFactory; import java.io.IOException; public class SSHAgentConnector implements Connector { private USocketFactory factory; public SSHAgentConnector(USocketFactory factory) throws AgentProxyException { this.factory = factory; // checking if factory is really functional. USocketFactory.Socket sock = null; try { sock = open(); } catch(IOException e){ throw new AgentProxyException(e.toString()); } catch(Exception e){ throw new AgentProxyException(e.toString()); } finally{ try{ if(sock!=null) sock.close(); } catch(IOException e){ throw new AgentProxyException(e.toString()); } } } public String getName(){ return "ssh-agent"; } public static boolean isConnectorAvailable(){ return System.getenv("SSH_AUTH_SOCK")!=null; } public boolean isAvailable(){ return isConnectorAvailable(); } private USocketFactory.Socket open() throws IOException { String ssh_auth_sock = System.getenv("SSH_AUTH_SOCK"); if(ssh_auth_sock ==null) { throw new IOException("SSH_AUTH_SOCK is not defined."); } return factory.open(ssh_auth_sock); } public void query(Buffer buffer) throws AgentProxyException { USocketFactory.Socket sock = null; try { sock = open(); sock.write(buffer.buffer, 0, buffer.getLength()); buffer.rewind(); int i = sock.readFull(buffer.buffer, 0, 4); // length i = buffer.getInt(); buffer.rewind(); buffer.checkFreeSize(i); i = sock.readFull(buffer.buffer, 0, i); } catch(IOException e){ throw new AgentProxyException(e.toString()); } finally { try { if(sock!=null) sock.close(); } catch(IOException e){ throw new AgentProxyException(e.toString()); } } } } jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/000077500000000000000000000000001227243206000210655ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/pom.xml000066400000000000000000000021071227243206000224020ustar00rootroot00000000000000 4.0.0 com.jcraft jsch.agentproxy 0.0.7 jsch.agentproxy.sshj a library to use jsch-agent-proxy with sshj net.schmizz sshj [0.8.1,) com.jcraft jsch.agentproxy.core ${project.version} org.apache.maven.plugins maven-jar-plugin 2.3.2 jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/src/000077500000000000000000000000001227243206000216545ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/src/main/000077500000000000000000000000001227243206000226005ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/src/main/java/000077500000000000000000000000001227243206000235215ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/src/main/java/com/000077500000000000000000000000001227243206000242775ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/src/main/java/com/jcraft/000077500000000000000000000000001227243206000255505ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000264775ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/src/main/java/com/jcraft/jsch/agentproxy/000077500000000000000000000000001227243206000306775ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/src/main/java/com/jcraft/jsch/agentproxy/sshj/000077500000000000000000000000001227243206000316465ustar00rootroot00000000000000AuthAgent.java000066400000000000000000000111411227243206000343100ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-sshj/src/main/java/com/jcraft/jsch/agentproxy/sshj/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2013 Olli Helenius All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy.sshj; import com.jcraft.jsch.agentproxy.AgentProxy; import com.jcraft.jsch.agentproxy.Identity; import net.schmizz.sshj.common.Buffer; import net.schmizz.sshj.common.Message; import net.schmizz.sshj.common.SSHPacket; import net.schmizz.sshj.transport.TransportException; import net.schmizz.sshj.userauth.UserAuthException; import net.schmizz.sshj.userauth.method.AbstractAuthMethod; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * An AuthMethod for sshj authentication with an agent. */ public class AuthAgent extends AbstractAuthMethod { protected final Logger log = LoggerFactory.getLogger(getClass()); /** The AgentProxy instance that is used for signing */ private final AgentProxy agentProxy; /** The identity from Agent */ private final Identity identity; /** The identity's key algorithm */ private final String algorithm; private final String comment; public AuthAgent(AgentProxy agentProxy, Identity identity) throws Buffer.BufferException { super("publickey"); this.agentProxy = agentProxy; this.identity = identity; this.comment = new String(identity.getComment()); this.algorithm = (new Buffer.PlainBuffer(identity.getBlob())).readString(); } /** Internal use. */ @Override public void handle(Message cmd, SSHPacket buf) throws UserAuthException, TransportException { if (cmd == Message.USERAUTH_60) sendSignedReq(); else super.handle(cmd, buf); } protected SSHPacket putPubKey(SSHPacket reqBuf) throws UserAuthException { reqBuf .putString(algorithm) .putBytes(identity.getBlob()).getCompactData(); return reqBuf; } private SSHPacket putSig(SSHPacket reqBuf) throws UserAuthException { final byte[] dataToSign = new Buffer.PlainBuffer() .putString(params.getTransport().getSessionID()) .putBuffer(reqBuf) // & rest of the data for sig .getCompactData(); reqBuf.putBytes(agentProxy.sign(identity.getBlob(), dataToSign)); return reqBuf; } /** * Send SSH_MSG_USERAUTH_REQUEST containing the signature. * * @throws UserAuthException * @throws TransportException */ private void sendSignedReq() throws UserAuthException, TransportException { params.getTransport().write(putSig(buildReq(true))); } /** * Builds SSH_MSG_USERAUTH_REQUEST packet. * * @param signed whether the request packet will contain signature * * @return the {@link SSHPacket} containing the request packet * * @throws UserAuthException */ private SSHPacket buildReq(boolean signed) throws UserAuthException { log.debug("Attempting authentication using agent identity {}", comment); return putPubKey(super.buildReq().putBoolean(signed)); } /** Builds a feeler request (sans signature). */ @Override protected SSHPacket buildReq() throws UserAuthException { return buildReq(false); } } jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/000077500000000000000000000000001227243206000237335ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/pom.xml000066400000000000000000000021661227243206000252550ustar00rootroot00000000000000 4.0.0 com.jcraft jsch.agentproxy 0.0.7 jsch.agentproxy.svnkit-trilead-ssh2 jsch-agent-proxy connector to SVNKit fork of Trilead SSH2 com.trilead trilead-ssh2 ${trilead.version} com.jcraft jsch.agentproxy.core ${project.version} org.apache.maven.plugins maven-jar-plugin 2.3.2 jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/src/000077500000000000000000000000001227243206000245225ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/src/main/000077500000000000000000000000001227243206000254465ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/src/main/java/000077500000000000000000000000001227243206000263675ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/src/main/java/com/000077500000000000000000000000001227243206000271455ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/src/main/java/com/jcraft/000077500000000000000000000000001227243206000304165ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000313455ustar00rootroot00000000000000agentproxy/000077500000000000000000000000001227243206000334665ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/src/main/java/com/jcraft/jschTrileadAgentIdentity.java000066400000000000000000000042421227243206000404100ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/src/main/java/com/jcraft/jsch/agentproxy/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2013 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy; import com.trilead.ssh2.auth.AgentIdentity; public class TrileadAgentIdentity implements AgentIdentity { AgentProxy proxy; Identity wrappedIdentity; String algName; public TrileadAgentIdentity(AgentProxy proxy, Identity wrappedIdentity) { byte[] blob = wrappedIdentity.getBlob(); this.proxy = proxy; this.wrappedIdentity = wrappedIdentity; this.algName = new String((new Buffer(blob)).getString()); } public String getAlgName() { return algName; } public byte[] getPublicKeyBlob() { return wrappedIdentity.getBlob(); } public byte[] sign(byte[] bytes) { return proxy.sign(getPublicKeyBlob(), bytes); } } TrileadAgentProxy.java000066400000000000000000000041641227243206000377430ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-svnkit-trilead-ssh2/src/main/java/com/jcraft/jsch/agentproxy/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2013 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy; import java.util.ArrayList; import java.util.Collection; public class TrileadAgentProxy implements com.trilead.ssh2.auth.AgentProxy { private com.jcraft.jsch.agentproxy.AgentProxy agent; public TrileadAgentProxy(Connector connector) { this.agent = new AgentProxy(connector); } public Collection getIdentities() { Identity[] identities = agent.getIdentities(); ArrayList wrapped_identities = new ArrayList(identities.length); for( Identity identity : identities) { wrapped_identities.add(new TrileadAgentIdentity(this.agent, identity)); } return wrapped_identities; } } jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/000077500000000000000000000000001227243206000223415ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/pom.xml000066400000000000000000000024271227243206000236630ustar00rootroot00000000000000 4.0.0 com.jcraft jsch.agentproxy 0.0.7 jsch.agentproxy.usocket-jna an implementation of USocketFactory using JNA bundle com.jcraft jsch.agentproxy.core ${project.version} net.java.dev.jna jna ${jna.version} net.java.dev.jna platform ${jna.version} org.apache.maven.plugins maven-jar-plugin 2.3.2 jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/src/000077500000000000000000000000001227243206000231305ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/src/main/000077500000000000000000000000001227243206000240545ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/src/main/java/000077500000000000000000000000001227243206000247755ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/src/main/java/com/000077500000000000000000000000001227243206000255535ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/src/main/java/com/jcraft/000077500000000000000000000000001227243206000270245ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000277535ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/src/main/java/com/jcraft/jsch/agentproxy/000077500000000000000000000000001227243206000321535ustar00rootroot00000000000000usocket/000077500000000000000000000000001227243206000335515ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/src/main/java/com/jcraft/jsch/agentproxyJNAUSocketFactory.java000066400000000000000000000107521227243206000376570ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-jna/src/main/java/com/jcraft/jsch/agentproxy/usocket/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy.usocket; import com.jcraft.jsch.agentproxy.AgentProxyException; import com.jcraft.jsch.agentproxy.USocketFactory; import com.sun.jna.Library; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.Structure; import java.io.IOException; import java.util.Arrays; import java.util.List; public class JNAUSocketFactory implements USocketFactory { public interface CLibrary extends Library { CLibrary INSTANCE = (CLibrary) Native.loadLibrary("c", CLibrary.class); int socket(int domain, int type, int protocol); int fcntl(int fd, int cmd, Object... args); int connect(int sockfd, Pointer addr, int addrlen); int close(int fd); int read(int fd, byte[] buf, int count); int write(int fd, byte[] buf, int count); } public static class SockAddr extends Structure { public short sun_family; public byte[] sun_path; protected List getFieldOrder() { return Arrays.asList(new String[] { "sun_family", "sun_path" }); } } public JNAUSocketFactory() throws AgentProxyException { } public class MySocket extends Socket { private int sock; public int readFull(byte[] buf, int s, int len) throws IOException { byte[] _buf = buf; int _len = len; int _s = s; while(_len > 0){ if(_s != 0){ _buf = new byte[_len]; } int i = CLibrary.INSTANCE.read(sock, _buf, _len); if(i <= 0){ return -1; // throw new IOException("failed to read usocket"); } if(_s != 0) System.arraycopy(_buf, 0, buf, _s, i); _s += i; _len -= i; } return len; } public void write(byte[] buf, int s, int len) throws IOException { byte[] _buf = buf; int _len = len; if(s != 0){ _buf = new byte[len]; System.arraycopy(buf, s, _buf, 0, len); } CLibrary.INSTANCE.write(sock, _buf, len); } MySocket(int sock) throws IOException { this.sock = sock; } public void close() throws IOException { CLibrary.INSTANCE.close(sock); } } public Socket open(String path) throws IOException { int sock = CLibrary.INSTANCE.socket(1, // AF_UNIX 1, // SOCK_STREAM 0); if(sock < 0){ throw new IOException("failed to allocate usocket"); } int foo = CLibrary.INSTANCE.fcntl(sock, 2, 8); if(foo < 0){ CLibrary.INSTANCE.close(sock); throw new IOException("failed to fctrl usocket: "+foo); } SockAddr sockaddr = new SockAddr(); sockaddr.sun_family = 1; sockaddr.sun_path = new byte[108]; System.arraycopy(path.getBytes(), 0, sockaddr.sun_path, 0, path.length()); sockaddr.write(); foo = CLibrary.INSTANCE.connect(sock, sockaddr.getPointer(), sockaddr.size()); if(foo < 0){ throw new IOException("failed to fctrl usocket: "+foo); } return new MySocket(sock); } } jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/000077500000000000000000000000001227243206000241375ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/pom.xml000066400000000000000000000023441227243206000254570ustar00rootroot00000000000000 4.0.0 com.jcraft jsch.agentproxy 0.0.7 jsch.agentproxy.usocket-junixsocket an implementation of USocketFactory using junixsocket bundle com.jcraft jsch.agentproxy.core ${project.version} org.newsclub junixsocket 1.3 system ${basedir}/../lib/junixsocket-1.3.jar org.apache.maven.plugins maven-jar-plugin 2.3.2 jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/src/000077500000000000000000000000001227243206000247265ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/src/main/000077500000000000000000000000001227243206000256525ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/src/main/java/000077500000000000000000000000001227243206000265735ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/src/main/java/com/000077500000000000000000000000001227243206000273515ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/src/main/java/com/jcraft/000077500000000000000000000000001227243206000306225ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000315515ustar00rootroot00000000000000agentproxy/000077500000000000000000000000001227243206000336725ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/src/main/java/com/jcraft/jschusocket/000077500000000000000000000000001227243206000353475ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/src/main/java/com/jcraft/jsch/agentproxyJUnixDomainSocketFactory.java000066400000000000000000000063021227243206000431010ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-junixsocket/src/main/java/com/jcraft/jsch/agentproxy/usocket/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2011 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy.usocket; import com.jcraft.jsch.agentproxy.AgentProxyException; import com.jcraft.jsch.agentproxy.USocketFactory; import org.newsclub.net.unix.AFUNIXSocket; import org.newsclub.net.unix.AFUNIXSocketAddress; import org.newsclub.net.unix.AFUNIXSocketException; import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; public class JUnixDomainSocketFactory implements USocketFactory { public JUnixDomainSocketFactory() throws AgentProxyException { } public class MySocket extends Socket { private AFUNIXSocket sock; private InputStream is; private OutputStream os; public int readFull(byte[] buf, int s, int len) throws IOException { int _len = len; while(len>0){ int j = is.read(buf, s, len); if(j<=0) return -1; if(j>0){ s+=j; len-=j; } } return _len; } public void write(byte[] buf, int s, int len) throws IOException { os.write(buf, s, len); } MySocket(AFUNIXSocket sock) throws IOException { this.sock = sock; this.os = sock.getOutputStream(); this.is = sock.getInputStream(); } public void close() throws IOException { is.close(); os.close(); sock.close(); } } public Socket open(String path) throws IOException { AFUNIXSocket sock = null; try { sock = AFUNIXSocket.newInstance(); sock.connect(new AFUNIXSocketAddress(new File(path))); } catch (AFUNIXSocketException e){ throw new IOException(e.toString()); } catch (NoClassDefFoundError e){ throw new IOException(e.toString()); } return new MySocket(sock); } } jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/000077500000000000000000000000001227243206000221715ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/pom.xml000066400000000000000000000017441227243206000235140ustar00rootroot00000000000000 4.0.0 com.jcraft jsch.agentproxy 0.0.7 jsch.agentproxy.usocket-nc an implementation of USocketFactory using netcat bundle com.jcraft jsch.agentproxy.core ${project.version} org.apache.maven.plugins maven-jar-plugin 2.3.2 jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/src/000077500000000000000000000000001227243206000227605ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/src/main/000077500000000000000000000000001227243206000237045ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/src/main/java/000077500000000000000000000000001227243206000246255ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/src/main/java/com/000077500000000000000000000000001227243206000254035ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/src/main/java/com/jcraft/000077500000000000000000000000001227243206000266545ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/src/main/java/com/jcraft/jsch/000077500000000000000000000000001227243206000276035ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/src/main/java/com/jcraft/jsch/agentproxy/000077500000000000000000000000001227243206000320035ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/src/main/java/com/jcraft/jsch/agentproxy/usocket/000077500000000000000000000000001227243206000334605ustar00rootroot00000000000000NCUSocketFactory.java000066400000000000000000000072171227243206000374010ustar00rootroot00000000000000jsch-agent-proxy-0.0.7/jsch-agent-proxy-usocket-nc/src/main/java/com/jcraft/jsch/agentproxy/usocket/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* Copyright (c) 2013 ymnk, JCraft,Inc. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.jcraft.jsch.agentproxy.usocket; import com.jcraft.jsch.agentproxy.AgentProxyException; import com.jcraft.jsch.agentproxy.USocketFactory; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; public class NCUSocketFactory implements USocketFactory { public NCUSocketFactory() throws AgentProxyException { Process p = null; StringBuilder sb = new StringBuilder(); try { p = Runtime.getRuntime().exec("nc -h"); InputStream is = p.getErrorStream(); byte[] buf = new byte[1024]; int i = 0; while((i = is.read(buf, 0, buf.length))>0){ sb.append(new String(buf, 0, i)); } } catch(IOException e){ } finally { try { if(p != null) { p.getErrorStream().close(); p.getOutputStream().close(); p.getInputStream().close(); p.destroy(); } } catch(IOException e){ } } String result = sb.toString(); if(result.indexOf("-U") == -1){ throw new AgentProxyException("netcat does not support -U option."); } } public class MySocket extends Socket { private Process p; private InputStream is; private OutputStream os; public int readFull(byte[] buf, int s, int len) throws IOException { int _len = len; while(len>0){ int j = is.read(buf, s, len); if(j<=0) return -1; if(j>0){ s+=j; len-=j; } } return _len; } public void write(byte[] buf, int s, int len) throws IOException { os.write(buf, s, len); os.flush(); } MySocket(Process p) throws IOException { this.p = p; this.os = p.getOutputStream(); this.is = p.getInputStream(); } public void close() throws IOException { p.getErrorStream().close(); p.getInputStream().close(); p.destroy(); os.close(); } } public Socket open(String path) throws IOException { Process p = null; try { p = Runtime.getRuntime().exec("nc -U "+path); } catch (SecurityException e){ throw new IOException(e.toString()); } return new MySocket(p); } } jsch-agent-proxy-0.0.7/pom.xml000066400000000000000000000104031227243206000162310ustar00rootroot00000000000000 4.0.0 3.0.0 com.jcraft jsch.agentproxy 0.0.7 pom jsch-agent-proxy: a parent of modules a proxy to ssh-agent and Pageant in Java JCraft,Inc. http://www.jcraft.com/ http://www.jcraft.com/jsch-agent-proxy/ jsch-agent-proxy-core jsch-agent-proxy-connector-factory jsch-agent-proxy-jsch jsch-agent-proxy-sshj jsch-agent-proxy-pageant jsch-agent-proxy-sshagent jsch-agent-proxy-usocket-jna jsch-agent-proxy-usocket-nc jsch-agent-proxy-svnkit-trilead-ssh2 UTF-8 UTF-8 0.1.49 3.4.0 1.0.0-build217 ymnk Atsuhiko Yamanaka ymnk at jcraft D0t com http://github.com/ymnk JCraft,Inc. http://www.jcraft.com/ architect developer +9 Revised BSD http://www.jcraft.com/jsch-agent-proxy/LICENSE.txt scm:git:git://github.com/ymnk/jsch-agent-proxy.git scm:git:git@github.com:ymnk/jsch-agent-proxy.git http://github.com/ymnk/jsch-agent-proxy/ org.apache.maven.plugins maven-source-plugin attach-sources jar org.apache.maven.plugins maven-compiler-plugin 2.3.2 1.5 1.5 org.apache.maven.plugins maven-javadoc-plugin attach-javadocs jar org.apache.felix maven-bundle-plugin 2.3.7 true org.apache.maven.wagon wagon-ssh-external 1.0-alpha-5 org.sonatype.oss oss-parent 6