Author: chatellier Date: 2009-05-12 17:09:16 +0000 (Tue, 12 May 2009) New Revision: 2225 Modified: isis-fish/trunk/pom.xml isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/versionning/VCSGenerateSshKeyUI.jaxx Log: Remove sshtools dependency (all based on jsch) Modified: isis-fish/trunk/pom.xml =================================================================== --- isis-fish/trunk/pom.xml 2009-05-12 17:00:38 UTC (rev 2224) +++ isis-fish/trunk/pom.xml 2009-05-12 17:09:16 UTC (rev 2225) @@ -188,20 +188,6 @@ </dependency> <dependency> - <groupId>sshtools</groupId> - <artifactId>j2ssh-common</artifactId> - <version>${sshtool.version}</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>sshtools</groupId> - <artifactId>j2ssh-core</artifactId> - <version>${sshtool.version}</version> - <scope>compile</scope> - </dependency> - - <dependency> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> <version>0.1.41</version> @@ -364,7 +350,6 @@ <license-switcher.version>0.6</license-switcher.version> <openmap.version>4.6.4</openmap.version> <aspectwerkz.version>2.0</aspectwerkz.version> - <sshtool.version>0.2.2</sshtool.version> <xmlrpc.version>3.1.2</xmlrpc.version> <!-- for compilation test to run --> Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/versionning/VCSGenerateSshKeyUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/versionning/VCSGenerateSshKeyUI.jaxx 2009-05-12 17:00:38 UTC (rev 2224) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/versionning/VCSGenerateSshKeyUI.jaxx 2009-05-12 17:09:16 UTC (rev 2225) @@ -1,7 +1,7 @@ <JDialog title='isisfish.server.ssh.generateKey.title' modal='true'> <script><![CDATA[ - import com.sshtools.j2ssh.transport.publickey.OpenSSHPublicKeyFormat; - import com.sshtools.j2ssh.transport.publickey.SshKeyGenerator; + import com.jcraft.jsch.JSch; + import com.jcraft.jsch.KeyPair; import org.codelutin.util.FileUtil; import java.io.File; import java.io.IOException; @@ -41,31 +41,37 @@ error=null; doCheck(); } + + /** + * Generate ssh key. + * + * Return true if error occurs. + */ + protected boolean doGenerate() { + File privateKeyFile = new File(getServerPrivateKeyFile().getText()); + File publicKeyFile = new File(serverPublicKeyFile.getText()); - protected boolean doGenerate() { - File f = new File(getServerPrivateKeyFile().getText()); + // bug #1623, le dossier parent n'existe pas + if (privateKeyFile.getParentFile() != null && privateKeyFile.getParentFile().isDirectory()) { + privateKeyFile.mkdirs(); + } + try { - SshKeyGenerator sshkeygenerator = new SshKeyGenerator(); char[] password = getServerPassPhrase().getPassword(); - noPassPhrase=password.length==0; + + JSch jsch=new JSch(); + KeyPair kpair=KeyPair.genKeyPair(jsch, KeyPair.RSA); if (password.length > 0) { - sshkeygenerator.generateKeyPair("dsa", 1024, f.getAbsolutePath(), vcsLogin, Arrays.toString(password)); - Arrays.fill(password, '0'); - } else { - sshkeygenerator.generateKeyPair("dsa", 1024, f.getAbsolutePath(), vcsLogin, ""); + kpair.setPassphrase(Arrays.toString(password)); } - // convert to openSSH ? - File publicKeyFile = new File(serverPublicKeyFile.getText()); - // bug #1623, le dossier parent n'existe pas - if (publicKeyFile.getParentFile() != null && publicKeyFile.getParentFile().isDirectory()) { - publicKeyFile.mkdirs(); + kpair.writePrivateKey(privateKeyFile.getAbsolutePath()); + kpair.writePublicKey(publicKeyFile.getAbsolutePath(), vcsLogin + "@forIsisFish 1024-bit rsa"); + if (log.isInfoEnabled()) { + log.info("Finger print: "+kpair.getFingerPrint()); } - log.info("public key before OpenSsh : "+ FileUtil.readAsString(publicKeyFile)); - String openSshPublicKey = SshKeyGenerator.convertPublicKeyFile(publicKeyFile, new OpenSSHPublicKeyFormat(vcsLogin + "@forIsisFish 1024-bit dsa")); - log.info("public key OpenSsh : "+openSshPublicKey); - FileUtil.writeString(publicKeyFile, openSshPublicKey); + kpair.dispose(); } catch (Exception e) { - error=e; + error=e; return true; } return false;