summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalina Jasinska <kalina.jasinska@gmail.com>2013-08-29 12:39:38 (GMT)
committer Kalina Jasinska <kalina.jasinska@gmail.com>2013-08-29 12:39:38 (GMT)
commitc36197a9ec7cc468ed0b56078278c6422439f193 (patch)
tree7981a8295f7b1f412e736d4f59b95341ef9000b4
parent0c8bc2e9012d3a8ad84c68e36229d5de20503b03 (diff)
downloadQCG-Data-gsisupport.zip
QCG-Data-gsisupport.tar.gz
QCG-Data-gsisupport.tar.bz2
p12,pem and browser supportgsisupport
-rw-r--r--idrop-swing/lib/libbrowser.jarbin0 -> 72048 bytes
-rw-r--r--idrop-swing/pom.xml5
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/LoginDialog.form299
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/LoginDialog.java828
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/CertificateConverter.java103
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/GssSecurityException.java27
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/GssUtil.java597
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/services/IdropConfigurationService.java4
8 files changed, 1791 insertions, 72 deletions
diff --git a/idrop-swing/lib/libbrowser.jar b/idrop-swing/lib/libbrowser.jar
new file mode 100644
index 0000000..dc7211c
--- /dev/null
+++ b/idrop-swing/lib/libbrowser.jar
Binary files differ
diff --git a/idrop-swing/pom.xml b/idrop-swing/pom.xml
index 1177cd5..a73df5e 100644
--- a/idrop-swing/pom.xml
+++ b/idrop-swing/pom.xml
@@ -97,6 +97,11 @@
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.10</version>
</dependency>
+ <dependency>
+ <groupId>vine_certman</groupId>
+ <artifactId>libbrowser</artifactId>
+ <version>1</version>
+ </dependency>
</dependencies>
<build>
<plugins>
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 e764320..5f8df5f 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
@@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <NonVisualComponents>
+ <Component class="javax.swing.ButtonGroup" name="btngrpProxySource">
+ </Component>
+ </NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
@@ -18,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,96,0,0,3,9"/>
+ <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"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
@@ -178,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="10" 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="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"/>
</Constraint>
</Constraints>
@@ -218,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="9" 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>
@@ -234,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="9" 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="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"/>
</Constraint>
</Constraints>
</Component>
@@ -244,14 +248,14 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="7" 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="9" 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="txtProxy">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="1" gridY="7" 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="9" 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>
@@ -261,14 +265,14 @@
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="0" gridY="8" 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="11" 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="txtCerts">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="1" gridY="8" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
+ <GridBagConstraints gridX="1" gridY="11" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
</Constraint>
</Constraints>
</Component>
@@ -281,7 +285,7 @@
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
- <GridBagConstraints gridX="2" gridY="7" 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="9" 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>
@@ -294,10 +298,287 @@
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="2" gridY="11" 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="lblCertMpde">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Certificate mode:"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="13" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Container class="javax.swing.JPanel" name="jPanel2">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="-1" gridY="-1" 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>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JRadioButton" name="btnProxyCertKeyPair">
+ <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="cert/key pair"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnProxyCertKeyPairActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JRadioButton" name="btnProxyP12">
+ <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="p12 certificate"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnProxyP12ActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JRadioButton" name="btnProxyBrowser">
+ <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="certificate in browser"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnProxyBrowserActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JRadioButton" name="btnProxyFile">
+ <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="proxy file"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnProxyFileActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="javax.swing.JTextField" name="txtKeyLocation">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="10" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="21" weightX="0.0" weightY="0.0"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblKeyLocation">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Key location:"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="10" 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.JButton" name="btnKeyLocation">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Choose..."/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnKeyLocationActionPerformed"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="2" gridY="10" 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="lblP12CertificateLocation">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="P12 Certificate location:"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="7" 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="txtP12CertificateLocation">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="7" 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>
+ <Component class="javax.swing.JButton" name="btnP12CertificateLocation">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Choose..."/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnP12CertificateLocationActionPerformed"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="2" gridY="7" 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="lblCertPass">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Certificate 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="12" 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="certpass">
+ <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="12" 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="lblPEMCertificateLocation">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="PEM Certificate location:"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="0" gridY="8" 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="txtPEMCertificateLocation">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
+ <GridBagConstraints gridX="1" gridY="8" 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>
+ <Component class="javax.swing.JButton" name="btnPEMCertificateLocation">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Choose..."/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPEMCertificateLocationActionPerformed"/>
+ </Events>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="2" gridY="8" 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="lbllBrowserCombo">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Selected browser:"/>
+ </Properties>
+ <AccessibilityProperties>
+ <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="Selected browser:"/>
+ </AccessibilityProperties>
+ <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="browserpass">
+ <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="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"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lblBrowserPass">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Browser 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="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>
+ <Component class="javax.swing.JComboBox" name="cmbBrowsers">
+ <Properties>
+ <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+ <StringArray count="4">
+ <StringItem index="0" value="Item 1"/>
+ <StringItem index="1" value="Item 2"/>
+ <StringItem index="2" value="Item 3"/>
+ <StringItem index="3" value="Item 4"/>
+ </StringArray>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmbBrowsersActionPerformed"/>
+ </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"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lbllCertCombo">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Selected certificate:"/>
+ </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"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JComboBox" name="cmbCertificates">
+ <Properties>
+ <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
+ <StringArray count="4">
+ <StringItem index="0" value="Item 1"/>
+ <StringItem index="1" value="Item 2"/>
+ <StringItem index="2" value="Item 3"/>
+ <StringItem index="3" value="Item 4"/>
+ </StringArray>
+ </Property>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmbCertificatesActionPerformed"/>
+ </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"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Component class="javax.swing.JButton" name="btnCheckCertsInBrowser">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Access..."/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCheckCertsInBrowserActionPerformed"/>
+ </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"/>
+ </Constraint>
+ </Constraints>
+ </Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="pnlToolbar">
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 0ab3cf4..6c25374 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
@@ -2,6 +2,15 @@ package org.irods.jargon.idrop.desktop.systraygui;
import java.awt.Color;
import java.awt.event.ActionEvent;
+import java.io.File;
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -11,9 +20,11 @@ import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.KeyStroke;
+import org.globus.gsi.GSIConstants;
import org.globus.gsi.GlobusCredential;
import org.globus.gsi.GlobusCredentialException;
import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
+
import org.ietf.jgss.GSSCredential;
import org.ietf.jgss.GSSException;
import org.irods.jargon.core.connection.GSIIRODSAccount;
@@ -22,12 +33,15 @@ import org.irods.jargon.core.connection.IRODSAccount;
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.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.openide.util.Exceptions;
import org.slf4j.LoggerFactory;
+import uk.ac.rl.esc.browser.Browser;
/**
*
@@ -40,6 +54,12 @@ public class LoginDialog extends JDialog {
public static org.slf4j.Logger log = LoggerFactory
.getLogger(LoginDialog.class);
+ // Indexes of gsi modes used in properties to store users choice
+ static final int PEM_MODE = 1;
+ static final int P12_MODE = 2;
+ static final int BROWSER_MODE = 3;
+ static final int PROXY_MODE = 4;
+
public LoginDialog(final JDialog parentDialog, final IDROPCore idropCore) {
super(parentDialog, true);
if (idropCore == null) {
@@ -92,6 +112,30 @@ public class LoginDialog extends JDialog {
txtCerts.setText(certificates);
}
+ // Read paths from propeties: PEM certificate, PEM key, p12 certificate
+ String pemcert = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_CERT_PEM_LOCATION);
+ if(pemcert!=null){
+ txtPEMCertificateLocation.setText(pemcert);
+
+ }
+ String p12cert = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_CERT_P12_LOCATION);
+ if(p12cert!=null){
+ txtP12CertificateLocation.setText(p12cert);
+ }
+
+ String keyLoc = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_KEY_PEM_LOCATION);
+ if(keyLoc!=null){
+ txtKeyLocation.setText(keyLoc);
+ }
+ // Read gsi mode from properties (p12, PEM, browser, proxy file)
+ String certMode = idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.ACCOUNT_CACHE_CERT_LOGIN_MODE);
+ try{
+ int certModeNum = Integer.parseInt(certMode);
+ setSelectedModeFields(certModeNum);
+ }catch(Exception ex){
+ Logger.getLogger(LoginDialog.class.getName()).log(Level.WARNING,null, ex);
+ }
+ //
txtPort.setText(port);
String zone = idropCore.getIdropConfig().getPropertyForKey(
IdropConfigurationService.ACCOUNT_CACHE_ZONE);
@@ -197,9 +241,10 @@ public class LoginDialog extends JDialog {
irodsAccount = IRODSAccount.instanceForAnonymous(
presetHost, presetPort, "", presetZone,
presetResource);
- } else if(chkProxyLogin.isSelected()){
- GlobusCredential globusCred = new GlobusCredential(txtProxy.getText());
- GSSCredential gssCred = new GlobusGSSCredentialImpl(globusCred,GSSCredential.INITIATE_AND_ACCEPT);
+ } else if(chkProxyLogin.isSelected()){
+
+ GSSCredential gssCred =getGssCredential();
+
GSIIRODSAccount acc = GSIIRODSAccount.instance(presetHost, presetPort, gssCred, presetResource);
acc.setCertificateAuthority(txtCerts.getText());
irodsAccount = acc;
@@ -222,8 +267,9 @@ public class LoginDialog extends JDialog {
txtResource.getText().trim());
} else if(chkProxyLogin.isSelected()){
// TODO
- GlobusCredential globusCred = new GlobusCredential(txtProxy.getText());
- GSSCredential gssCred = new GlobusGSSCredentialImpl(globusCred, GSSCredential.INITIATE_AND_ACCEPT);
+ GSSCredential gssCred = getGssCredential();
+
+
GSIIRODSAccount acc = GSIIRODSAccount.instance(
txtHost.getText().trim(),
Integer.parseInt(txtPort.getText().trim()), gssCred, txtResource.getText().trim());
@@ -254,6 +300,12 @@ 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);
+ MessageManager.showError(this,
+ "Wrong certifcate, key, password or proxy.",
+ "Login Error");
+ return true;
}
if (comboLoginMode.getSelectedItem().toString()
@@ -279,6 +331,11 @@ public class LoginDialog extends JDialog {
.saveLogin(irodsAccount);
idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_PROXY_LOCATION, txtProxy.getText());
idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.ACCOUNT_CACHE_CERTIFICATES_LOCATION, txtCerts.getText());
+ // Save in properties: paths to certificates, key and gsi mode
+ 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_CERT_LOGIN_MODE, ""+getSelectedModeFieldNum());
//todo save proxy path and certificates location
} catch (IdropException ex) {
throw new IdropRuntimeException("error saving irodsAccount", ex);
@@ -361,6 +418,7 @@ public class LoginDialog extends JDialog {
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
+ btngrpProxySource = new javax.swing.ButtonGroup();
pnlLoginInfo = new javax.swing.JPanel();
lblHost = new javax.swing.JLabel();
txtHost = new javax.swing.JTextField();
@@ -386,6 +444,30 @@ public class LoginDialog extends JDialog {
txtCerts = new javax.swing.JTextField();
btnProxy = new javax.swing.JButton();
btnCerts = new javax.swing.JButton();
+ lblCertMpde = new javax.swing.JLabel();
+ jPanel2 = new javax.swing.JPanel();
+ btnProxyCertKeyPair = new javax.swing.JRadioButton();
+ btnProxyP12 = new javax.swing.JRadioButton();
+ btnProxyBrowser = new javax.swing.JRadioButton();
+ btnProxyFile = 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();
+ lblPEMCertificateLocation = new javax.swing.JLabel();
+ txtPEMCertificateLocation = new javax.swing.JTextField();
+ btnPEMCertificateLocation = new javax.swing.JButton();
+ lbllBrowserCombo = new javax.swing.JLabel();
+ browserpass = new javax.swing.JPasswordField();
+ lblBrowserPass = new javax.swing.JLabel();
+ cmbBrowsers = new javax.swing.JComboBox();
+ lbllCertCombo = new javax.swing.JLabel();
+ cmbCertificates = new javax.swing.JComboBox();
+ btnCheckCertsInBrowser = new javax.swing.JButton();
pnlToolbar = new javax.swing.JPanel();
btnOK = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
@@ -521,14 +603,14 @@ public class LoginDialog extends JDialog {
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 10;
+ gridBagConstraints.gridy = 17;
pnlLoginInfo.add(jPanel1, gridBagConstraints);
lblLoginMode.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
lblLoginMode.setText("Login Mode:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 9;
+ gridBagConstraints.gridy = 16;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
pnlLoginInfo.add(lblLoginMode, gridBagConstraints);
@@ -536,31 +618,31 @@ public class LoginDialog extends JDialog {
comboLoginMode.setToolTipText("Authentication mode used at login");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 9;
+ gridBagConstraints.gridy = 16;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
pnlLoginInfo.add(comboLoginMode, gridBagConstraints);
lblProxy.setText("Proxy location:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 7;
+ gridBagConstraints.gridy = 9;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
pnlLoginInfo.add(lblProxy, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 7;
+ gridBagConstraints.gridy = 9;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
pnlLoginInfo.add(txtProxy, gridBagConstraints);
lblCerts.setText("Certificates location:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 8;
+ gridBagConstraints.gridy = 11;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
pnlLoginInfo.add(lblCerts, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 8;
+ gridBagConstraints.gridy = 11;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
pnlLoginInfo.add(txtCerts, gridBagConstraints);
@@ -573,7 +655,7 @@ public class LoginDialog extends JDialog {
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
- gridBagConstraints.gridy = 7;
+ gridBagConstraints.gridy = 9;
pnlLoginInfo.add(btnProxy, gridBagConstraints);
btnCerts.setText("Choose...");
@@ -584,9 +666,204 @@ public class LoginDialog extends JDialog {
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
- gridBagConstraints.gridy = 8;
+ gridBagConstraints.gridy = 11;
pnlLoginInfo.add(btnCerts, gridBagConstraints);
+ lblCertMpde.setText("Certificate mode:");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
+ pnlLoginInfo.add(lblCertMpde, gridBagConstraints);
+
+ btngrpProxySource.add(btnProxyCertKeyPair);
+ btnProxyCertKeyPair.setText("cert/key pair");
+ btnProxyCertKeyPair.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnProxyCertKeyPairActionPerformed(evt);
+ }
+ });
+ jPanel2.add(btnProxyCertKeyPair);
+
+ btngrpProxySource.add(btnProxyP12);
+ btnProxyP12.setText("p12 certificate");
+ btnProxyP12.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnProxyP12ActionPerformed(evt);
+ }
+ });
+ jPanel2.add(btnProxyP12);
+
+ btngrpProxySource.add(btnProxyBrowser);
+ btnProxyBrowser.setText("certificate in browser");
+ btnProxyBrowser.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnProxyBrowserActionPerformed(evt);
+ }
+ });
+ jPanel2.add(btnProxyBrowser);
+
+ btngrpProxySource.add(btnProxyFile);
+ btnProxyFile.setText("proxy file");
+ btnProxyFile.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnProxyFileActionPerformed(evt);
+ }
+ });
+ jPanel2.add(btnProxyFile);
+
+ pnlLoginInfo.add(jPanel2, new java.awt.GridBagConstraints());
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 10;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
+ pnlLoginInfo.add(txtKeyLocation, gridBagConstraints);
+
+ lblKeyLocation.setText("Key location:");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 10;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
+ pnlLoginInfo.add(lblKeyLocation, gridBagConstraints);
+
+ btnKeyLocation.setText("Choose...");
+ btnKeyLocation.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnKeyLocationActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 10;
+ pnlLoginInfo.add(btnKeyLocation, gridBagConstraints);
+
+ lblP12CertificateLocation.setText("P12 Certificate location:");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 7;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
+ pnlLoginInfo.add(lblP12CertificateLocation, gridBagConstraints);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 7;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ pnlLoginInfo.add(txtP12CertificateLocation, gridBagConstraints);
+
+ btnP12CertificateLocation.setText("Choose...");
+ btnP12CertificateLocation.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnP12CertificateLocationActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 7;
+ pnlLoginInfo.add(btnP12CertificateLocation, gridBagConstraints);
+
+ lblCertPass.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);
+
+ certpass.setColumns(30);
+ certpass.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);
+
+ lblPEMCertificateLocation.setText("PEM Certificate location:");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 8;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
+ pnlLoginInfo.add(lblPEMCertificateLocation, gridBagConstraints);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 8;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ pnlLoginInfo.add(txtPEMCertificateLocation, gridBagConstraints);
+
+ btnPEMCertificateLocation.setText("Choose...");
+ btnPEMCertificateLocation.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnPEMCertificateLocationActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 8;
+ pnlLoginInfo.add(btnPEMCertificateLocation, gridBagConstraints);
+
+ lbllBrowserCombo.setText("Selected browser:");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 13;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
+ pnlLoginInfo.add(lbllBrowserCombo, gridBagConstraints);
+ lbllBrowserCombo.getAccessibleContext().setAccessibleName("Selected browser:");
+
+ browserpass.setColumns(30);
+ browserpass.setPreferredSize(null);
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 14;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ pnlLoginInfo.add(browserpass, gridBagConstraints);
+
+ lblBrowserPass.setText("Browser password:");
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 14;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_END;
+ pnlLoginInfo.add(lblBrowserPass, gridBagConstraints);
+
+ cmbBrowsers.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
+ cmbBrowsers.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cmbBrowsersActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 13;
+ 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.anchor = java.awt.GridBagConstraints.LINE_END;
+ pnlLoginInfo.add(lbllCertCombo, gridBagConstraints);
+
+ cmbCertificates.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
+ cmbCertificates.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ cmbCertificatesActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 15;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ pnlLoginInfo.add(cmbCertificates, gridBagConstraints);
+
+ btnCheckCertsInBrowser.setText("Access...");
+ btnCheckCertsInBrowser.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnCheckCertsInBrowserActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 14;
+ pnlLoginInfo.add(btnCheckCertsInBrowser, gridBagConstraints);
+
getContentPane().add(pnlLoginInfo, java.awt.BorderLayout.CENTER);
pnlToolbar.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 2, 5));
@@ -624,7 +901,9 @@ public class LoginDialog extends JDialog {
chkGuestLogin.setSelected(false);
//hide username/pass
hideForGuestLogin();
- showProxyLoginFields();
+ showProxyLoginFields();
+ //Shows proper fields for choosen gsi mode (p12/pem/browser/proxy file)
+ showProxyChoosenModeFields();
}else{
//show username/password
showWhenGuestLogin();
@@ -653,6 +932,83 @@ public class LoginDialog extends JDialog {
}
}//GEN-LAST:event_btnCertsActionPerformed
+ private void btnKeyLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnKeyLocationActionPerformed
+ //get path of key file when using PEM pair to authenticate user
+ final JFileChooser chooser = new JFileChooser();
+ int res = chooser.showOpenDialog(this);
+ if(res == JFileChooser.APPROVE_OPTION){
+ txtKeyLocation.setText(chooser.getSelectedFile().getAbsolutePath());
+ }
+ }//GEN-LAST:event_btnKeyLocationActionPerformed
+
+ private void btnP12CertificateLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnP12CertificateLocationActionPerformed
+ //get path of certificate file when using p12 certificate to authenticate user
+ final JFileChooser chooser = new JFileChooser();
+ int res = chooser.showOpenDialog(this);
+ if(res == JFileChooser.APPROVE_OPTION){
+ txtP12CertificateLocation.setText(chooser.getSelectedFile().getAbsolutePath());
+ }
+ }//GEN-LAST:event_btnP12CertificateLocationActionPerformed
+
+ private void btnProxyCertKeyPairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProxyCertKeyPairActionPerformed
+// show proper fields when using PEM pair to authenticate user
+ hideCertP12Fields();
+ hideCertInBrowserFields();
+ hideProxyFileFields();
+ showCertKeyPairFields();
+ }//GEN-LAST:event_btnProxyCertKeyPairActionPerformed
+
+ private void btnProxyP12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProxyP12ActionPerformed
+// show proper fields when using p12 certificate to authenticate user
+ hideCertKeyPairFields();
+ hideCertInBrowserFields();
+ hideProxyFileFields();
+ showCertP12Fields();
+ }//GEN-LAST:event_btnProxyP12ActionPerformed
+
+ private void btnProxyBrowserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProxyBrowserActionPerformed
+// show proper fields when using credentials from browser to authenticate user
+ hideCertKeyPairFields();
+ hideCertP12Fields();
+ hideProxyFileFields();
+ showCertInBrowserFields();
+ fillBrowserComboBox();
+ }//GEN-LAST:event_btnProxyBrowserActionPerformed
+
+ private void btnProxyFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProxyFileActionPerformed
+// show proper fields when using proxy file to authenticate user
+ hideCertKeyPairFields();
+ hideCertP12Fields();
+ hideCertInBrowserFields();
+ showProxyFileFields();
+ }//GEN-LAST:event_btnProxyFileActionPerformed
+
+ private void btnPEMCertificateLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPEMCertificateLocationActionPerformed
+ //get path of certificate file when using PEM pair to authenticate user
+ final JFileChooser chooser = new JFileChooser();
+ int res = chooser.showOpenDialog(this);
+ if(res == JFileChooser.APPROVE_OPTION){
+ txtPEMCertificateLocation.setText(chooser.getSelectedFile().getAbsolutePath());
+ }
+ }//GEN-LAST:event_btnPEMCertificateLocationActionPerformed
+
+ private void cmbBrowsersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbBrowsersActionPerformed
+
+ }//GEN-LAST:event_cmbBrowsersActionPerformed
+
+ private void cmbCertificatesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbCertificatesActionPerformed
+
+ }//GEN-LAST:event_cmbCertificatesActionPerformed
+
+ private void btnCheckCertsInBrowserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheckCertsInBrowserActionPerformed
+ //fill proper combobox with certificates' list derived from selected browser
+ String choosenBrowser = (String)cmbBrowsers.getSelectedItem();
+ if(choosenBrowser != null){
+ setSelectedBrowser(choosenBrowser);
+ fillCertificateComboBox();
+ }
+ }//GEN-LAST:event_btnCheckCertsInBrowserActionPerformed
+
private void chkAdvancedLoginActionPerformed(
final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_chkAdvancedLoginActionPerformed
// TODO add your handling code here:
@@ -683,30 +1039,55 @@ public class LoginDialog extends JDialog {
dispose();
}// GEN-LAST:event_btnCancelActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JPasswordField browserpass;
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnCerts;
+ private javax.swing.JButton btnCheckCertsInBrowser;
+ private javax.swing.JButton btnKeyLocation;
private javax.swing.JButton btnOK;
+ private javax.swing.JButton btnP12CertificateLocation;
+ private javax.swing.JButton btnPEMCertificateLocation;
private javax.swing.JButton btnProxy;
+ private javax.swing.JRadioButton btnProxyBrowser;
+ private javax.swing.JRadioButton btnProxyCertKeyPair;
+ private javax.swing.JRadioButton btnProxyFile;
+ private javax.swing.JRadioButton btnProxyP12;
+ private javax.swing.ButtonGroup btngrpProxySource;
+ private javax.swing.JPasswordField certpass;
private javax.swing.JCheckBox chkAdvancedLogin;
private javax.swing.JCheckBox chkGuestLogin;
private javax.swing.JCheckBox chkProxyLogin;
+ private javax.swing.JComboBox cmbBrowsers;
+ private javax.swing.JComboBox cmbCertificates;
private javax.swing.JComboBox comboLoginMode;
private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JLabel lblBrowserPass;
+ private javax.swing.JLabel lblCertMpde;
+ private javax.swing.JLabel lblCertPass;
private javax.swing.JLabel lblCerts;
private javax.swing.JLabel lblHost;
+ private javax.swing.JLabel lblKeyLocation;
private javax.swing.JLabel lblLogin;
private javax.swing.JLabel lblLoginMode;
+ private javax.swing.JLabel lblP12CertificateLocation;
+ private javax.swing.JLabel lblPEMCertificateLocation;
private javax.swing.JLabel lblPassword;
private javax.swing.JLabel lblPort;
private javax.swing.JLabel lblProxy;
private javax.swing.JLabel lblResource;
private javax.swing.JLabel lblUserName;
private javax.swing.JLabel lblZone;
+ private javax.swing.JLabel lbllBrowserCombo;
+ private javax.swing.JLabel lbllCertCombo;
private javax.swing.JPasswordField password;
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 txtP12CertificateLocation;
+ private javax.swing.JTextField txtPEMCertificateLocation;
private javax.swing.JTextField txtPort;
private javax.swing.JTextField txtProxy;
private javax.swing.JTextField txtResource;
@@ -714,54 +1095,375 @@ public class LoginDialog extends JDialog {
private javax.swing.JTextField txtZone;
// End of variables declaration//GEN-END:variables
- private void showAdvancedViewFields() {
- txtResource.setVisible(true);
- txtPort.setVisible(true);
- lblPort.setVisible(true);
- lblResource.setVisible(true);
- }
-
- private void hideAdvancedViewFields() {
- txtResource.setVisible(false);
- txtPort.setVisible(false);
- lblPort.setVisible(false);
- lblResource.setVisible(false);
- }
-
- private void hideForGuestLogin() {
- lblUserName.setVisible(false);
- txtUserName.setVisible(false);
- lblPassword.setVisible(false);
- password.setVisible(false);
- lblLoginMode.setVisible(false);
- comboLoginMode.setVisible(false);
- }
-
- private void showWhenGuestLogin() {
- lblUserName.setVisible(true);
- txtUserName.setVisible(true);
- lblPassword.setVisible(true);
- password.setVisible(true);
- }
+ private void showAdvancedViewFields() {
+ txtResource.setVisible(true);
+ txtPort.setVisible(true);
+ lblPort.setVisible(true);
+ lblResource.setVisible(true);
+ //show advanced option
+ lblCerts.setVisible(true);
+ txtCerts.setVisible(true);
+ btnCerts.setVisible(true);
+ }
+
+ private void hideAdvancedViewFields() {
+ txtResource.setVisible(false);
+ txtPort.setVisible(false);
+ lblPort.setVisible(false);
+ lblResource.setVisible(false);
+ //hide advanced option
+ lblCerts.setVisible(false);
+ txtCerts.setVisible(false);
+ btnCerts.setVisible(false);
+ }
+
+ private void hideForGuestLogin() {
+ lblUserName.setVisible(false);
+ txtUserName.setVisible(false);
+ lblPassword.setVisible(false);
+ password.setVisible(false);
+ lblLoginMode.setVisible(false);
+ comboLoginMode.setVisible(false);
+ }
+
+ private void showWhenGuestLogin() {
+ lblUserName.setVisible(true);
+ txtUserName.setVisible(true);
+ lblPassword.setVisible(true);
+ password.setVisible(true);
+ }
+
+ private void showProxyLoginFields(){
+ //show buttngroup to let user choose a way to authenticate
+ btnProxyBrowser.setVisible(true);
+ btnProxyCertKeyPair.setVisible(true);
+ btnProxyFile.setVisible(true);
+ btnProxyP12.setVisible(true);
+ lblCertMpde.setVisible(true);
+ }
+
+ private void hideProxyLoginFields(){
+ btnProxyBrowser.setVisible(false);
+ btnProxyCertKeyPair.setVisible(false);
+ btnProxyFile.setVisible(false);
+ btnProxyP12.setVisible(false);
+ lblCertMpde.setVisible(false);
+
+ hideCertKeyPairFields();
+ hideCertP12Fields();
+ hideCertInBrowserFields();
+ hideProxyFileFields();
- private void showProxyLoginFields(){
- lblProxy.setVisible(true);
- txtProxy.setVisible(true);
- btnProxy.setVisible(true);
- lblCerts.setVisible(true);
- txtCerts.setVisible(true);
- btnCerts.setVisible(true);
+ lblPassword.setVisible(true);
+ password.setVisible(true);
+ }
+ private void hideCertKeyPairFields(){
+ lblPEMCertificateLocation.setVisible(false);
+ txtPEMCertificateLocation.setVisible(false);
+ btnPEMCertificateLocation.setVisible(false);
+ lblKeyLocation.setVisible(false);
+ txtKeyLocation.setVisible(false);
+ btnKeyLocation.setVisible(false);
+ lblCertPass.setVisible(false);
+ certpass.setVisible(false);
+ }
+ private void showCertKeyPairFields(){
+ lblPEMCertificateLocation.setVisible(true);
+ txtPEMCertificateLocation.setVisible(true);
+ btnPEMCertificateLocation.setVisible(true);
+ lblKeyLocation.setVisible(true);
+ txtKeyLocation.setVisible(true);
+ btnKeyLocation.setVisible(true);
+ lblCertPass.setVisible(true);
+ certpass.setVisible(true);
+ }
+ private void hideCertP12Fields(){
+ lblP12CertificateLocation.setVisible(false);
+ txtP12CertificateLocation.setVisible(false);
+ btnP12CertificateLocation.setVisible(false);
+ lblCertPass.setVisible(false);
+ certpass.setVisible(false);
+ }
+ private void showCertP12Fields(){
+ lblP12CertificateLocation.setVisible(true);
+ txtP12CertificateLocation.setVisible(true);
+ btnP12CertificateLocation.setVisible(true);
+ lblCertPass.setVisible(true);
+ certpass.setVisible(true);
+ }
+ private void hideCertInBrowserFields(){
+ lblBrowserPass.setVisible(false);
+ browserpass.setVisible(false);
+ lbllBrowserCombo.setVisible(false);
+ cmbBrowsers.setVisible(false);
+ lbllCertCombo.setVisible(false);
+ cmbCertificates.setVisible(false);
+ btnCheckCertsInBrowser.setVisible(false);
+ cmbCertificates.removeAllItems();
+ cmbBrowsers.removeAllItems();
+ }
+ private void showCertInBrowserFields(){
+ lblBrowserPass.setVisible(true);
+ browserpass.setVisible(true);
+ lbllBrowserCombo.setVisible(true);
+ cmbBrowsers.setVisible(true);
+ lbllCertCombo.setVisible(true);
+ cmbCertificates.setVisible(true);
+ btnCheckCertsInBrowser.setVisible(true);
+ cmbCertificates.removeAllItems();
+ cmbBrowsers.removeAllItems();
+ }
+ private void hideProxyFileFields(){
+ lblProxy.setVisible(false);
+ txtProxy.setVisible(false);
+ btnProxy.setVisible(false);
+ }
+ private void showProxyFileFields(){
+ lblProxy.setVisible(true);
+ txtProxy.setVisible(true);
+ btnProxy.setVisible(true);
+ }
+/*
+ * Set selected the proper radiobutton depending the number of mode
+ * used while reading from properties
+ */
+ private void setSelectedModeFields(int num) {
+ switch(num){
+ case PEM_MODE:
+ btnProxyCertKeyPair.setSelected(true);
+ break;
+ case P12_MODE:
+ btnProxyP12.setSelected(true);
+ break;
+ case BROWSER_MODE:
+ btnProxyBrowser.setSelected(true);
+ break;
+ case PROXY_MODE:
+ btnProxyFile.setSelected(true);
+ break;
}
-
- private void hideProxyLoginFields(){
- lblProxy.setVisible(false);
- txtProxy.setVisible(false);
- btnProxy.setVisible(false);
- lblCerts.setVisible(false);
- txtCerts.setVisible(false);
- btnCerts.setVisible(false);
+ }
+ private int getSelectedModeFieldNum() {
+ if(btnProxyCertKeyPair.isSelected())
+ return PEM_MODE;
+ if(btnProxyP12.isSelected())
+ return P12_MODE;
+ if(btnProxyBrowser.isSelected())
+ return BROWSER_MODE;
+ if(btnProxyFile.isSelected())
+ return PROXY_MODE;
+ return PROXY_MODE; //old option used as default
+ }
+ private void showProxyChoosenModeFields() {
+ if(btnProxyCertKeyPair.isSelected()){
+ showCertKeyPairFields();
+ }else if(btnProxyP12.isSelected()){
+ showCertP12Fields();
+ }else if(btnProxyBrowser.isSelected()){
+ showCertInBrowserFields();
+ }else if(btnProxyFile.isSelected()){
+ showProxyFileFields();
+ }
+ }
+ /*
+ * Creates a GSSCredential form diferent data: proxy file, p12, pem form file system or browser
+ * Proxy type as default in grid-proxy-init (GSIConstants.GSI_3_IMPERSONATION_PROXY).
+ */
+ private GSSCredential getGssCredential() throws GlobusCredentialException, GSSException {
+ // should it be possinble to change by user?
+ int proxyLifetimeSeconds = 1000;
+ if(btnProxyFile.isSelected()){
+ //a it was previously
+ String proxyFilePath = txtProxy.getText();
+ GlobusCredential globusCred = new GlobusCredential(proxyFilePath);
+ return new GlobusGSSCredentialImpl(globusCred, GSSCredential.INITIATE_AND_ACCEPT);
+ }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);
+ }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";
+ try {
+ CertificateConverter.PKCS12ToPem(p12Cert, certpass.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);
+ }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);
}
-
-
-
+ return null;
+ }
+/*
+ * WARNING:
+ * - partly untested code below
+ * - code based on correct function actionPerformed from CertificateManager.java in Certman project
+ *
+ * - to install requred jar file in yout local maven repo please excute:
+ * mvn install:install-file -Dfile=<your location of this jar>/libbrowser.jar -DgroupId=vine_certman -DartifactId=libbrowser -Dversion=1 -Dpackaging=jar -e
+ *
+ * It is necessary due to he fact, that this jar is unreachable in main maven repo
+ */
+ private void fillBrowserComboBox(){
+ cmbBrowsers.removeAllItems();
+ String[] browsers = getBrowsersList();
+ if(browsers != null){
+ for(String s : browsers){
+ cmbBrowsers.addItem(s);
+ }
+ }
+ }
+ private void fillCertificateComboBox(){
+ cmbCertificates.removeAllItems();
+ String[] certs = getCertifiatesInBrowserList();
+ if(certs != null){
+ for(String s : certs){
+ cmbCertificates.addItem(s);
+ }
+ }
+ }
+ /*
+ * Class needed by Browser class used by code based on certman
+ */
+ private static class PasswordPrompt implements Browser.PasswordCallback {
+ public char[] prompt(String promptString) {
+ return dialog.browserpass.getPassword();
+ }
+ public PasswordPrompt(LoginDialog tmp) {
+ this.dialog = tmp;
+ }
+ final LoginDialog dialog;
+ }
+ private String profile = null;
+ /*
+ * Gets the list of browsers.
+ */
+ private String[] getBrowsersList(){
+ //Browser.getCurrentBrowser();
+ String profiles[] = null;
+ if (profile == null) {
+ profiles = new String[0];
+ try {
+ profiles = Browser.getBrowserList();
+ } catch (IOException e) {
+ log.debug("Could not find any recognized browsers." + e);
+ MessageManager.showError(this,"Could not find any recognized browsers.", "Browser Error");
+ return null;
+ }
+ if (profiles.length == 0) {
+ log.debug("No browsers found");
+ MessageManager.showError(this,"No browsers found.", "Browser Error");
+ return null;
+ }
+ }
+ return profiles;
+ }
+ /*
+ * Sets the selected browser, what is needed for other funkctions to know
+ * where to look for the certificates
+ */
+ private void setSelectedBrowser(String browserChoosen){
+ log.debug("Response option: " + browserChoosen);
+ if (browserChoosen == null)
+ return;
+ else
+ Browser.setBrowser(browserChoosen);
+ profile = Browser.getCurrentBrowser();
+ log.debug("Current browser profile: " + profile);
+ }
+ /*
+ * Gets list of certificates in selected browser keystore
+ * Acceses selected browser keystore, uses prossword provided by user
+ */
+ private String[] getCertifiatesInBrowserList(){
+ if(Browser.getCurrentBrowser() == null){
+ return null;
+ }
+ String dnlist[] = null;
+ try {
+ dnlist = Browser.getDNlist(new PasswordPrompt(this));
+ log.debug("Current dnlist: " + dnlist);
+ } catch (IOException e) {
+ log.debug("Could not access keystore in profile: " + profile + " : " + e);
+ MessageManager.showError(this, "Could not access keystore in profile: " + profile, e.getLocalizedMessage());
+ return null;
+ } catch (KeyStoreException e) {
+ log.debug("Could not access keystore in profile: " + profile + " : " + e);
+ MessageManager.showError(this, "Could not access keystore in profile: " + profile, e.getLocalizedMessage());
+ return null;
+ } catch (NoSuchAlgorithmException e) {
+ log.debug("Could not access keystore in profile: " + profile + " : " + e);
+ MessageManager.showError(this, "Could not access keystore in profile: " + profile, e.getLocalizedMessage());
+ return null;
+ } catch (CertificateException e) {
+ log.debug("Could not access keystore in profile: " + profile + " : " + e);
+ MessageManager.showError(this, "Could not access keystore in profile: " + profile, e.getLocalizedMessage());
+ return null;
+ } catch (InvalidAlgorithmParameterException e) {
+ log.debug("Could not access keystore in profile: " + profile + " : " + e);
+ MessageManager.showError(this, "Could not access keystore in profile: " + profile, e.getLocalizedMessage());
+ return null;
+ } catch (javax.security.auth.login.FailedLoginException e) {
+ log.debug("Could not access keystore in profile: " + profile + " : " + e);
+ MessageManager.showError(this, e.getMessage(), "Incorrect Password");
+ return null;
+ } catch (GeneralSecurityException e) {
+ if (e.getMessage().indexOf("version>=1.5") >= 0) {
+ MessageManager.showError(this, e.getMessage(), "Browser selection tool");
+ } else {
+ log.debug("Could not access keystore in profile: " + profile + " : " + e);
+ MessageManager.showError(this, "Could not access keystore in profile: " + profile, e.getLocalizedMessage());
+ }
+ return null;
+ }
+ if (dnlist == null) {
+ log.debug("Certificates list is empty: " + profile);
+ MessageManager.showError(this, "No Certificates found", "Browser selection tool");
+ return null;
+ }
+ if (dnlist.length == 0) {
+ MessageManager.showError(this, "No Certificates found", "Browser selection tool");
+ return null;
+ }
+ return dnlist;
+ }
+ /*
+ * Gets the choosen certificate from actual browser.
+ */
+ private X509Certificate getSelectedCertificateFromBrowser(String dnChoosen){
+ X509Certificate certificateBrowser = null;
+ String browserDNChosen = dnChoosen;
+ log.debug("Browser cert DN chosen : " + browserDNChosen);
+ Browser.CertInfo info = null;
+ try {
+ certificateBrowser = Browser.getCertificate(browserDNChosen);
+ log.debug("Browser cert retrieved: " + certificateBrowser.getSubjectDN());
+ info = Browser.theProfile;
+ log.debug("Browser cert info : " + info);
+ } catch (IOException e) {
+ log.debug("Could not access certificate in the browser keystore in profile: " + profile + " : " + e);
+ MessageManager.showError(this, e.getMessage(), "Could not access certificate in the browser keystore in profile: " + profile);
+ return null;
+ } catch (GeneralSecurityException e) {
+ log.debug("Could not access certificate in the browser keystore in profile: " + profile + " : " + e);
+ MessageManager.showError(this, e.getMessage(), "Could not access certificate in the browser keystore in profile: " + profile);
+ return null;
+ }
+ return certificateBrowser;
+ }
+ /*
+ * Gets the choosen key from actual browser.
+ */
+ private PrivateKey getSelectedKeyFromBrowser(String dnChoosen){
+ PrivateKey browserKey = uk.ac.rl.esc.browser.IECertificateInterface.getKey(dnChoosen);
+ log.debug("Browser cert key present : " + (browserKey != null));
+ return browserKey;
+ }
}
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
new file mode 100644
index 0000000..4d2d447
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/CertificateConverter.java
@@ -0,0 +1,103 @@
+package org.irods.jargon.idrop.desktop.systraygui.gss;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.security.Key;
+import java.security.SecureRandom;
+import java.security.Security;
+import org.bouncycastle.openssl.PEMWriter;
+import java.security.cert.Certificate;
+
+/**
+ * Class based on QCG-Icon project on CertificateFromP12ToPem.java file
+ *
+ * Commented code - possible improvements requiering much more copied code and classes.
+ *
+ * @author Kalina Jasinska
+ * @author jkonczak
+ */
+public class CertificateConverter {
+
+ static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(CertificateConverter.class.getName());
+
+ public static void PKCS12ToPem(final String cerFile, final String password) throws Exception {
+ char[] pass = password.toCharArray();
+ try {
+ java.security.KeyStore ks = java.security.KeyStore.getInstance("PKCS12");
+ ks.load(new FileInputStream(cerFile), pass);
+ String alias = ks.aliases().nextElement();
+ logger.error("Alias: " + alias);
+ Key key = ks.getKey(alias, pass);
+ Certificate cert = ks.getCertificate(alias);
+
+ WriteCert(cert);
+ WriteKey(key, pass);
+
+ } catch (Exception ex) {
+ logger.error("PKCK12 to PEM conversion failed.\n" + ex.getMessage());
+ ex.printStackTrace();
+ throw ex;
+ }
+ }
+
+ public static void WriteCert(Certificate cert) throws IOException {
+ File certFile = initializeCredentialFile("usercert.pem");
+ FileWriter certWriter = new FileWriter(certFile);
+ PEMWriter pemCertWriter = new PEMWriter(certWriter);
+ pemCertWriter.writeObject(cert);
+ pemCertWriter.close();
+ certWriter.close();
+ //Utils.trySetOwnerOnlyChmod(certFile, true);
+ //Utils.tryHideFile(globusDir.getAbsolutePath());
+ }
+
+ public static void WriteKey(Key key, char[] password) throws IOException {
+ File keyFile = initializeCredentialFile("userkey.pem");
+ FileWriter keyWriter = new FileWriter(keyFile);
+ PEMWriter pemKeyWriter = new PEMWriter(keyWriter);
+ Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
+ pemKeyWriter.writeObject(key, "DESEDE", password, new SecureRandom());//to sypie
+ pemKeyWriter.close();
+ keyWriter.close();
+ // Utils.trySetOwnerOnlyChmod(keyFile, true);
+ // Utils.tryHideFile(globusDir.getAbsolutePath());
+ }
+
+ public static File initializeCredentialFile(String name) throws IOException {
+ File keyFile = new File(System.getProperty("user.home") + File.separator + ".idrop" + File.separator + name);
+ //trySetOwnerOnlyChmod(keyFile, false);
+ return keyFile;
+ }
+// public static void secureCredentialFile(String property) throws IOException {
+// File globusDir = new File(System.getProperty(property)).getParentFile();
+// File keyFile = new File(System.getProperty(property));
+// trySetOwnerOnlyChmod(keyFile, true);
+// tryHideFile(globusDir.getAbsolutePath());
+// }
+// public static void tryHideFile(String filePath) {
+// try {
+// PlatformProvider.getProvider().tryHideFile(filePath);
+// } catch (Exception ex) {
+// logger.debug("Utils.tryHideFile", ex);
+// }
+// }
+ /**
+ * Probably makes the file owner-only accessible and - if specified - read
+ * only
+ */
+// public static void trySetOwnerOnlyChmod(File file, boolean readOnly) {
+// try {
+// if (file.exists()) {
+// PlatformProvider.getProvider().trySetOwnerOnlyChmod(file, readOnly);
+// return;
+// }
+// logger.debug("Utils.trySetOwnerOnlyChmod.0: the specified file doesn't exist:" + file.getAbsolutePath());
+// } catch (IOException ex) {
+// logger.debug("Utils.trySetOwnerOnlyChmod.2", ex);
+// } catch (InterruptedException ex) {
+// logger.debug("Utils.trySetOwnerOnlyChmod.3", ex);
+// }
+// }
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/GssSecurityException.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/GssSecurityException.java
new file mode 100644
index 0000000..3078eeb
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/GssSecurityException.java
@@ -0,0 +1,27 @@
+package org.irods.jargon.idrop.desktop.systraygui.gss;
+/**
+ * @author <a href="mailto:michael.russell@aei.mpg.de">Michael Russell</a>
+ * @version $Id: GssSecurityException.java 5 2006-03-08 15:33:41Z wehrens $
+ */
+
+/**
+ * Describes a credential related exception.
+ */
+public class GssSecurityException extends RuntimeException {
+
+ public GssSecurityException() {
+ super();
+ }
+
+ public GssSecurityException(Throwable ex) {
+ super(ex);
+ }
+
+ public GssSecurityException(String message) {
+ super(message);
+ }
+
+ public GssSecurityException(String message, Throwable ex) {
+ super(message, ex);
+ }
+} \ No newline at end of file
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/GssUtil.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/GssUtil.java
new file mode 100644
index 0000000..f171375
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/gss/GssUtil.java
@@ -0,0 +1,597 @@
+package org.irods.jargon.idrop.desktop.systraygui.gss;
+
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.globus.gsi.GSIConstants;
+import org.globus.gsi.GlobusCredential;
+import org.globus.gsi.OpenSSLKey;
+import org.globus.gsi.X509ExtensionSet;
+import org.globus.gsi.bc.BouncyCastleCertProcessingFactory;
+import org.globus.gsi.bc.BouncyCastleOpenSSLKey;
+import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
+import org.globus.util.Base64;
+import org.gridforum.jgss.ExtendedGSSCredential;
+import org.gridforum.jgss.ExtendedGSSManager;
+import org.ietf.jgss.GSSCredential;
+import org.apache.log4j.Logger;
+import java.io.*;
+import java.security.*;
+import java.security.cert.CertificateFactory;
+import java.security.cert.X509Certificate;
+
+/*
+ * Class from Certman project, without some unused functions.
+ */
+public class GssUtil {
+
+ static Logger log = Logger.getLogger(GssUtil.class.getName());
+ /**
+ * Default credential type:
+ * <code>GSIConstants.GSI_3_IMPERSONATION_PROXY</code>
+ *
+ * @see GSIConstants
+ */
+ public static final int DEFAULT_CREDENTIAL_TYPE = GSIConstants.GSI_3_IMPERSONATION_PROXY;
+ /**
+ * Default credential lifetime is the "maximum permitted" credential
+ * lifetime. See
+ * <code>ExtendedGSSManager</code> for more information.
+ *
+ * @see org.ietf.jgss.GSSCredential
+ */
+ public static final int DEFAULT_CREDENTIAL_LIFETIME = GSSCredential.DEFAULT_LIFETIME;
+ /**
+ * Default signature algorithm: "MD5WithRSA"
+ */
+ /**
+ * The Java security provider is determined during initialization of this
+ * utility. The default will be
+ * <code>BouncyCastle</code> if one is not already set.
+ */
+ private static Provider provider = null;
+ /**
+ * The X509
+ * <code>CertificateFactory</code> is determined during initialization of
+ * this utility and depends on which security provider is enabled for this
+ * utility. The default will be the
+ * <code>BouncyCastle</code> certificate factory if one is not already set.
+ */
+ private static CertificateFactory certificateFactory = null;
+ /**
+ * Indicates whether this utility has been initialized or not.
+ */
+ private static boolean isInited = false;
+ private static KeyPair keyPair = null;
+
+ public static KeyPair getKeyPair() {
+ return keyPair;
+ }
+
+ /**
+ * Creates a GSS credential for the system user under which this application
+ * is running.
+ *
+ * @return The default system user GSS credential.
+ * @throws org.vinetoolkit.certman.spi.GssSecurityException If an error
+ * occurs while retrieving the GSS credential
+ */
+ public static GSSCredential createDefaultSystemUserGssCredential() throws GssSecurityException {
+ try {
+ log.info("Creating default GSS credential for environment ");
+ GlobusCredential credential = GlobusCredential.getDefaultCredential();
+ return new GlobusGSSCredentialImpl(credential,
+ GSSCredential.INITIATE_AND_ACCEPT);
+ } catch (Exception e) {
+ log.error("Unable to create default GSS credential for environment", e);
+ throw new GssSecurityException(e);
+ }
+ }
+
+ /**
+ * Creates a GSS credential stored in the given proxy file.
+ *
+ * @param file The proxy file
+ * @return The GSS credential
+ * @throws GssSecurityException If an error occurs while creating the GSS
+ * credential
+ */
+ public static GSSCredential createCredentialFromProxyFile(File file) throws GssSecurityException {
+ return createCredentialFromProxyFileTime(file, DEFAULT_CREDENTIAL_LIFETIME);
+ }
+
+ /**
+ * Creates a GSS credential from the given proxy file for the given
+ * lifetime.
+ *
+ * @param proxyFile The proxy file
+ * @param time The credential lifetime
+ * @return The GSS credential
+ * @throws GssSecurityException If an error occurs while creating the GSS
+ * credential
+ */
+ public static GSSCredential createCredentialFromProxyFileTime(File proxyFile, int time) throws GssSecurityException {
+ FileInputStream in = null;
+ try {
+
+ // Make sure we're initialized
+ init();
+
+ log.info("Creating GSS credential with proxy file " + proxyFile.getPath());
+ byte[] data = new byte[(int) proxyFile.length()];
+ in = new FileInputStream(proxyFile);
+ // read in the credential data
+ in.read(data);
+ in.close();
+ ExtendedGSSManager manager = (ExtendedGSSManager) ExtendedGSSManager.getInstance();
+ if (time <= 0) {
+ time = DEFAULT_CREDENTIAL_LIFETIME;
+ }
+ return manager.createCredential(data,
+ ExtendedGSSCredential.IMPEXP_OPAQUE,
+ time,
+ null, // use default mechanism - GSI
+ GSSCredential.INITIATE_AND_ACCEPT);
+ } catch (Exception e) {
+ log.error("Unable to create GSS credential with " + proxyFile);
+ throw new GssSecurityException(e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (Exception ex) {
+ }
+ }
+ }
+ }
+
+ /**
+ * Creates a GSS credential from the given proxy file for the given
+ * lifetime.
+ *
+ * @param data The proxy file
+ * @return The GSS credential
+ * @throws GssSecurityException If an error occurs while creating the GSS
+ * credential
+ */
+ public static GSSCredential createCredentialFromProxyFileTime(byte[] data) throws GssSecurityException {
+ return createCredentialFromData(data, DEFAULT_CREDENTIAL_LIFETIME);
+ }
+
+ /**
+ * Creates a GSS credential from the given proxy file for the given
+ * lifetime.
+ *
+ * @param data The proxy data
+ * @param time The credential lifetime
+ * @return The GSS credential
+ * @throws GssSecurityException If an error occurs while creating the GSS
+ * credential
+ */
+ public static GSSCredential createCredentialFromData(byte[] data, int time) throws GssSecurityException {
+ try {
+
+ // Make sure we're initialized
+ init();
+
+ log.info("Creating GSS credential with data " + data.length);
+ ExtendedGSSManager manager = (ExtendedGSSManager) ExtendedGSSManager.getInstance();
+ if (time <= 0) {
+ time = DEFAULT_CREDENTIAL_LIFETIME;
+ }
+ return manager.createCredential(data,
+ ExtendedGSSCredential.IMPEXP_OPAQUE,
+ time,
+ null, // use default mechanism - GSI
+ GSSCredential.INITIATE_AND_ACCEPT);
+ } catch (Exception e) {
+ log.error("Unable to create GSS credential with data " + data.length, e);
+ throw new GssSecurityException(e);
+ }
+ }
+
+ /**
+ * Creates a GSS credential from the given certificate file and private key
+ * file paths lasting for the maximum permitted lifetime.
+ *
+ * @param certFilePath The path to the certificate file
+ * @param keyFilePath The path to the private key file
+ * @return The GSS credential
+ * @throws GssSecurityException If an error occurs while creating the GSS
+ * credential
+ */
+ public static GSSCredential createCredentialFromCertKey(String certFilePath, String keyFilePath)
+ throws GssSecurityException {
+ return createCredentialFromCertKeyTime(certFilePath, keyFilePath, DEFAULT_CREDENTIAL_LIFETIME);
+ }
+
+ public static GSSCredential createCredentialFromCertKeyTime(String certFilePath, String keyFilePath, int time)
+ throws GssSecurityException {
+ return createCredentialFromCertKeyPassTime(certFilePath, keyFilePath, null, time);
+ }
+
+ /**
+ * Creates a GSS credential from the given certificate file and private key
+ * file paths and private key password lasting for the maximum permitted
+ * lifetime.
+ *
+ * @param certFilePath The path to the certificate file
+ * @param keyFilePath The path to the private key file
+ * @param password The private key password
+ * @return The GSS credential
+ * @throws GssSecurityException If an error occurs while creating the GSS
+ * credential
+ */
+ public static GSSCredential createCredentialFromCertKeyPass(String certFilePath, String keyFilePath, String password)
+ throws GssSecurityException {
+ return createCredentialFromCertKeyPassTime(certFilePath, keyFilePath, password, 0);
+ }
+
+ /**
+ * Creates a GSS credential from the given certificate file and private key
+ * file paths and private key password lasting for the maximum permitted
+ * lifetime.
+ *
+ * @param certFilePath The path to the certificate file
+ * @param keyFilePath The path to the private key file
+ * @param password The private key password
+ * @param proxyType type of the proxy
+ * @return The GSS credential
+ * @throws GssSecurityException If an error occurs while creating the GSS
+ * credential
+ */
+ public static GSSCredential createCredentialFromCertKeyPass(String certFilePath, String keyFilePath, String password, int proxyType)
+ throws GssSecurityException {
+ return createCredentialFromCertKeyPassTime(certFilePath, keyFilePath, password, 0, proxyType);
+ }
+
+ public static GSSCredential createCredentialFromCertKeyPassTime(String certFilePath, String keyFilePath, String password, int time)
+ throws GssSecurityException {
+ return createCredentialFromCertKeyPassTime(certFilePath, keyFilePath, password, time, DEFAULT_CREDENTIAL_TYPE);
+ }
+
+ public static GSSCredential createCredentialFromCertKeyPassTime(String certFilePath, String keyFilePath, String password, int time, int proxyType)
+ throws GssSecurityException {
+ try {
+
+ // Make sure we're initialized
+ init();
+
+ GlobusCredential cred = null;
+ PrivateKey privateKey = loadPrivateKey(keyFilePath, password);
+ X509Certificate[] certificates = new X509Certificate[]{loadCertificate(certFilePath)};
+ BouncyCastleCertProcessingFactory factorybc =
+ BouncyCastleCertProcessingFactory.getDefault();
+ X509ExtensionSet extSet = null;
+ log.debug("Creating GSS credential");
+ cred = factorybc.createCredential(certificates,
+ privateKey,
+ 512,
+ time,
+ proxyType,
+ extSet);
+ log.debug("createCredentialFromCertKeyPassTime() cred \n" + cred.toString());
+ GSSCredential gsscred = new GlobusGSSCredentialImpl(cred,
+ GSSCredential.INITIATE_AND_ACCEPT);
+ return gsscred;
+ } catch (Exception e) {
+ log.error("Unable to create GSS credential with " + certFilePath + " and " + keyFilePath + ". Error message: " + e.getMessage());
+ throw new GssSecurityException(e);
+ }
+
+ }
+
+ public static GSSCredential createCredentialFromCertKeyPassTime(X509Certificate publicCert, PrivateKey key, String password, int time, int proxyType)
+ throws GssSecurityException {
+ try {
+
+ // Make sure we're initialized
+ init();
+
+ GlobusCredential cred = null;
+ X509Certificate[] certificates = new X509Certificate[]{publicCert};
+ BouncyCastleCertProcessingFactory factorybc =
+ BouncyCastleCertProcessingFactory.getDefault();
+ X509ExtensionSet extSet = null;
+ log.debug("Creating GSS credential");
+ cred = factorybc.createCredential(certificates,
+ key,
+ 512,
+ time,
+ proxyType,
+ extSet);
+ log.debug("createCredentialFromCertKeyPassTime() cred \n" + cred.toString());
+ GSSCredential gsscred = new GlobusGSSCredentialImpl(cred,
+ GSSCredential.INITIATE_AND_ACCEPT);
+ return gsscred;
+ } catch (Exception e) {
+ log.error("Unable to create GSS credential with " + publicCert + " and " + key + ". Error message: " + e.getMessage());
+ throw new GssSecurityException(e);
+ }
+
+ }
+
+ public static GlobusCredential createCredentialFromKeystorePassTime(String keystoreFilePath, String password, String alias, int time, int proxyType)
+ throws GssSecurityException {
+ try {
+
+ // Make sure we're initialized
+ init();
+
+ GlobusCredential cred = null;
+ PrivateKey privateKey = loadPrivateKey(keystoreFilePath, alias, password);
+ X509Certificate[] certificates = new X509Certificate[]{loadCertificateFromKeystore(keystoreFilePath, alias, password)};
+ BouncyCastleCertProcessingFactory factorybc =
+ BouncyCastleCertProcessingFactory.getDefault();
+ X509ExtensionSet extSet = null;
+ log.debug("Creating GSS credential");
+ cred = factorybc.createCredential(certificates,
+ privateKey,
+ 512,
+ time,
+ proxyType,
+ extSet);
+ log.debug("createCredentialFromCertKeyPassTime() cred: " + cred.toString());
+ log.debug("createCredentialFromCertKeyPassTime() cred class: " + cred.getClass());
+ /*GSSCredential gsscred = new GlobusGSSCredentialImpl(cred,
+ GSSCredential.INITIATE_AND_ACCEPT);
+ return gsscred; */
+ return cred;
+ } catch (Exception e) {
+ log.error("Unable to create GSS credential with keystore: " + keystoreFilePath + ". Error message: " + e.getMessage());
+ throw new GssSecurityException(e);
+ }
+
+ }
+
+ public static X509Certificate loadCertificate(String filePath) throws GssSecurityException {
+
+
+ boolean isCert = false;
+ X509Certificate cert = null;
+
+ String line;
+ StringBuffer buff = new StringBuffer();
+
+ try {
+
+ // Make sure we're inited
+ init();
+
+ BufferedReader reader = new BufferedReader(new FileReader(filePath));
+ while ((line = reader.readLine()) != null) {
+ if (line.indexOf("BEGIN CERTIFICATE") != -1) {
+ isCert = true;
+ } else if (isCert && line.indexOf("END CERTIFICATE") != -1) {
+ byte[] data = Base64.decode(buff.toString().getBytes());
+ cert = loadCertificate(new ByteArrayInputStream(data));
+ } else if (isCert) {
+ buff.append(line);
+ }
+ }
+ reader.close();
+ } catch (Exception e) {
+ log.error("Error loading X509 certificate from file " + filePath, e);
+ throw new GssSecurityException(e);
+ }
+
+ if (cert == null) {
+ log.error("No data found in X509 certificate from file " + filePath);
+ throw new GssSecurityException("Certificate data not found.");
+ }
+
+ return cert;
+ }
+
+ /**
+ * Deserializes the X509 certificate stored in the given file path
+ *
+ * @param keystoreFilePath The X509 certificate file path
+ * @return The X509 certificate
+ * @throws GssSecurityException If an error occurs during deserialization
+ */
+ public static X509Certificate loadCertificateFromKeystore(String keystoreFilePath, String alias, String password) throws GssSecurityException {
+ boolean isCert = false;
+ X509Certificate cert = null;
+
+ String line;
+ StringBuffer buff = new StringBuffer();
+
+ try {
+
+ // Make sure we're inited
+ init();
+
+ KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
+ log.debug("GssUtil: loadCertificateFromKeystore() load keystore " + keystoreFilePath);
+
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(keystoreFilePath);
+ ks.load(fis, password.toCharArray());
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ }
+ log.debug("GssUtil: loadCertificateFromKeystore() keystore loaded: " + ks);
+
+ cert = (X509Certificate) ks.getCertificate(alias);
+
+ log.debug("GssUtil: loadCertificateFromKeystore() cert loaded: " + cert);
+
+ } catch (Exception e) {
+ log.error("Error loading X509 certificate from file " + keystoreFilePath, e);
+ throw new GssSecurityException(e);
+ }
+
+ if (cert == null) {
+ log.error("No data found in X509 certificate from file " + keystoreFilePath);
+ throw new GssSecurityException("Certificate data not found.");
+ }
+
+ return cert;
+ }
+
+ /**
+ * Deserializes the X509 certificate stored in the given input stream
+ *
+ * @param in The input stream
+ * @return The X509 certificate
+ * @throws GssSecurityException If an error occurs during deserialization
+ */
+ public static X509Certificate loadCertificate(InputStream in) throws GeneralSecurityException {
+ return (X509Certificate) getCertificateFactory().generateCertificate(in);
+ }
+
+ /**
+ * Returns the private key from the given file path using the given
+ * password.
+ *
+ * @param keyFile The private key file path
+ * @param password The password
+ * @return The private key
+ * @throws GssSecurityException If an error occurs while retrieving the
+ * private key
+ */
+ public static PrivateKey loadPrivateKey(String keyFile, String password) throws GssSecurityException {
+ try {
+
+ // Make sure we're inited
+ init();
+
+ OpenSSLKey key = new BouncyCastleOpenSSLKey(keyFile);
+ if (key.isEncrypted()) {
+ key.decrypt(password);
+ }
+ return key.getPrivateKey();
+ } catch (IOException e) {
+ log.error("Failed to load private key ", e);
+ throw new GssSecurityException("Failed to load private key ", e);
+ } catch (GeneralSecurityException e) {
+ log.error("Looks like wrong pass phrase. Error message: " + e.getMessage());
+ throw new GssSecurityException(e);
+ }
+ }
+
+ /**
+ * Returns the private key from the given file path to keystore using the
+ * given password.
+ *
+ * @param keyStoreFile The private key file path
+ * @param alias Alias
+ * @param password The password
+ * @return The private key
+ * @throws GssSecurityException If an error occurs while retrieving the
+ * private key
+ */
+ public static PrivateKey loadPrivateKey(String keyStoreFile, String alias, String password) throws GssSecurityException {
+ try {
+
+ // Make sure we're inited
+ init();
+
+ KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
+ log.debug("GssUtil: loadPrivateKey() load keystore " + keyStoreFile);
+
+ FileInputStream fis = null;
+ try {
+ fis = new FileInputStream(keyStoreFile);
+ ks.load(fis, password.toCharArray());
+ } finally {
+ if (fis != null) {
+ fis.close();
+ }
+ }
+ log.debug("GssUtil: loadPrivateKey() keystore loaded: " + ks);
+ KeyStore.PasswordProtection pp = new KeyStore.PasswordProtection(password.toCharArray());
+ KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry) ks.getEntry(alias, pp);
+ PrivateKey myPrivateKey = pkEntry.getPrivateKey();
+ log.debug("GssUtil: loadPrivateKey() private key loaded: " + myPrivateKey);
+
+ return myPrivateKey;
+ } catch (IOException e) {
+ log.error("Failed to load private key ", e);
+ throw new GssSecurityException("Failed to load private key ", e);
+ } catch (GeneralSecurityException e) {
+ log.error("Looks like wrong pass phrase. Error message: " + e.getMessage());
+ throw new GssSecurityException("Wrong pass phrase", e);
+ }
+ }
+
+ public static Provider getProvider() throws GeneralSecurityException {
+ // Make sure we're initialized
+ init();
+ return provider;
+ }
+
+ /**
+ * Sets the security provider for this utility. This method will also
+ * reconfigure the certificate factory used by this utility.
+ *
+ * @param provider The security provider
+ * @throws java.security.GeneralSecurityException If an error occurs getting
+ * a new certificate factory for the provider.
+ */
+ public static void setProvider(Provider provider) throws GeneralSecurityException {
+ GssUtil.provider = provider;
+ // TODO: Should we assume the provider was already added to the JVM?
+ certificateFactory = CertificateFactory.getInstance("X.509", provider);
+ }
+
+ /**
+ * Returns the certificate factory configured for use by this utility. This
+ * method will initialize this utility if hasn't already been initialized
+ *
+ * @return The certificate factory
+ * @throws java.security.GeneralSecurityException If an error occurs while
+ * initializing this utilty.
+ */
+ public static CertificateFactory getCertificateFactory() throws GeneralSecurityException {
+ // Make sure we're initialized
+ init();
+ return certificateFactory;
+ }
+
+ /**
+ * Sets the certificate factory for this utilty. This method will also
+ * reconfigure the security provider used by this utility.
+ *
+ * @param certificateFactory The certificate factory
+ */
+ public static void setCertificateFactory(CertificateFactory certificateFactory) {
+ GssUtil.certificateFactory = certificateFactory;
+ GssUtil.provider = certificateFactory.getProvider();
+ // TODO: Should we assume the provider was already added to the JVM?
+ }
+
+ /**
+ * Initializes this utility. Determines the Java security provider and
+ * certificate factory to use for handling GSS certificates.
+ *
+ * @throws java.security.GeneralSecurityException If an error occurs during
+ * initialization.
+ */
+ public static void init() throws GeneralSecurityException {
+ // Invoked by credential manager at startup, so don't need to synchronize
+ if (!isInited) {
+ log.info("Initializing GSS security");
+ if (certificateFactory == null) {
+ if (provider == null) {
+ provider = new BouncyCastleProvider();
+ if (Security.getProvider(provider.getName()) == null) {
+ log.info("Registering security provider: " + provider.getName());
+ Security.addProvider(provider);
+ } else {
+ provider = Security.getProvider(provider.getName());
+ log.info("Obtaining security provider: " + provider.getName());
+ }
+ // TODO: Should we just pass the provider here or what (was originally copied from cog)?
+ }
+ log.info("Creating certificate factory with security provider: " + provider);
+ certificateFactory = CertificateFactory.getInstance("X.509", provider);
+ } else {
+ }
+
+ isInited = true;
+ }
+ }
+}
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 0b64246..64e41df 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
@@ -38,6 +38,10 @@ public interface IdropConfigurationService {
// for GSI
public static final String ACCOUNT_CACHE_PROXY_LOCATION = "irods.account.gsi.proxy.location";
public static final String ACCOUNT_CACHE_CERTIFICATES_LOCATION = "irods.account.gsi.certificates.location";
+ 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_LOGIN_MODE = "irods.account.gsi.cert.login.mode";
// /for GSI
public static final String POLICY_AWARE_PROPERTY = "policy.aware";
public static final String LOOK_AND_FEEL = "idrop.lookandfeel";