r2058 - in isis-fish/trunk/src: main/java/fr/ifremer/isisfish/simulator/launcher main/java/fr/ifremer/isisfish/simulator/launcher/ssh main/java/fr/ifremer/isisfish/ui/simulator main/java/fr/ifremer/isisfish/util main/java/fr/ifremer/isisfish/util/ssh main/java/fr/ifremer/isisfish/vcs main/resources/i18n test/java/fr/ifremer/isisfish/util test/java/fr/ifremer/isisfish/util/ssh
Author: chatellier Date: 2009-04-01 16:51:28 +0000 (Wed, 01 Apr 2009) New Revision: 2058 Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/InvalidPassphraseException.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/SSHAgent.java isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/ssh/ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/ssh/SSHAgentTest.java Removed: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/SSHUtils.java Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/ssh/SSHUserInfo.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties Log: Refactoring de la gestion des passphrases Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java 2009-04-01 14:56:28 UTC (rev 2057) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SSHSimulatorLauncher.java 2009-04-01 16:51:28 UTC (rev 2058) @@ -49,6 +49,8 @@ import fr.ifremer.isisfish.simulator.launcher.ssh.SSHUserInfo; import fr.ifremer.isisfish.simulator.launcher.ssh.SSHUtils; import fr.ifremer.isisfish.util.ClasspathTemplateLoader; +import fr.ifremer.isisfish.util.ssh.InvalidPassphraseException; +import fr.ifremer.isisfish.util.ssh.SSHAgent; import freemarker.cache.TemplateLoader; import freemarker.template.Configuration; import freemarker.template.Template; @@ -79,8 +81,8 @@ protected Configuration freemarkerConfiguration; /** Freemarker qsub template. */ - protected static final String QSUB_SCRIPT_TEMPLATE = "templates/ssh/launch-isis-qsub.seq"; - //protected static final String QSUB_SCRIPT_TEMPLATE = "templates/ssh/launch-isis-cron.seq"; + //protected static final String QSUB_SCRIPT_TEMPLATE = "templates/ssh/launch-isis-qsub.seq"; + protected static final String QSUB_SCRIPT_TEMPLATE = "templates/ssh/launch-isis-cron.seq"; /** * Opened session. @@ -390,7 +392,19 @@ Session session = jsch.getSession(username, host, port); // username and password will be given via UserInfo interface. - UserInfo ui = new SSHUserInfo(); + SSHUserInfo ui = new SSHUserInfo(); + if (sshKeyUsed) { + String passphrase = null; + try { + passphrase = SSHAgent.getAgent().getPassphrase(sshKey); + ui.setPassphrase(passphrase); + } + catch(InvalidPassphraseException e) { + if (log.isWarnEnabled()) { + log.warn("Can't key passphrase for key", e); + } + } + } session.setUserInfo(ui); session.connect(60000); // timeout Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/ssh/SSHUserInfo.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/ssh/SSHUserInfo.java 2009-04-01 14:56:28 UTC (rev 2057) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/ssh/SSHUserInfo.java 2009-04-01 16:51:28 UTC (rev 2058) @@ -18,18 +18,10 @@ package fr.ifremer.isisfish.simulator.launcher.ssh; -import java.awt.Container; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; - -import javax.swing.JLabel; import javax.swing.JOptionPane; -import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JTextField; -import com.jcraft.jsch.UIKeyboardInteractive; import com.jcraft.jsch.UserInfo; /** @@ -43,7 +35,7 @@ * Last update : $Date: 1 déc. 2008 $ * By : $Author: chatellier $ */ -public class SSHUserInfo implements UserInfo, UIKeyboardInteractive { +public class SSHUserInfo implements UserInfo { /** * Passphrase. @@ -53,19 +45,14 @@ protected String passphrase; /** - * Passphrase text field. - */ - protected JTextField passphraseField = new JPasswordField(20); - - /** * Password text field. */ protected String passwd; - /** + /** * Password text field. */ - protected JTextField passwordField = new JPasswordField(20); + protected JPasswordField passwordField = new JPasswordField(20); /** * Call to ask user in remote server key @@ -82,31 +69,44 @@ } @Override - public boolean promptPassphrase(String message) { - Object[] ob = { passphraseField }; - int result = JOptionPane.showConfirmDialog(null, ob, message, - JOptionPane.OK_CANCEL_OPTION); - boolean bResult = false; - if (result == JOptionPane.OK_OPTION) { - passphrase = passphraseField.getText(); - bResult = true; - } - return bResult; + public String getPassword() { + return passwd; } - @Override - public String getPassword() { + /** + * @return the passwd + */ + public String getPasswd() { return passwd; } + /** + * @param passwd the passwd to set + */ + public void setPasswd(String passwd) { + this.passwd = passwd; + } + + /** + * @param passphrase the passphrase to set + */ + public void setPassphrase(String passphrase) { + this.passphrase = passphrase; + } + @Override + public boolean promptPassphrase(String arg0) { + return true; + } + + @Override public boolean promptPassword(String message) { Object[] ob = { passwordField }; int result = JOptionPane.showConfirmDialog(null, ob, message, JOptionPane.OK_CANCEL_OPTION); boolean bResult = false; if (result == JOptionPane.OK_OPTION) { - passwd = passwordField.getText(); + passwd = String.valueOf(passwordField.getPassword()); bResult = true; } return bResult; @@ -116,53 +116,4 @@ public void showMessage(String message) { JOptionPane.showMessageDialog(null, message); } - - @Override - public String[] promptKeyboardInteractive(String destination, String name, - String instruction, String[] prompt, boolean[] echo) { - final GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 1, 1, - GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, - new Insets(0, 0, 0, 0), 0, 0); - Container panel = new JPanel(); - panel.setLayout(new GridBagLayout()); - - gbc.weightx = 1.0; - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.gridx = 0; - panel.add(new JLabel(instruction), gbc); - gbc.gridy++; - - gbc.gridwidth = GridBagConstraints.RELATIVE; - - JTextField[] texts = new JTextField[prompt.length]; - for (int i = 0; i < prompt.length; i++) { - gbc.fill = GridBagConstraints.NONE; - gbc.gridx = 0; - gbc.weightx = 1; - panel.add(new JLabel(prompt[i]), gbc); - - gbc.gridx = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weighty = 1; - if (echo[i]) { - texts[i] = new JTextField(20); - } else { - texts[i] = new JPasswordField(20); - } - panel.add(texts[i], gbc); - gbc.gridy++; - } - - String[] response = null; - if (JOptionPane.showConfirmDialog(null, panel, destination + ": " - + name, JOptionPane.OK_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION) { - response = new String[prompt.length]; - for (int i = 0; i < prompt.length; i++) { - response[i] = texts[i].getText(); - } - } - // else = cancel - return response; - } } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2009-04-01 14:56:28 UTC (rev 2057) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2009-04-01 16:51:28 UTC (rev 2058) @@ -425,7 +425,7 @@ <Table> <row> <cell fill="horizontal"> - <JLabel id='lblName' text='{isSensitivity() ? _("isisfish.params.sensibilityName") : _("isisfish.params.simulationName")}' minimumSize='{new Dimension(195,25)}' preferredSize='{new Dimension(195,25)}'/> + <JLabel id='lblName' text='{isSensitivity() ? _("isisfish.params.sensitivityName") : _("isisfish.params.simulationName")}' minimumSize='{new Dimension(195,25)}' preferredSize='{new Dimension(195,25)}'/> </cell> <cell fill="both" weightx="1.0"> <JTextField id="fieldSimulParamsName" onFocusLost='saveName()'/> Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/InvalidPassphraseException.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/InvalidPassphraseException.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/InvalidPassphraseException.java 2009-04-01 16:51:28 UTC (rev 2058) @@ -0,0 +1,53 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package fr.ifremer.isisfish.util.ssh; + +/** + * TODO COMMENT ME. + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 1 avr. 2009 $ + * By : $Author: chatellier $ + */ +public class InvalidPassphraseException extends Exception { + + /** serialVersionUID. */ + private static final long serialVersionUID = -8878596298083203705L; + + /** + * Constructor with message and cause. + * + * @param message message + * @param cause cause + */ + public InvalidPassphraseException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructor with message. + * + * @param message message + */ + public InvalidPassphraseException(String message) { + super(message); + } +} Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/SSHAgent.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/SSHAgent.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ssh/SSHAgent.java 2009-04-01 16:51:28 UTC (rev 2058) @@ -0,0 +1,165 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package fr.ifremer.isisfish.util.ssh; + +import static org.codelutin.i18n.I18n._; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPasswordField; + +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.JSchException; +import com.jcraft.jsch.KeyPair; + +/** + * Isis SSH agent. + * + * This class centralize, ssh key and passphrase + * management. + * + * This is a singleton class. + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 1 avr. 2009 $ + * By : $Author: chatellier $ + */ +public class SSHAgent { + + /** JSSch instance. */ + protected JSch jsch; + + /** + * Passphrase associated to key file path. + * + * private key file path => passphrase. + * + * Ensure that passphrase are valid before add into. + */ + protected Map<String, String> passphraseForKeys; + + /** Unique agent. */ + private static SSHAgent agent = new SSHAgent(); + + /** + * Constructor. + */ + private SSHAgent() { + jsch = new JSch(); + passphraseForKeys = new HashMap<String, String>(); + } + + /** + * Get agent instance. + * + * @return agent + */ + public static SSHAgent getAgent() { + return agent; + } + + /** + * Get passphrase for key. + * + * @param privatekeyFile private key file + * @return <tt>null</tt> if there is no passphrase + * @throws InvalidPassphraseException if user cancel authentication + */ + public String getPassphrase(File privatekeyFile) + throws InvalidPassphraseException { + String passphrase = getPassphrase(privatekeyFile.getAbsolutePath()); + return passphrase; + } + + /** + * Get passphrase for key. + * + * @param privatekeyFile private key file path + * @return <tt>null</tt> if there is no passphrase + * @throws InvalidPassphraseException if user cancel authentication + */ + public String getPassphrase(String privatekeyFile) + throws InvalidPassphraseException { + + String passphrase = passphraseForKeys.get(privatekeyFile); + + if (passphrase == null) { + try { + KeyPair kpair = KeyPair.load(jsch, privatekeyFile); + + if (kpair.isEncrypted()) { + + boolean isValid = false; + String message = _("isisfish.ssh.askpassphrase.message", + privatekeyFile); + do { + passphrase = askPassphrase(privatekeyFile, message); + + if (kpair.decrypt(passphrase)) { + isValid = true; + passphraseForKeys.put(privatekeyFile, passphrase); + } else { + message = _( + "isisfish.ssh.askpassphrase.wrongpassphrase", + privatekeyFile); + } + } while (!isValid); + } + } catch (JSchException e) { + throw new RuntimeException("Can't find key : " + privatekeyFile); + } + } + + return passphrase; + } + + /** + * Ask for passphrase. + * + * @param privatekeyFile private key file path + * @param message message + * @return entrered passphrase + * @throws InvalidPassphraseException if user cancel authentication + */ + protected String askPassphrase(String privatekeyFile, String message) + throws InvalidPassphraseException { + + JPasswordField passwordField = new JPasswordField(); + JLabel labelField = new JLabel(message); + + Object[] objs = { labelField, passwordField }; + + int option = JOptionPane.showConfirmDialog(null, objs, + _("isisfish.ssh.askpassphrase.title"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); + + if (option == JOptionPane.CANCEL_OPTION) { + throw new InvalidPassphraseException("User cancel passphrase ask"); + } + + return String.valueOf(passwordField.getPassword()); + } + +} \ No newline at end of file Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2009-04-01 14:56:28 UTC (rev 2057) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2009-04-01 16:51:28 UTC (rev 2058) @@ -30,10 +30,6 @@ import java.util.Map; import java.util.Set; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPasswordField; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.codelutin.util.VersionNumber; @@ -43,10 +39,7 @@ import org.tmatesoft.svn.core.SVNDirEntry; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.auth.BasicAuthenticationManager; import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; -import org.tmatesoft.svn.core.auth.SVNAuthentication; -import org.tmatesoft.svn.core.auth.SVNSSHAuthentication; import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory; import org.tmatesoft.svn.core.internal.io.fs.FSRepositoryFactory; import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl; @@ -66,6 +59,9 @@ import org.tmatesoft.svn.core.wc.SVNWCClient; import org.tmatesoft.svn.core.wc.SVNWCUtil; +import fr.ifremer.isisfish.util.ssh.InvalidPassphraseException; +import fr.ifremer.isisfish.util.ssh.SSHAgent; + /** * SVN VCS. * @@ -150,12 +146,23 @@ + sshKeyFile.getAbsolutePath()); } - // FIXME following AuthenticationManager will try to connect to - // realm and if it fail, will try to ask for passphrase - // even if there is another error - // FIXME 22 here - auth = new SSHSVNAuthenticationManager(login, sshKeyFile, - null, 22); + String passphrase = null; + try { + passphrase = SSHAgent.getAgent().getPassphrase(sshKeyFile); + } + catch(InvalidPassphraseException e) { + if(log.isWarnEnabled()) { + log.warn("Can't get passphrase for key", e); + } + } + + auth = SVNWCUtil.createDefaultAuthenticationManager( + SVNWCUtil.getDefaultConfigurationDirectory(), //File configDir + login, // String userName + null, //String password + sshKeyFile, //File privateKey + passphrase, //String passphrase, + true); //boolean storeAuth) } else { // log for private key @@ -1217,69 +1224,4 @@ return filesInConflict; } -} - -/** - * Authentication manager, that ask for passphrase - * if first authentication fail. - * - * @author chatellier - * @version $Revision: 1.0 $ - * - * Last update : $Date: 23 févr. 2009 $ - * By : $Author: chatellier $ - */ -class SSHSVNAuthenticationManager extends BasicAuthenticationManager { - - protected String userName; - protected File keyFile; - protected int portNumber; - protected JPasswordField passwordField; - - /** - * Creates an auth manager given a user credential - a username and an ssh private key. - * - * @param userName - * @param keyFile - * @param passphrase - * @param portNumber - */ - public SSHSVNAuthenticationManager(String userName, File keyFile, - String passphrase, int portNumber) { - super(userName, keyFile, passphrase, portNumber); - this.userName = userName; - this.keyFile = keyFile; - this.portNumber = portNumber; - passwordField = new JPasswordField(); - } - - /* - * @see org.tmatesoft.svn.core.auth.BasicAuthenticationManager#getNextAuthentication(java.lang.String, java.lang.String, org.tmatesoft.svn.core.SVNURL) - */ - @Override - public SVNAuthentication getNextAuthentication(String kind, String realm, - SVNURL url) throws SVNException { - - SVNAuthentication auth = null; - - if (kind.equals(ISVNAuthenticationManager.SSH) && keyFile != null) { - - JLabel labelField = new JLabel(_( - "isisfish.vcs.vcssvn.connection.message", keyFile - .getAbsolutePath())); - Object[] ob = { labelField, passwordField }; - int option = JOptionPane.showConfirmDialog(null, ob, _( - "isisfish.vcs.vcssvn.connection.title", realm) - + url, JOptionPane.OK_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE); - - if (option != JOptionPane.CANCEL_OPTION) { - auth = new SVNSSHAuthentication(userName, keyFile, new String( - passwordField.getPassword()), portNumber, true); - } - } else { - auth = super.getNextAuthentication(kind, realm, url); - } - return auth; - } } \ No newline at end of file Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties =================================================================== --- isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2009-04-01 14:56:28 UTC (rev 2057) +++ isis-fish/trunk/src/main/resources/i18n/isis-fish-en_GB.properties 2009-04-01 16:51:28 UTC (rev 2058) @@ -1,13 +1,13 @@ Add\ to\ %s\ queue= Add\ to\ default\ queue= Analyse\ plan\ error,\ too\ many\ simulation\ for\ %s\ \:\ %s= -Can''t\ evaluate\ simulation\ prescript= Can't\ add\ result\ '%1$s'\ at\ date\ %2$s=Can't add result '%1$s' at date %2$s Can't\ add\ simulation\:\ = Can't\ create\ simulation\ logger=Can't create simulation logger Can't\ delete\ simulation\ %s\ = Can't\ do\ post\ action\ %s= Can't\ do\ simulation\ %s= +Can't\ download\ file= Can't\ evaluate\ simulation\ prescript= Can't\ export\ simulation\ %s= Can't\ get\ changlog= @@ -23,7 +23,6 @@ Could\ not\ found\ formule\ type\ %s\ autorised\ type\ are\ %s= Error\ during\ vcs\ initialisation= Error\ while\ uploading\ public\ key\ to\ remote\ serveur\ authorized_keys= -Factors\ analyse\ plan= Generate\ next\ simulation= Import\ one\ java\ file\ script\ source= Import\ simulation\ file\ %s\ in\ directory\ %s\ and\ rename\ from\ %s\ to\ %s= @@ -116,7 +115,6 @@ isisfish.common.populations=populations isisfish.common.port=port isisfish.common.prev=previous -isisfish.common.previous=previous isisfish.common.region=region isisfish.common.remove=remove isisfish.common.reset=reset @@ -320,7 +318,6 @@ isisfish.error.save.simulation.parameters=Can't save simulation parameters in file %1$s isisfish.error.script.create=isisfish.error.script.create isisfish.error.script.delete=Can't delete file %1$s for reason %2$s -isisfish.error.script.evaluate= isisfish.error.script.import=Can't import file for reason %1$s isisfish.error.script.load=Can't load file %1$s for reason %2$s isisfish.error.script.save=Can't save file %1$s for reason %2$s @@ -355,20 +352,8 @@ isisfish.export.directory=Export directory isisfish.export.saved=Export saved isisfish.export.title=Results export -isisfish.factor.coefficient=Coefficient (in %) -isisfish.factor.comment=Comment -isisfish.factor.continue=Continue factor -isisfish.factor.discret=Discret factor isisfish.factor.factor=Factor -isisfish.factor.firstValue=First value isisfish.factor.increment=Cardinality -isisfish.factor.lastValue=Last value -isisfish.factor.name=Factor name -isisfish.factor.operateur=Operator -isisfish.factor.selectDiscretNumber=Number of factors -isisfish.factor.title=Factor input -isisfish.factor.validDiscretNumber=Ok -isisfish.factor.value=Value isisfish.filter=Filter isisfish.filter.apply=Apply filter isisfish.filter.cancel=Cancel @@ -531,7 +516,6 @@ isisfish.message.check.region= isisfish.message.checking.cell= isisfish.message.choose.archive=choose archive file or directory -isisfish.message.commit= isisfish.message.commit.cancelled=commit cancelled isisfish.message.commit.finished=commit finished isisfish.message.commit.region.canceled=Commit region canceled @@ -581,7 +565,6 @@ isisfish.message.region.removed=Region removed isisfish.message.remove.canceled=Remove canceled isisfish.message.remove.finished=Remove finished -isisfish.message.remove.unnecessary.cells= isisfish.message.removing.region=Removing region %1$s ... isisfish.message.result.verif.region=R\u00E9sultat de la v\u00E9rification de la r\u00E9gion isisfish.message.save.finished=Save finished @@ -633,8 +616,7 @@ isisfish.params.onlyExportSimulation=Only export simulation isisfish.params.populationNumbers=Population numbers input isisfish.params.ruleParameters=Rule's parameters -isisfish.params.sensibility=Sensibility -isisfish.params.sensibilityName=Sensitivity name +isisfish.params.sensitivityName=Sensitivity name isisfish.params.simulationName=Simulation name isisfish.params.title=Parameters isisfish.params.toString.fishery=P\u00EAcherie\: %1$s\n\n @@ -849,21 +831,6 @@ isisfish.selectivity.title=Selectivity isisfish.sens.backParameter=Back to parameter tab isisfish.sens.title=Sensibility analysis -isisfish.sensWizardPanels.add=Add -isisfish.sensWizardPanels.clear=Clear -isisfish.sensWizardPanels.down=Down -isisfish.sensWizardPanels.field=Field -isisfish.sensWizardPanels.finish=Please click Finish to validate your choices -isisfish.sensWizardPanels.modify=Modify -isisfish.sensWizardPanels.object=Object -isisfish.sensWizardPanels.remove=Remove -isisfish.sensWizardPanels.scripts=Scripts List -isisfish.sensWizardPanels.selectType=Select the type to add -isisfish.sensWizardPanels.type=Type -isisfish.sensWizardPanels.up=Up -isisfish.sensWizardPanels.validate=Validate -isisfish.sensWizardPanels.values=Values -isisfish.sensibilityWizard.title=Sensibility Wizard isisfish.sensitivity.displaysecondpass=Display results isisfish.sensitivity.export=Export isisfish.sensitivity.secondpass=Analyze results @@ -908,6 +875,9 @@ isisfish.species.rubbinCode=Rubbin code isisfish.species.scientificName=Scientific name isisfish.species.structured=Structured +isisfish.ssh.askpassphrase.message=Enter passphrase for key '%s' \: +isisfish.ssh.askpassphrase.title=SSH key unlocking +isisfish.ssh.askpassphrase.wrongpassphrase=Wrong passphrase, enter a new one for key '%s' \: isisfish.strategy.comments=Comments isisfish.strategy.inactivity= isisfish.strategy.inactivityEquationUsed=Use inactivity equation @@ -974,8 +944,6 @@ isisfish.vcs.vcssvn.cleanup.error=Can't cleanup working copy isisfish.vcs.vcssvn.commit.error=Can't commit files isisfish.vcs.vcssvn.commit.errorreadonly=You can't commit file, this repository is readonly -isisfish.vcs.vcssvn.connection.message=Passphrase for key %s -isisfish.vcs.vcssvn.connection.title=Connecting to %s isisfish.vcs.vcssvn.delete.error=Can't delete file isisfish.vcs.vcssvn.delete.errorreadonly=You can't delete file, this repository is readonly isisfish.vcs.vcssvn.diff.error=Can't get diff Modified: isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties =================================================================== --- isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties 2009-04-01 14:56:28 UTC (rev 2057) +++ isis-fish/trunk/src/main/resources/i18n/isis-fish-fr_FR.properties 2009-04-01 16:51:28 UTC (rev 2058) @@ -1,13 +1,13 @@ Add\ to\ %s\ queue= Add\ to\ default\ queue= Analyse\ plan\ error,\ too\ many\ simulation\ for\ %s\ \:\ %s= -Can''t\ evaluate\ simulation\ prescript= Can't\ add\ result\ '%1$s'\ at\ date\ %2$s=Can't add result '%1$s' at date %2$s Can't\ add\ simulation\:\ = Can't\ create\ simulation\ logger=Can't create simulation logger Can't\ delete\ simulation\ %s\ = Can't\ do\ post\ action\ %s= Can't\ do\ simulation\ %s= +Can't\ download\ file= Can't\ evaluate\ simulation\ prescript= Can't\ export\ simulation\ %s= Can't\ get\ changlog=Impossible d'obtenir de changelog @@ -23,7 +23,6 @@ Could\ not\ found\ formule\ type\ %s\ autorised\ type\ are\ %s= Error\ during\ vcs\ initialisation= Error\ while\ uploading\ public\ key\ to\ remote\ serveur\ authorized_keys= -Factors\ analyse\ plan= Generate\ next\ simulation= Import\ one\ java\ file\ script\ source= Import\ simulation\ file\ %s\ in\ directory\ %s\ and\ rename\ from\ %s\ to\ %s= @@ -116,7 +115,6 @@ isisfish.common.populations=Populations isisfish.common.port=port isisfish.common.prev=Pr\u00E9c\u00E9dent -isisfish.common.previous=Pr\u00E9c\u00E9dent isisfish.common.region=R\u00E9gion isisfish.common.remove=Supprimer isisfish.common.reset=reset @@ -320,7 +318,6 @@ isisfish.error.save.simulation.parameters=Can't save simulation parameters in file %1$s isisfish.error.script.create=isisfish.error.script.create isisfish.error.script.delete=N'a pas pu supprimer le fichier %1$s pour la raison suivante %2$s -isisfish.error.script.evaluate= isisfish.error.script.import=N'a pas pu importer pour la raison suivante %1$s isisfish.error.script.load=N'a pas pu charger le fichier %1$s pour la raison suivante %2$s isisfish.error.script.save=N'a pas pu sauver le fichier %1$s pour la raison suivante %2$s @@ -355,20 +352,8 @@ isisfish.export.directory=Dossier d'export isisfish.export.saved=Exports des r\u00E9sultats sauvegard\u00E9s isisfish.export.title=Export des r\u00E9sultats -isisfish.factor.coefficient=Co\u00E9fficient (en %) -isisfish.factor.comment=Commentaires -isisfish.factor.continue=Facteur continu -isisfish.factor.discret=Facteur discret isisfish.factor.factor=Facteur -isisfish.factor.firstValue=Premi\u00E8re valeur isisfish.factor.increment=Cardinalit\u00E9 -isisfish.factor.lastValue=Derni\u00E8re valeur -isisfish.factor.name=Nom du facteur -isisfish.factor.operateur=Op\u00E9rateur -isisfish.factor.selectDiscretNumber=Nombre de facteurs -isisfish.factor.title=Saisie d'un facteur -isisfish.factor.validDiscretNumber=Valider -isisfish.factor.value=Valeur isisfish.filter=Filtrer isisfish.filter.apply=Appliquer le filtre isisfish.filter.cancel=Annuler @@ -531,7 +516,6 @@ isisfish.message.check.region= isisfish.message.checking.cell= isisfish.message.choose.archive=choose archive file or directory -isisfish.message.commit= isisfish.message.commit.cancelled=commit annul\u00E9 isisfish.message.commit.finished=commit termin\u00E9 isisfish.message.commit.region.canceled=Commit de la r\u00E9gion annul\u00E9 @@ -581,7 +565,6 @@ isisfish.message.region.removed=R\u00E9gion supprim\u00E9e isisfish.message.remove.canceled=Suppression annul\u00E9e isisfish.message.remove.finished=Suppresison termin\u00E9 -isisfish.message.remove.unnecessary.cells= isisfish.message.removing.region=Suppression de la r\u00E9gion %1$s ... isisfish.message.result.verif.region=R\u00E9sultat de la v\u00E9rification de la r\u00E9gion isisfish.message.save.finished=Sauvegarde termin\u00E9e @@ -633,8 +616,7 @@ isisfish.params.onlyExportSimulation=Exporter uniquement des simulations isisfish.params.populationNumbers=Donn\u00E9es de population isisfish.params.ruleParameters=Param\u00E8tres des r\u00E8gles -isisfish.params.sensibility=Sensibilit\u00E9 -isisfish.params.sensibilityName=Nom de l'analyse de sensibilit\u00E9 +isisfish.params.sensitivityName=Nom de l'analyse de sensibilit\u00E9 isisfish.params.simulationName=Nom de la simulation isisfish.params.title=Param\u00E8tres isisfish.params.toString.fishery=P\u00EAcherie\: %1$s\n\n @@ -849,21 +831,6 @@ isisfish.selectivity.title=S\u00E9lectivit\u00E9 isisfish.sens.backParameter=Retour aux param\u00E8tres isisfish.sens.title=Plan de simulation -isisfish.sensWizardPanels.add=Ajouter -isisfish.sensWizardPanels.clear=Effacer -isisfish.sensWizardPanels.down=Bas -isisfish.sensWizardPanels.field=Champ -isisfish.sensWizardPanels.finish=Cliquez sur Terminer pour valider vos choix -isisfish.sensWizardPanels.modify=Modifier -isisfish.sensWizardPanels.object=Objet -isisfish.sensWizardPanels.remove=Supprimer -isisfish.sensWizardPanels.scripts=Liste des scripts -isisfish.sensWizardPanels.selectType=Selectionner le type \u00E0 ajouter -isisfish.sensWizardPanels.type=Type -isisfish.sensWizardPanels.up=Haut -isisfish.sensWizardPanels.validate=Valider -isisfish.sensWizardPanels.values=Valeurs -isisfish.sensibilityWizard.title=Sensibility Wizard isisfish.sensitivity.displaysecondpass=Afficher les r\u00E9sultats isisfish.sensitivity.export=Export isisfish.sensitivity.secondpass=Analyse des r\u00E9sultats @@ -908,6 +875,9 @@ isisfish.species.rubbinCode=Code Rubbin isisfish.species.scientificName=Scientific name isisfish.species.structured=Structur\u00E9 +isisfish.ssh.askpassphrase.message=Entrez la passphrase pour la cl\u00E9 '%s' \: +isisfish.ssh.askpassphrase.title=D\u00E9verrouillage de cl\u00E9 SSH +isisfish.ssh.askpassphrase.wrongpassphrase=Mauvaise cl\u00E9, entrez une nouvelle passphrase '%s' \: isisfish.strategy.comments=Commentaires isisfish.strategy.inactivity=Equation d'inactivit\u00E9 isisfish.strategy.inactivityEquationUsed=Utiliser une \u00E9quation d'inactivit\u00E9 @@ -974,8 +944,6 @@ isisfish.vcs.vcssvn.cleanup.error=Impossible de d\u00E9verrouiller la copie locale isisfish.vcs.vcssvn.commit.error=Impossible de commiter isisfish.vcs.vcssvn.commit.errorreadonly=Vous ne pouvez pas commiter, le d\u00E9p\u00F4t est en lecture seule -isisfish.vcs.vcssvn.connection.message=Passphrase pour la cl\u00E9 %s -isisfish.vcs.vcssvn.connection.title=Connexion \u00E0 %s isisfish.vcs.vcssvn.delete.error=Impossible de supprimer des fichiers isisfish.vcs.vcssvn.delete.errorreadonly=Vous ne pouvez pas supprimer ce fichier, le d\u00E9p\u00F4t est en lecture seule isisfish.vcs.vcssvn.diff.error=Impossible d'obtenir le diff Deleted: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/SSHUtils.java =================================================================== --- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/SSHUtils.java 2009-04-01 14:56:28 UTC (rev 2057) +++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/SSHUtils.java 2009-04-01 16:51:28 UTC (rev 2058) @@ -1,99 +0,0 @@ -/* *##% - * Copyright (C) 2009 Code Lutin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *##%*/ - -package fr.ifremer.isisfish.util; - -import java.io.File; -import java.net.URISyntaxException; -import java.net.URL; - -import junit.framework.Assert; - -import org.codelutin.util.Resource; -import org.junit.BeforeClass; -import org.junit.Test; - -import com.jcraft.jsch.JSch; -import com.jcraft.jsch.JSchException; -import com.jcraft.jsch.KeyPair; - -/** - * Class de test créé pour tester et centraliser la gestion - * des clés SSH et leur passphrase dans Isis. - * - * @author chatellier - * @version $Revision: 1.0 $ - * - * Last update : $Date: 1 avr. 2009 $ - * By : $Author: chatellier $ - */ -public class SSHUtils { - - protected static File keyFile; - - /** - * Find ssh key file. - * - * @throws URISyntaxException - */ - @BeforeClass - public static void init() throws URISyntaxException { - keyFile = new File("src/test/resources/ssh/isistestkey"); - } - - /** - * Test que la clé existe. - */ - @Test - public void testKeyExist() { - Assert.assertNotNull(keyFile); - Assert.assertTrue(keyFile.isFile()); - } - - /** - * Test si une passphrase est valide pour une clé SSH. - * - * @throws JSchException - */ - @Test - public void testIsValidPassphrase() throws JSchException { - String passphrase = "isispassphrase"; - - JSch jsch=new JSch(); - KeyPair kpair=KeyPair.load(jsch, keyFile.getAbsolutePath()); - - Assert.assertTrue(kpair.isEncrypted()); // cle protegee - Assert.assertTrue(kpair.decrypt(passphrase)); // decodage fonctionne - - } - - /** - * Test qu'une passphrase n'est pas valide pour une clé. - * @throws JSchException - */ - @Test - public void testIsNotValidPassphrase() throws JSchException { - String passphrase = "passphare not good"; - - JSch jsch=new JSch(); - KeyPair kpair=KeyPair.load(jsch, keyFile.getAbsolutePath()); - - Assert.assertTrue(kpair.isEncrypted()); // cle protegee - Assert.assertFalse(kpair.decrypt(passphrase)); // decodage fonctionne - } -} Copied: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/ssh/SSHAgentTest.java (from rev 2057, isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/SSHUtils.java) =================================================================== --- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/ssh/SSHAgentTest.java (rev 0) +++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/util/ssh/SSHAgentTest.java 2009-04-01 16:51:28 UTC (rev 2058) @@ -0,0 +1,97 @@ +/* *##% + * Copyright (C) 2009 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +package fr.ifremer.isisfish.util.ssh; + +import java.io.File; +import java.net.URISyntaxException; + +import junit.framework.Assert; + +import org.junit.BeforeClass; +import org.junit.Test; + +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.JSchException; +import com.jcraft.jsch.KeyPair; + +/** + * Class de test créé pour tester et centraliser la gestion + * des clés SSH et leur passphrase dans Isis. + * + * @author chatellier + * @version $Revision: 1.0 $ + * + * Last update : $Date: 1 avr. 2009 $ + * By : $Author: chatellier $ + */ +public class SSHAgentTest { + + protected static File keyFile; + + /** + * Find ssh key file. + * + * @throws URISyntaxException + */ + @BeforeClass + public static void init() throws URISyntaxException { + keyFile = new File("src/test/resources/ssh/isistestkey"); + } + + /** + * Test que la clé existe. + */ + @Test + public void testKeyExist() { + Assert.assertNotNull(keyFile); + Assert.assertTrue(keyFile.isFile()); + } + + /** + * Test si une passphrase est valide pour une clé SSH. + * + * @throws JSchException + */ + @Test + public void testIsValidPassphrase() throws JSchException { + String passphrase = "isispassphrase"; + + JSch jsch=new JSch(); + KeyPair kpair=KeyPair.load(jsch, keyFile.getAbsolutePath()); + + Assert.assertTrue(kpair.isEncrypted()); // cle protegee + Assert.assertTrue(kpair.decrypt(passphrase)); // decodage fonctionne + + } + + /** + * Test qu'une passphrase n'est pas valide pour une clé. + * @throws JSchException + */ + @Test + public void testIsNotValidPassphrase() throws JSchException { + String passphrase = "passphare not good"; + + JSch jsch=new JSch(); + KeyPair kpair=KeyPair.load(jsch, keyFile.getAbsolutePath()); + + Assert.assertTrue(kpair.isEncrypted()); // cle protegee + Assert.assertFalse(kpair.decrypt(passphrase)); // decodage fonctionne + } +}
participants (1)
-
chatellier@users.labs.libre-entreprise.org