diff options
author | Kalina Jasinska <kalina.jasinska@gmail.com> | 2013-09-05 09:53:03 (GMT) |
---|---|---|
committer | Kalina Jasinska <kalina.jasinska@gmail.com> | 2013-09-05 09:53:03 (GMT) |
commit | c5eec6e9259d31e50bd3e3a2dda64d6517f1e7db (patch) | |
tree | 9d17d2c3500e39e2b3aa5e093c1e2565e599c6be | |
parent | efde462d09e71faa590aa663085dfb8aa4f795d3 (diff) | |
download | QCG-Data-c5eec6e9259d31e50bd3e3a2dda64d6517f1e7db.zip QCG-Data-c5eec6e9259d31e50bd3e3a2dda64d6517f1e7db.tar.gz QCG-Data-c5eec6e9259d31e50bd3e3a2dda64d6517f1e7db.tar.bz2 |
certificases.zip added, keyFS mode, default elder10 for public links, before changes in interface
9 files changed, 713 insertions, 89 deletions
diff --git a/idrop-swing/pom.xml b/idrop-swing/pom.xml index 996239c..8c542ba 100644 --- a/idrop-swing/pom.xml +++ b/idrop-swing/pom.xml @@ -112,6 +112,12 @@ <artifactId>libbrowser</artifactId> <version>1</version> </dependency> + <dependency> + <groupId>com.jcraft</groupId> + <artifactId>jsch</artifactId> + <version>0.1.27</version> + <type>jar</type> + </dependency> </dependencies> <build> <plugins> diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.form b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.form index 0fe055a..2c662b9 100644 --- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.form +++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.form @@ -13,6 +13,7 @@ </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> </SyntheticProperties> <AuxValues> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.java index 37b6c7a..85b5010 100644 --- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.java +++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.java @@ -92,6 +92,20 @@ public class IDROPConfigurationPanel extends javax.swing.JDialog { } }); + // default value of publicLinkService url + String publicLinkDef = "http://elder10.man.poznan.pl:8080/gdrop-web/register"; + String publicLinkAddress = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.IDROP_PUBLIC_LINK_SERVICE); + if(publicLinkAddress == null){ + publicLinkAddress = publicLinkDef; + } + txtPublicLinks.setText(publicLinkAddress); + try { + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.IDROP_PUBLIC_LINK_SERVICE, txtPublicLinks.getText()); + } catch (IdropException ex) { + log.error("Error saving public link service url.",ex); + } + + pnlConfigPublicLinks.add(txtPublicLinks); tabConfig.addTab("Public links", pnlConfigPublicLinks); } diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/LoginDialog.form b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/LoginDialog.form index 12a7651..4042fc2 100644 --- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/LoginDialog.form +++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/LoginDialog.form @@ -22,7 +22,7 @@ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-68,0,0,2,-87"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,19,0,0,2,-87"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> @@ -182,7 +182,7 @@ <Container class="javax.swing.JPanel" name="jPanel1"> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> - <GridBagConstraints gridX="1" gridY="17" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + <GridBagConstraints gridX="1" gridY="22" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> </Constraint> </Constraints> @@ -222,7 +222,7 @@ </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> - <GridBagConstraints gridX="0" gridY="16" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> + <GridBagConstraints gridX="0" gridY="21" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> </Constraint> </Constraints> </Component> @@ -238,7 +238,7 @@ </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> - <GridBagConstraints gridX="1" gridY="16" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/> + <GridBagConstraints gridX="1" gridY="21" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/> </Constraint> </Constraints> </Component> @@ -365,6 +365,17 @@ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnProxyFileActionPerformed"/> </Events> </Component> + <Component class="javax.swing.JRadioButton" name="btnProxyKeyFS"> + <Properties> + <Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor"> + <ComponentRef name="btngrpProxySource"/> + </Property> + <Property name="text" type="java.lang.String" value="KeyFS"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnProxyKeyFSActionPerformed"/> + </Events> + </Component> </SubComponents> </Container> <Component class="javax.swing.JTextField" name="txtKeyLocation"> @@ -427,7 +438,7 @@ </Constraint> </Constraints> </Component> - <Component class="javax.swing.JLabel" name="lblCertPass"> + <Component class="javax.swing.JLabel" name="lblCertPassP12"> <Properties> <Property name="text" type="java.lang.String" value="Certificate password:"/> </Properties> @@ -437,7 +448,7 @@ </Constraint> </Constraints> </Component> - <Component class="javax.swing.JPasswordField" name="certpass"> + <Component class="javax.swing.JPasswordField" name="certpassP12"> <Properties> <Property name="columns" type="int" value="30"/> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> @@ -486,7 +497,7 @@ </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> - <GridBagConstraints gridX="0" gridY="13" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> + <GridBagConstraints gridX="0" gridY="14" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> </Constraint> </Constraints> </Component> @@ -499,7 +510,7 @@ </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> - <GridBagConstraints gridX="1" gridY="14" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/> + <GridBagConstraints gridX="1" gridY="15" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/> </Constraint> </Constraints> </Component> @@ -509,7 +520,7 @@ </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> - <GridBagConstraints gridX="0" gridY="14" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> + <GridBagConstraints gridX="0" gridY="15" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> </Constraint> </Constraints> </Component> @@ -529,7 +540,7 @@ </Events> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> - <GridBagConstraints gridX="1" gridY="13" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + <GridBagConstraints gridX="1" gridY="14" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> </Constraint> </Constraints> </Component> @@ -539,7 +550,7 @@ </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> - <GridBagConstraints gridX="0" gridY="15" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> + <GridBagConstraints gridX="0" gridY="16" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> </Constraint> </Constraints> </Component> @@ -559,7 +570,7 @@ </Events> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> - <GridBagConstraints gridX="1" gridY="15" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + <GridBagConstraints gridX="1" gridY="16" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> </Constraint> </Constraints> </Component> @@ -572,7 +583,124 @@ </Events> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> - <GridBagConstraints gridX="2" gridY="14" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + <GridBagConstraints gridX="2" gridY="15" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lblCertPassPEM"> + <Properties> + <Property name="text" type="java.lang.String" value="Key password:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="13" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JPasswordField" name="certpassPEM"> + <Properties> + <Property name="columns" type="int" value="30"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="null"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="13" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lblLdapKeyPass"> + <Properties> + <Property name="text" type="java.lang.String" value="Key password:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="19" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JPasswordField" name="ldapKeyPassword"> + <Properties> + <Property name="columns" type="int" value="30"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="null"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="19" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lblPLGRIDUserName"> + <Properties> + <Property name="text" type="java.lang.String" value="PLGRID User Name:"/> + <Property name="toolTipText" type="java.lang.String" value=""/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="17" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtPLGRIDUserName"> + <Properties> + <Property name="columns" type="int" value="30"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="null"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="17" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lblplgridpass"> + <Properties> + <Property name="text" type="java.lang.String" value="PLGRID Password:"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="18" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JPasswordField" name="plgridpass"> + <Properties> + <Property name="columns" type="int" value="30"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="null"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="18" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JTextField" name="txtKeyfsLifetime"> + <Properties> + <Property name="columns" type="int" value="30"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="null"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="1" gridY="20" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="17" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JLabel" name="lblKeyfsLifetime"> + <Properties> + <Property name="text" type="java.lang.String" value="Proxy lifetime (hours):"/> + <Property name="toolTipText" type="java.lang.String" value=""/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="20" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="22" weightX="0.0" weightY="0.0"/> </Constraint> </Constraints> </Component> diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/LoginDialog.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/LoginDialog.java index d45d35c..86e50b7 100644 --- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/LoginDialog.java +++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/LoginDialog.java @@ -34,14 +34,21 @@ import org.irods.jargon.core.connection.auth.AuthResponse; import org.irods.jargon.core.exception.JargonException; import org.irods.jargon.core.pub.IRODSFileSystem; import org.irods.jargon.idrop.desktop.systraygui.gss.CertificateConverter; -import org.irods.jargon.idrop.desktop.systraygui.gss.GssSecurityException; import org.irods.jargon.idrop.desktop.systraygui.gss.GssUtil; +import org.irods.jargon.idrop.desktop.systraygui.gss.ZipFileExtractor; import org.irods.jargon.idrop.desktop.systraygui.services.IdropConfigurationService; import org.irods.jargon.idrop.desktop.systraygui.utils.IdropPropertiesHelper; import org.irods.jargon.idrop.exceptions.IdropException; import org.irods.jargon.idrop.exceptions.IdropRuntimeException; import org.slf4j.LoggerFactory; import uk.ac.rl.esc.browser.Browser; +import com.jcraft.jsch.Channel; +import com.jcraft.jsch.ChannelExec; +import com.jcraft.jsch.ChannelSftp; +import com.jcraft.jsch.JSch; +import com.jcraft.jsch.JSchException; +import com.jcraft.jsch.SftpException; +import java.io.InputStream; /** * @@ -62,19 +69,28 @@ public class LoginDialog extends JDialog { static final int P12_MODE = 2; static final int BROWSER_MODE = 3; static final int PROXY_MODE = 4; - + static final int KEYFS_MODE = 5; + // default certificates location + static String IDROP_HOME = ""; + static String DEFAULT_CA_FILES_NAME = "/certificates"; + static final String CA_ZIP_FILE_PATH = "certificates.zip";//zip? + boolean CAfilesConfigured = false; boolean tryToLogin; - + public LoginDialog(final JDialog parentDialog, final IDROPCore idropCore, boolean tryToLogin) { super(parentDialog, true); this.tryToLogin = tryToLogin; - + if (idropCore == null) { throw new IllegalArgumentException("null idropCore"); } this.idropCore = idropCore; initComponents(); + // set needed variables + IDROP_HOME = deriveConfigHomeDirectory(); + CAfilesConfigured = configureCAFiles(); + if (idropCore.getIdropConfig().isLoginPreset()) { loginUsingPreset(); } else { @@ -83,7 +99,52 @@ public class LoginDialog extends JDialog { registerKeystrokeListener(); setLocationRelativeTo(parentDialog); - + + } + //construct path to idrop home + + private String deriveConfigHomeDirectory() { + String userHomeDirectory = System.getProperty("user.home"); + userHomeDirectory = userHomeDirectory.replaceAll("\\\\", "/"); + StringBuilder sb = new StringBuilder(); + sb.append(userHomeDirectory); + sb.append("/.idrop"); + String derivedConfigHomeDirectory = sb.toString(); + return derivedConfigHomeDirectory; + } + /* + * Extracts certificates from package inside idrop jar to default location + */ + + private boolean configureCAFiles() { + File caDir = new File(IDROP_HOME + DEFAULT_CA_FILES_NAME); + + if (caDir.exists() && (!caDir.canRead() || !caDir.canWrite())) { + log.debug("Do not have sufficient read & write permissions CA certificates directory: " + IDROP_HOME + DEFAULT_CA_FILES_NAME); + return false; + } + + if (!caDir.exists()) { + log.info("Trying to create " + IDROP_HOME + DEFAULT_CA_FILES_NAME); + if (caDir.mkdir()) { + log.info(caDir.getPath() + " created"); + } else { + log.error("Unable to make CA certificates directory: " + IDROP_HOME + DEFAULT_CA_FILES_NAME); + } + } + try { + String dest = IDROP_HOME + DEFAULT_CA_FILES_NAME + ".zip"; + ZipFileExtractor.unzipFile(LoginDialog.class.getClassLoader(), CA_ZIP_FILE_PATH, dest); + txtCerts.setText(dest); + } catch (Exception e) { + + if (caDir.exists() && (caDir.list().length == 0)) { + caDir.delete(); + log.debug("Empty certificates dir deleted."); + return false; + } + } + return true; } private void loginNormally() { @@ -117,6 +178,9 @@ public class LoginDialog extends JDialog { if (certificates != null) { txtCerts.setText(certificates); + } else if (CAfilesConfigured) { + // if no diferent location was set - set default one + txtCerts.setText(IDROP_HOME + DEFAULT_CA_FILES_NAME); } // Read paths from propeties: PEM certificate, PEM key, p12 certificate @@ -153,41 +217,59 @@ public class LoginDialog extends JDialog { String username = idropCore.getIdropConfig().getPropertyForKey( IdropConfigurationService.ACCOUNT_CACHE_USER_NAME); txtUserName.setText(username); - + String plgridusername = idropCore.getIdropConfig().getPropertyForKey( + IdropConfigurationService.ACCOUNT_CACHE_PLGRID_USERNAME); + txtPLGRIDUserName.setText(plgridusername); + String save = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_USER_SAVE_PASS); boolean saveP = "true".equals(save); boolean autoGsi = false; String gsi = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_USER_AUTO_GSI); autoGsi = "true".equals(gsi); - + hideAdvancedViewFields(); hideProxyLoginFields(); - - if(autoGsi){ + + if (autoGsi) { hideNormalLoginFields(); showProxyLoginFields(); chkProxyLogin.setSelected(true); String gsiMode = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_CERT_LOGIN_MODE); - try{ + try { int gsiModeNum = Integer.parseInt(gsiMode); setSelectedModeFields(gsiModeNum); showProxyChoosenModeFields(); - }catch(Exception e){ + } catch (Exception e) { } } - + if (saveP) { String savedPassword = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_USER_PASSWORD); password.setText(savedPassword); chkRememberPass.setSelected(true); - - String certPassword = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_CERT_PASSWORD); - certpass.setText(certPassword); - if(tryToLogin){ + + String certp12Password = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_CERT_P12_PASSWORD); + certpassP12.setText(certp12Password); + + String certPemPassword = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_CERT_PEM_PASSWORD); + certpassPEM.setText(certPemPassword); + + String plgpassword = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_PLGRID_PASSWORD); + String plgkeypassword = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_PLGRID_KEY_PASSWORD); + plgridpass.setText(plgpassword); + ldapKeyPassword.setText(plgkeypassword); + + if (tryToLogin) { loginTrialSuccesful = !processLogin(); } } + //if location not set - show field to set it + if (!CAfilesConfigured || txtCerts.getText() == null || "".equals(txtCerts.getText())) { + txtCerts.setVisible(true); + lblCerts.setVisible(true); + btnCerts.setVisible(true); + } } private void loginUsingPreset() { @@ -283,7 +365,9 @@ public class LoginDialog extends JDialog { } else if (chkProxyLogin.isSelected()) { GSSCredential gssCred = getGssCredential(); - + if(gssCred == null){ + throw new Exception(); + } GSIIRODSAccount acc = GSIIRODSAccount.instance(presetHost, presetPort, gssCred, presetResource); acc.setCertificateAuthority(txtCerts.getText()); irodsAccount = acc; @@ -307,7 +391,9 @@ public class LoginDialog extends JDialog { } else if (chkProxyLogin.isSelected()) { // TODO GSSCredential gssCred = getGssCredential(); - + if(gssCred == null){ + throw new Exception(); + } GSIIRODSAccount acc = GSIIRODSAccount.instance( txtHost.getText().trim(), @@ -339,8 +425,8 @@ public class LoginDialog extends JDialog { Logger.getLogger(LoginDialog.class.getName()).log(Level.SEVERE, null, ex); MessageManager.showError(this, ex.getMessage(), MessageManager.TITLE_MESSAGE); return true; - } catch (GssSecurityException ex) {//? - Logger.getLogger(LoginDialog.class.getName()).log(Level.SEVERE, null, ex); + } catch (Exception ex) {//? + Logger.getLogger(LoginDialog.class.getName()).log(Level.WARNING, null, ex); MessageManager.showError(this, "Wrong certifcate, key, password or proxy.", "Login Error"); @@ -367,21 +453,32 @@ public class LoginDialog extends JDialog { .getAuthenticatedIRODSAccount()); try { idropCore.getIdropConfigurationService().saveLogin(irodsAccount); - if(chkRememberPass.isSelected()){ + if (chkRememberPass.isSelected()) { idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_USER_PASSWORD, - irodsAccount.getPassword()); + irodsAccount.getPassword()); idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_USER_SAVE_PASS, - "true"); - - idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_CERT_PASSWORD, - certpass.getText()); - }else{ - idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_USER_PASSWORD, - ""); - idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_USER_SAVE_PASS, - "false"); - idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_CERT_PASSWORD, - ""); + "true"); + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_CERT_P12_PASSWORD, + new String(certpassP12.getPassword())); + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_CERT_PEM_PASSWORD, + new String(certpassPEM.getPassword())); + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_PLGRID_PASSWORD, + new String(plgridpass.getPassword())); + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_PLGRID_KEY_PASSWORD, + new String(ldapKeyPassword.getPassword())); + } else { + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_USER_PASSWORD, + ""); + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_USER_SAVE_PASS, + "false"); + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_CERT_P12_PASSWORD, + ""); + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_CERT_PEM_PASSWORD, + ""); + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_PLGRID_PASSWORD, + ""); + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_PLGRID_KEY_PASSWORD, + ""); } idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_PROXY_LOCATION, txtProxy.getText()); idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_CERTIFICATES_LOCATION, txtCerts.getText()); @@ -398,7 +495,10 @@ public class LoginDialog extends JDialog { idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_CERT_PEM_LOCATION, txtPEMCertificateLocation.getText()); idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_KEY_PEM_LOCATION, txtKeyLocation.getText()); idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_CERT_P12_LOCATION, txtP12CertificateLocation.getText()); - + + idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_PLGRID_USERNAME, + txtPLGRIDUserName.getText()); + //todo save proxy path and certificates location } catch (IdropException ex) { @@ -513,14 +613,15 @@ public class LoginDialog extends JDialog { btnProxyP12 = new javax.swing.JRadioButton(); btnProxyBrowser = new javax.swing.JRadioButton(); btnProxyFile = new javax.swing.JRadioButton(); + btnProxyKeyFS = new javax.swing.JRadioButton(); txtKeyLocation = new javax.swing.JTextField(); lblKeyLocation = new javax.swing.JLabel(); btnKeyLocation = new javax.swing.JButton(); lblP12CertificateLocation = new javax.swing.JLabel(); txtP12CertificateLocation = new javax.swing.JTextField(); btnP12CertificateLocation = new javax.swing.JButton(); - lblCertPass = new javax.swing.JLabel(); - certpass = new javax.swing.JPasswordField(); + lblCertPassP12 = new javax.swing.JLabel(); + certpassP12 = new javax.swing.JPasswordField(); lblPEMCertificateLocation = new javax.swing.JLabel(); txtPEMCertificateLocation = new javax.swing.JTextField(); btnPEMCertificateLocation = new javax.swing.JButton(); @@ -531,6 +632,16 @@ public class LoginDialog extends JDialog { lbllCertCombo = new javax.swing.JLabel(); cmbCertificates = new javax.swing.JComboBox(); btnCheckCertsInBrowser = new javax.swing.JButton(); + lblCertPassPEM = new javax.swing.JLabel(); + certpassPEM = new javax.swing.JPasswordField(); + lblLdapKeyPass = new javax.swing.JLabel(); + ldapKeyPassword = new javax.swing.JPasswordField(); + lblPLGRIDUserName = new javax.swing.JLabel(); + txtPLGRIDUserName = new javax.swing.JTextField(); + lblplgridpass = new javax.swing.JLabel(); + plgridpass = new javax.swing.JPasswordField(); + txtKeyfsLifetime = new javax.swing.JTextField(); + lblKeyfsLifetime = new javax.swing.JLabel(); pnlToolbar = new javax.swing.JPanel(); chkRememberPass = new javax.swing.JCheckBox(); btnOK = new javax.swing.JButton(); @@ -667,14 +778,14 @@ public class LoginDialog extends JDialog { gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 17; + gridBagConstraints.gridy = 22; pnlLoginInfo.add(jPanel1, gridBagConstraints); lblLoginMode.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); lblLoginMode.setText("Login Mode:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 16; + gridBagConstraints.gridy = 21; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; pnlLoginInfo.add(lblLoginMode, gridBagConstraints); @@ -682,7 +793,7 @@ public class LoginDialog extends JDialog { comboLoginMode.setToolTipText("Authentication mode used at login"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 16; + gridBagConstraints.gridy = 21; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START; pnlLoginInfo.add(comboLoginMode, gridBagConstraints); @@ -774,6 +885,15 @@ public class LoginDialog extends JDialog { }); jPanel2.add(btnProxyFile); + btngrpProxySource.add(btnProxyKeyFS); + btnProxyKeyFS.setText("KeyFS"); + btnProxyKeyFS.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnProxyKeyFSActionPerformed(evt); + } + }); + jPanel2.add(btnProxyKeyFS); + pnlLoginInfo.add(jPanel2, new java.awt.GridBagConstraints()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; @@ -823,21 +943,21 @@ public class LoginDialog extends JDialog { gridBagConstraints.gridy = 7; pnlLoginInfo.add(btnP12CertificateLocation, gridBagConstraints); - lblCertPass.setText("Certificate password:"); + lblCertPassP12.setText("Certificate password:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 12; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; - pnlLoginInfo.add(lblCertPass, gridBagConstraints); + pnlLoginInfo.add(lblCertPassP12, gridBagConstraints); - certpass.setColumns(30); - certpass.setPreferredSize(null); + certpassP12.setColumns(30); + certpassP12.setPreferredSize(null); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 12; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; - pnlLoginInfo.add(certpass, gridBagConstraints); + pnlLoginInfo.add(certpassP12, gridBagConstraints); lblPEMCertificateLocation.setText("PEM Certificate location:"); gridBagConstraints = new java.awt.GridBagConstraints(); @@ -865,7 +985,7 @@ public class LoginDialog extends JDialog { lbllBrowserCombo.setText("Selected browser:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 13; + gridBagConstraints.gridy = 14; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; pnlLoginInfo.add(lbllBrowserCombo, gridBagConstraints); @@ -873,7 +993,7 @@ public class LoginDialog extends JDialog { browserpass.setPreferredSize(null); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 14; + gridBagConstraints.gridy = 15; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; pnlLoginInfo.add(browserpass, gridBagConstraints); @@ -881,7 +1001,7 @@ public class LoginDialog extends JDialog { lblBrowserPass.setText("Browser password:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 14; + gridBagConstraints.gridy = 15; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; pnlLoginInfo.add(lblBrowserPass, gridBagConstraints); @@ -893,14 +1013,14 @@ public class LoginDialog extends JDialog { }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 13; + gridBagConstraints.gridy = 14; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; pnlLoginInfo.add(cmbBrowsers, gridBagConstraints); lbllCertCombo.setText("Selected certificate:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; - gridBagConstraints.gridy = 15; + gridBagConstraints.gridy = 16; gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; pnlLoginInfo.add(lbllCertCombo, gridBagConstraints); @@ -912,7 +1032,7 @@ public class LoginDialog extends JDialog { }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; - gridBagConstraints.gridy = 15; + gridBagConstraints.gridy = 16; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; pnlLoginInfo.add(cmbCertificates, gridBagConstraints); @@ -924,9 +1044,91 @@ public class LoginDialog extends JDialog { }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; - gridBagConstraints.gridy = 14; + gridBagConstraints.gridy = 15; pnlLoginInfo.add(btnCheckCertsInBrowser, gridBagConstraints); + lblCertPassPEM.setText("Key password:"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 13; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; + pnlLoginInfo.add(lblCertPassPEM, gridBagConstraints); + + certpassPEM.setColumns(30); + certpassPEM.setPreferredSize(null); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 13; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + pnlLoginInfo.add(certpassPEM, gridBagConstraints); + + lblLdapKeyPass.setText("Key password:"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 19; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; + pnlLoginInfo.add(lblLdapKeyPass, gridBagConstraints); + + ldapKeyPassword.setColumns(30); + ldapKeyPassword.setPreferredSize(null); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 19; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + pnlLoginInfo.add(ldapKeyPassword, gridBagConstraints); + + lblPLGRIDUserName.setText("PLGRID User Name:"); + lblPLGRIDUserName.setToolTipText(""); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 17; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; + pnlLoginInfo.add(lblPLGRIDUserName, gridBagConstraints); + + txtPLGRIDUserName.setColumns(30); + txtPLGRIDUserName.setPreferredSize(null); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 17; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + pnlLoginInfo.add(txtPLGRIDUserName, gridBagConstraints); + + lblplgridpass.setText("PLGRID Password:"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 18; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; + pnlLoginInfo.add(lblplgridpass, gridBagConstraints); + + plgridpass.setColumns(30); + plgridpass.setPreferredSize(null); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 18; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + pnlLoginInfo.add(plgridpass, gridBagConstraints); + + txtKeyfsLifetime.setColumns(30); + txtKeyfsLifetime.setPreferredSize(null); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 20; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + pnlLoginInfo.add(txtKeyfsLifetime, gridBagConstraints); + + lblKeyfsLifetime.setText("Proxy lifetime (hours):"); + lblKeyfsLifetime.setToolTipText(""); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 20; + gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END; + pnlLoginInfo.add(lblKeyfsLifetime, gridBagConstraints); + getContentPane().add(pnlLoginInfo, java.awt.BorderLayout.CENTER); pnlToolbar.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 2, 5)); @@ -1031,6 +1233,7 @@ public class LoginDialog extends JDialog { hideCertP12Fields(); hideCertInBrowserFields(); hideProxyFileFields(); + hideKeyFSFields(); showCertKeyPairFields(); }//GEN-LAST:event_btnProxyCertKeyPairActionPerformed @@ -1039,6 +1242,7 @@ public class LoginDialog extends JDialog { hideCertKeyPairFields(); hideCertInBrowserFields(); hideProxyFileFields(); + hideKeyFSFields(); showCertP12Fields(); }//GEN-LAST:event_btnProxyP12ActionPerformed @@ -1047,6 +1251,7 @@ public class LoginDialog extends JDialog { hideCertKeyPairFields(); hideCertP12Fields(); hideProxyFileFields(); + hideKeyFSFields(); showCertInBrowserFields(); fillBrowserComboBox(); }//GEN-LAST:event_btnProxyBrowserActionPerformed @@ -1056,6 +1261,7 @@ public class LoginDialog extends JDialog { hideCertKeyPairFields(); hideCertP12Fields(); hideCertInBrowserFields(); + hideKeyFSFields(); showProxyFileFields(); }//GEN-LAST:event_btnProxyFileActionPerformed @@ -1083,6 +1289,14 @@ public class LoginDialog extends JDialog { } }//GEN-LAST:event_btnCheckCertsInBrowserActionPerformed + private void btnProxyKeyFSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProxyKeyFSActionPerformed + hideCertP12Fields(); + hideCertInBrowserFields(); + hideProxyFileFields(); + hideCertKeyPairFields(); + showKeyFSFields(); + }//GEN-LAST:event_btnProxyKeyFSActionPerformed + private void chkAdvancedLoginActionPerformed( final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_chkAdvancedLoginActionPerformed // TODO add your handling code here: @@ -1125,9 +1339,11 @@ public class LoginDialog extends JDialog { private javax.swing.JRadioButton btnProxyBrowser; private javax.swing.JRadioButton btnProxyCertKeyPair; private javax.swing.JRadioButton btnProxyFile; + private javax.swing.JRadioButton btnProxyKeyFS; private javax.swing.JRadioButton btnProxyP12; private javax.swing.ButtonGroup btngrpProxySource; - private javax.swing.JPasswordField certpass; + private javax.swing.JPasswordField certpassP12; + private javax.swing.JPasswordField certpassPEM; private javax.swing.JCheckBox chkAdvancedLogin; private javax.swing.JCheckBox chkGuestLogin; private javax.swing.JCheckBox chkProxyLogin; @@ -1139,14 +1355,18 @@ public class LoginDialog extends JDialog { private javax.swing.JPanel jPanel2; private javax.swing.JLabel lblBrowserPass; private javax.swing.JLabel lblCertMode; - private javax.swing.JLabel lblCertPass; + private javax.swing.JLabel lblCertPassP12; + private javax.swing.JLabel lblCertPassPEM; private javax.swing.JLabel lblCerts; private javax.swing.JLabel lblHost; private javax.swing.JLabel lblKeyLocation; + private javax.swing.JLabel lblKeyfsLifetime; + private javax.swing.JLabel lblLdapKeyPass; private javax.swing.JLabel lblLogin; private javax.swing.JLabel lblLoginMode; private javax.swing.JLabel lblP12CertificateLocation; private javax.swing.JLabel lblPEMCertificateLocation; + private javax.swing.JLabel lblPLGRIDUserName; private javax.swing.JLabel lblPassword; private javax.swing.JLabel lblPort; private javax.swing.JLabel lblProxy; @@ -1155,14 +1375,19 @@ public class LoginDialog extends JDialog { private javax.swing.JLabel lblZone; private javax.swing.JLabel lbllBrowserCombo; private javax.swing.JLabel lbllCertCombo; + private javax.swing.JLabel lblplgridpass; + private javax.swing.JPasswordField ldapKeyPassword; private javax.swing.JPasswordField password; + private javax.swing.JPasswordField plgridpass; private javax.swing.JPanel pnlLoginInfo; private javax.swing.JPanel pnlToolbar; private javax.swing.JTextField txtCerts; private javax.swing.JTextField txtHost; private javax.swing.JTextField txtKeyLocation; + private javax.swing.JTextField txtKeyfsLifetime; private javax.swing.JTextField txtP12CertificateLocation; private javax.swing.JTextField txtPEMCertificateLocation; + private javax.swing.JTextField txtPLGRIDUserName; private javax.swing.JTextField txtPort; private javax.swing.JTextField txtProxy; private javax.swing.JTextField txtResource; @@ -1170,13 +1395,13 @@ public class LoginDialog extends JDialog { private javax.swing.JTextField txtZone; // End of variables declaration//GEN-END:variables - private void hideNormalLoginFields(){ + private void hideNormalLoginFields() { password.setVisible(false); lblPassword.setVisible(false); txtUserName.setVisible(false); lblUserName.setVisible(false); } - + private void showAdvancedViewFields() { lblHost.setVisible(true); txtHost.setVisible(true); @@ -1232,6 +1457,7 @@ public class LoginDialog extends JDialog { btnProxyFile.setVisible(true); btnProxyP12.setVisible(true); lblCertMode.setVisible(true); + btnProxyKeyFS.setVisible(true); } private void hideProxyLoginFields() { @@ -1240,13 +1466,14 @@ public class LoginDialog extends JDialog { btnProxyFile.setVisible(false); btnProxyP12.setVisible(false); lblCertMode.setVisible(false); - + btnProxyKeyFS.setVisible(false); hideCertKeyPairFields(); hideCertP12Fields(); hideCertInBrowserFields(); hideProxyFileFields(); - // lblPassword.setVisible(true); - // password.setVisible(true); + hideKeyFSFields(); + // lblPassword.setVisible(true); + // password.setVisible(true); } private void hideCertKeyPairFields() { @@ -1256,8 +1483,8 @@ public class LoginDialog extends JDialog { lblKeyLocation.setVisible(false); txtKeyLocation.setVisible(false); btnKeyLocation.setVisible(false); - lblCertPass.setVisible(false); - certpass.setVisible(false); + lblCertPassPEM.setVisible(false); + certpassPEM.setVisible(false); } private void showCertKeyPairFields() { @@ -1267,24 +1494,24 @@ public class LoginDialog extends JDialog { lblKeyLocation.setVisible(true); txtKeyLocation.setVisible(true); btnKeyLocation.setVisible(true); - lblCertPass.setVisible(true); - certpass.setVisible(true); + lblCertPassPEM.setVisible(true); + certpassPEM.setVisible(true); } private void hideCertP12Fields() { lblP12CertificateLocation.setVisible(false); txtP12CertificateLocation.setVisible(false); btnP12CertificateLocation.setVisible(false); - lblCertPass.setVisible(false); - certpass.setVisible(false); + lblCertPassP12.setVisible(false); + certpassP12.setVisible(false); } private void showCertP12Fields() { lblP12CertificateLocation.setVisible(true); txtP12CertificateLocation.setVisible(true); btnP12CertificateLocation.setVisible(true); - lblCertPass.setVisible(true); - certpass.setVisible(true); + lblCertPassP12.setVisible(true); + certpassP12.setVisible(true); } private void hideCertInBrowserFields() { @@ -1322,6 +1549,28 @@ public class LoginDialog extends JDialog { txtProxy.setVisible(true); btnProxy.setVisible(true); } + + private void hideKeyFSFields() { + ldapKeyPassword.setVisible(false); + lblLdapKeyPass.setVisible(false); + lblPLGRIDUserName.setVisible(false); + txtPLGRIDUserName.setVisible(false); + lblplgridpass.setVisible(false); + plgridpass.setVisible(false); + txtKeyfsLifetime.setVisible(false); + lblKeyfsLifetime.setVisible(false); + } + + private void showKeyFSFields() { + ldapKeyPassword.setVisible(true); + lblLdapKeyPass.setVisible(true); + lblPLGRIDUserName.setVisible(true); + txtPLGRIDUserName.setVisible(true); + lblplgridpass.setVisible(true); + plgridpass.setVisible(true); + txtKeyfsLifetime.setVisible(true); + lblKeyfsLifetime.setVisible(true); + } /* * Set selected the proper radiobutton depending the number of mode * used while reading from properties @@ -1341,6 +1590,10 @@ public class LoginDialog extends JDialog { case PROXY_MODE: btnProxyFile.setSelected(true); break; + case KEYFS_MODE: + btnProxyKeyFS.setSelected(true); + break; + } } @@ -1357,6 +1610,9 @@ public class LoginDialog extends JDialog { if (btnProxyFile.isSelected()) { return PROXY_MODE; } + if (btnProxyKeyFS.isSelected()) { + return KEYFS_MODE; + } return -1; //old option used as default } @@ -1369,6 +1625,8 @@ public class LoginDialog extends JDialog { showCertInBrowserFields(); } else if (btnProxyFile.isSelected()) { showProxyFileFields(); + } else if (btnProxyKeyFS.isSelected()) { + showKeyFSFields(); } } /* @@ -1387,28 +1645,129 @@ public class LoginDialog extends JDialog { } else if (btnProxyCertKeyPair.isSelected()) { String pemCert = txtPEMCertificateLocation.getText(); String pemKey = txtKeyLocation.getText(); - return GssUtil.createCredentialFromCertKeyPassTime(pemCert, pemKey, certpass.getText(), proxyLifetimeSeconds, GSIConstants.GSI_3_IMPERSONATION_PROXY); + return GssUtil.createCredentialFromCertKeyPassTime(pemCert, pemKey, new String(certpassPEM.getPassword()), proxyLifetimeSeconds, GSIConstants.GSI_3_IMPERSONATION_PROXY); } else if (btnProxyP12.isSelected()) { String p12Cert = txtP12CertificateLocation.getText(); //convert p12 to pem pair - String certPath = System.getProperty("user.home") + File.separator + ".idrop" + File.separator + "usercert.pem"; - String keyPath = System.getProperty("user.home") + File.separator + ".idrop" + File.separator + "userkey.pem"; + String certPath = IDROP_HOME + File.separator + "usercert.pem"; + String keyPath = IDROP_HOME + File.separator + "userkey.pem"; try { - CertificateConverter.PKCS12ToPem(p12Cert, certpass.getText()); + CertificateConverter.PKCS12ToPem(p12Cert, certpassP12.getText()); } catch (Exception ex) { log.error("Error during certificate conversion." + ex.getMessage()); } - return GssUtil.createCredentialFromCertKeyPassTime(certPath, keyPath, certpass.getText(), proxyLifetimeSeconds, GSIConstants.GSI_3_IMPERSONATION_PROXY); + return GssUtil.createCredentialFromCertKeyPassTime(certPath, keyPath, new String(certpassP12.getPassword()), proxyLifetimeSeconds, GSIConstants.GSI_3_IMPERSONATION_PROXY); } else if (btnProxyBrowser.isSelected()) { String dn = (String) cmbCertificates.getSelectedItem(); X509Certificate browserCert = getSelectedCertificateFromBrowser(dn); PrivateKey browserKey = getSelectedKeyFromBrowser(dn); String emptyPass = ""; GssUtil.createCredentialFromCertKeyPassTime(browserCert, browserKey, emptyPass, proxyLifetimeSeconds, GSIConstants.GSI_3_IMPERSONATION_PROXY); + } else if (btnProxyKeyFS.isSelected()) { + try { + int hours = 10; + try { + hours = Integer.parseInt(txtKeyfsLifetime.getText()); + } catch (Exception ex) { + } + String proxyFilePath = importCredentialsFromKeyFS(txtPLGRIDUserName.getText(), plgridpass.getText(), ldapKeyPassword.getText(), hours); + if(proxyFilePath == null){ + return null; + } + GlobusCredential globusCred = new GlobusCredential(proxyFilePath); + return new GlobusGSSCredentialImpl(globusCred, GSSCredential.INITIATE_AND_ACCEPT); + } catch (IOException ex) { + log.error("Importing and using proxy from keyFS failed", ex); + } } return null; } /* + * KeyFS + */ + + private String importCredentialsFromKeyFS(String username, String password, String keyPasword, int hours) throws IOException { + log.info("Importing proxy from keyFS"); + + String result = null; + String host = "ui.plgrid.wcss.wroc.pl"; + String remotePathPrefix = "/mnt/keyfs/users/"; + String remotePathPostfix = "/.globus/"; + String remoteUserHome = "/home/grid/users/" + username + "/"; + String certName = remotePathPrefix + username + remotePathPostfix + "usercert.pem"; + String keyName = remotePathPrefix + username + remotePathPostfix + "userkey.pem"; + String proxyFileName = "proxy"; + String outName = remoteUserHome + proxyFileName; + String userHomeDir = IDROP_HOME; + + JSch jsch = new JSch(); + String keypass = keyPasword; + if (keypass == null) { + keypass = password; + } + String command = "echo " + keypass + " | grid-proxy-init -valid " + hours + ":0 -cert " + certName + " -key " + keyName + " -out " + outName + " -pwstdin"; + + try { + java.util.Properties config = new java.util.Properties(); + config.put("StrictHostKeyChecking", "no"); + com.jcraft.jsch.Session session = jsch.getSession(username, host); + session.setPassword(password); + session.setConfig(config); + session.connect(); + + Channel channel = session.openChannel("exec"); + ((ChannelExec) channel).setCommand(command); + channel.connect(); + + byte[] tmp = new byte[1024]; + InputStream in = channel.getInputStream(); + channel.connect(); + + int count = 0; + while (true) { + count++; + if (count > 60) { + break; + } + while (in.available() > 0) { + int i = in.read(tmp, 0, 1024); + if (i < 0) { + break; + } + // System.out.print(new String(tmp, 0, i)); + } + if (channel.isClosed()) { + log.info("exit-status: " + channel.getExitStatus()); + break; + } + try { + Thread.sleep(1000); + } catch (Exception ee) { + } + } + if (channel.getExitStatus() != 0) { + return null; + } + channel.disconnect(); + + Channel channel2 = session.openChannel("sftp"); + channel2.connect(); + ChannelSftp c = (ChannelSftp) channel2; +// wyrzucac proxy z srwera po sciagnieciu + c.get(outName, userHomeDir); + result = IDROP_HOME + "/" + proxyFileName; + channel2.disconnect(); + session.disconnect(); + + } catch (SftpException ex) { + log.error("SFTP failed", ex); + } catch (JSchException ex) { + log.error("JSch session start failed", ex); + } + return result; + } + + /* * WARNING: * - partly untested code below * - code based on correct function actionPerformed from CertificateManager.java in Certman project @@ -1418,7 +1777,6 @@ public class LoginDialog extends JDialog { * * It is necessary due to he fact, that this jar is unreachable in main maven repo */ - private void fillBrowserComboBox() { cmbBrowsers.removeAllItems(); String[] browsers = getBrowsersList(); diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/CertificateConverter.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/CertificateConverter.java index 4d2d447..4c194b8 100644 --- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/CertificateConverter.java +++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/CertificateConverter.java @@ -57,7 +57,9 @@ public class CertificateConverter { File keyFile = initializeCredentialFile("userkey.pem"); FileWriter keyWriter = new FileWriter(keyFile); PEMWriter pemKeyWriter = new PEMWriter(keyWriter); - Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); + if(Security.getProvider("BC") == null){ + Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); + } pemKeyWriter.writeObject(key, "DESEDE", password, new SecureRandom());//to sypie pemKeyWriter.close(); keyWriter.close(); diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/ZipFileExtractor.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/ZipFileExtractor.java new file mode 100644 index 0000000..1fb7554 --- /dev/null +++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/ZipFileExtractor.java @@ -0,0 +1,111 @@ +package org.irods.jargon.idrop.desktop.systraygui.gss; + +import java.io.*; +import java.util.Enumeration; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; +import org.slf4j.LoggerFactory; + +/* + * Class based on certMan, used to extract cerificates. + */ +public class ZipFileExtractor { + + public static org.slf4j.Logger log = LoggerFactory.getLogger(ZipFileExtractor.class); + + public static void unzipFile(String zipFileName, + String zipFileDest) throws IOException { + log.info("Unzipping " + zipFileName + " to " + zipFileDest + " with this class loader"); + ClassLoader classLoader = ZipFileExtractor.class.getClassLoader(); + unzipFile(classLoader, zipFileName, zipFileDest); + } + + public static void unzipFile(ClassLoader classLoader, + String zipFileName, + String zipFileDest) throws IOException { + // Unzip with our class loader + extractZipFile(classLoader, zipFileName, zipFileDest); + // Unzip the file + unzip(zipFileDest); + } + + public static void extractZipFile(String zipFileName, + String zipFileDest) throws IOException { + log.info("Extracting " + zipFileName + " to " + zipFileDest + " with this class loader"); + ClassLoader classLoader = ZipFileExtractor.class.getClassLoader(); + extractZipFile(classLoader, zipFileName, zipFileDest); + } + + public static void extractZipFile(ClassLoader classLoader, + String zipFileName, + String zipFileDest) throws IOException { + + log.info("Extracting " + zipFileName + " from class loader to " + zipFileDest); + + try { + log.info("Getting input stream for " + zipFileName); + InputStream inputStream = classLoader.getResourceAsStream(zipFileName); + if (inputStream == null) { + throw new IOException("Unable to get input stream for " + zipFileName + " from class loader!"); + } + log.info("Creating file output stream for " + zipFileDest); + OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(zipFileDest)); + log.info("Output stream created."); + byte[] buffer = new byte[2048]; + for (;;) { + int nBytes = inputStream.read(buffer); + if (nBytes <= 0) { + break; + } + outputStream.write(buffer, 0, nBytes); + } + outputStream.flush(); + outputStream.close(); + inputStream.close(); + log.info(zipFileName + " has been unloaded to " + zipFileDest); + } catch (IOException e) { + log.error("Failed to extract " + zipFileName + " to " + zipFileDest); + e.printStackTrace(); + throw e; + } + } + + public static void unzip(String path) { + Enumeration entries; + ZipFile zipFile; + String dir = new File(path).getParent(); + + try { + zipFile = new ZipFile(path); + entries = zipFile.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = (ZipEntry) entries.nextElement(); + String entryDest = dir + File.separator + entry.getName(); + if (entry.isDirectory()) { + // Assume directories are stored parents first then children. + log.error("Extracting directory: " + entry.getName()); + // This is not robust, just for demonstration purposes. + (new File(entryDest)).mkdir(); + } else { + log.error("Extracting file: " + entry.getName()); + copyInputStream(zipFile.getInputStream(entry), + new BufferedOutputStream(new FileOutputStream(entryDest))); + } + } + zipFile.close(); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + } + + public static void copyInputStream(InputStream in, OutputStream out) + throws IOException { + byte[] buffer = new byte[1024]; + int len; + while ((len = in.read(buffer)) >= 0) { + out.write(buffer, 0, len); + } + in.close(); + out.close(); + } +}
\ No newline at end of file diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/services/IdropConfigurationService.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/services/IdropConfigurationService.java index a9e49f9..677654d 100644 --- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/services/IdropConfigurationService.java +++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/services/IdropConfigurationService.java @@ -44,8 +44,12 @@ public interface IdropConfigurationService { public static final String ACCOUNT_CACHE_CERT_PEM_LOCATION = "irods.account.gsi.cert.pem.location"; public static final String ACCOUNT_CACHE_KEY_PEM_LOCATION = "irods.account.gsi.key.pem.location"; public static final String ACCOUNT_CACHE_CERT_P12_LOCATION = "irods.account.gsi.cert.p12.location"; - public static final String ACCOUNT_CACHE_CERT_PASSWORD = "irods.account.gsi.cert.password"; - public static final String ACCOUNT_CACHE_CERT_LOGIN_MODE = "irods.account.gsi.cert.login.mode"; + public static final String ACCOUNT_CACHE_CERT_P12_PASSWORD = "irods.account.gsi.cert.p12.password"; + public static final String ACCOUNT_CACHE_CERT_PEM_PASSWORD = "irods.account.gsi.cert.pem.password"; + public static final String ACCOUNT_CACHE_CERT_LOGIN_MODE = "irods.account.gsi.cert.login.mode"; + public static final String ACCOUNT_CACHE_PLGRID_USERNAME = "irods.account.gsi.plgrid.username"; + public static final String ACCOUNT_CACHE_PLGRID_PASSWORD = "irods.account.gsi.plgrid.password"; + public static final String ACCOUNT_CACHE_PLGRID_KEY_PASSWORD = "irods.account.gsi.plgrid.key.password"; // /for GSI public static final String POLICY_AWARE_PROPERTY = "policy.aware"; public static final String LOOK_AND_FEEL = "idrop.lookandfeel"; @@ -71,7 +75,7 @@ public interface IdropConfigurationService { public static final String IRODS_CONNECTION_RESTART = "transfer.reconnect"; public static final String IDROP_ENABLE_RESC_EDIT = "idrop.settings.enable_default_resc_edit"; public static final String IDROP_PUBLIC_LINK_SERVICE = "idrop.public.link.service.url"; - + Properties bootstrapConfigurationAndMergePropertiesFromLocalAndClasspath() throws IdropException; diff --git a/idrop-swing/src/main/resources/certificates.zip b/idrop-swing/src/main/resources/certificates.zip Binary files differnew file mode 100644 index 0000000..cb7d4c5 --- /dev/null +++ b/idrop-swing/src/main/resources/certificates.zip |