summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Reilly <jdr0887@renci.org>2011-07-05 15:27:08 (GMT)
committer Jason Reilly <jdr0887@renci.org>2011-07-05 15:27:08 (GMT)
commit6caa2ea55985521f673e433128625c6a4105da1a (patch)
tree206164ddb1a9cf4b41573aac89f61c8f9b2ab87b
parent6c037039ce80e4e39270e678527184db8f417c28 (diff)
downloadQCG-Data-6caa2ea55985521f673e433128625c6a4105da1a.zip
QCG-Data-6caa2ea55985521f673e433128625c6a4105da1a.tar.gz
QCG-Data-6caa2ea55985521f673e433128625c6a4105da1a.tar.bz2
initial commit
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordCancelActionListener.java27
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordDialogEnterKeyListener.java31
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordDialogWindowListener.java24
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordMenuActionListener.java33
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordSaveActionListener.java124
-rw-r--r--idrop-swing/src/main/resources/org/irods/jargon/idrop/changePasswordDialog.xml56
6 files changed, 295 insertions, 0 deletions
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordCancelActionListener.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordCancelActionListener.java
new file mode 100644
index 0000000..b998a86
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordCancelActionListener.java
@@ -0,0 +1,27 @@
+package org.irods.jargon.idrop.desktop.systraygui.listeners;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import org.irods.jargon.idrop.desktop.systraygui.IDROPDesktop;
+
+/**
+ *
+ * @author jdr0887
+ *
+ */
+public class ChangePasswordCancelActionListener implements ActionListener {
+
+ private IDROPDesktop desktop;
+
+ public ChangePasswordCancelActionListener(IDROPDesktop desktop) {
+ super();
+ this.desktop = desktop;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ desktop.changePasswordDialog.setVisible(false);
+ desktop.mainFrame.requestFocus();
+ }
+
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordDialogEnterKeyListener.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordDialogEnterKeyListener.java
new file mode 100644
index 0000000..e8f6308
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordDialogEnterKeyListener.java
@@ -0,0 +1,31 @@
+package org.irods.jargon.idrop.desktop.systraygui.listeners;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+
+import org.irods.jargon.idrop.desktop.systraygui.IDROPDesktop;
+
+public class ChangePasswordDialogEnterKeyListener extends KeyAdapter {
+
+ private IDROPDesktop desktop;
+
+ public ChangePasswordDialogEnterKeyListener(IDROPDesktop desktop) {
+ super();
+ this.desktop = desktop;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyReleased(KeyEvent e) {
+ int key = e.getKeyCode();
+ if (key == KeyEvent.VK_ENTER) {
+ ActionEvent ae = new ActionEvent(desktop.changePasswordDialogSaveButton, ActionEvent.ACTION_PERFORMED, "");
+ desktop.changePasswordDialogSaveActionListener.actionPerformed(ae);
+ }
+ }
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordDialogWindowListener.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordDialogWindowListener.java
new file mode 100644
index 0000000..a6cc0c6
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordDialogWindowListener.java
@@ -0,0 +1,24 @@
+package org.irods.jargon.idrop.desktop.systraygui.listeners;
+
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import org.irods.jargon.idrop.desktop.systraygui.IDROPDesktop;
+
+public class ChangePasswordDialogWindowListener extends WindowAdapter {
+
+ private IDROPDesktop desktop;
+
+ public ChangePasswordDialogWindowListener(IDROPDesktop desktop) {
+ super();
+ this.desktop = desktop;
+ }
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ super.windowClosing(e);
+ desktop.mainFrame.requestFocus();
+ }
+
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordMenuActionListener.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordMenuActionListener.java
new file mode 100644
index 0000000..9bd55f9
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordMenuActionListener.java
@@ -0,0 +1,33 @@
+package org.irods.jargon.idrop.desktop.systraygui.listeners;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import org.irods.jargon.core.connection.IRODSAccount;
+import org.irods.jargon.idrop.desktop.systraygui.IDROPDesktop;
+
+/**
+ *
+ * @author jdr0887
+ *
+ */
+public class ChangePasswordMenuActionListener implements ActionListener {
+
+ private IDROPDesktop desktop;
+
+ public ChangePasswordMenuActionListener(IDROPDesktop desktop) {
+ super();
+ this.desktop = desktop;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ StringBuilder sb = new StringBuilder();
+ IRODSAccount account = desktop.getiDropCore().getIrodsAccount();
+ sb.append("irods://").append(account.getUserName()).append("@").append(account.getHost()).append(":")
+ .append(account.getPort());
+
+ desktop.changePasswordDialogCurrentAccountTextField.setText(sb.toString());
+ desktop.changePasswordDialog.setVisible(true);
+ }
+
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordSaveActionListener.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordSaveActionListener.java
new file mode 100644
index 0000000..efc877c
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/listeners/ChangePasswordSaveActionListener.java
@@ -0,0 +1,124 @@
+package org.irods.jargon.idrop.desktop.systraygui.listeners;
+
+import java.awt.Color;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.List;
+
+import javax.swing.JOptionPane;
+
+import org.apache.commons.lang.StringUtils;
+import org.irods.jargon.core.connection.IRODSAccount;
+import org.irods.jargon.core.exception.JargonException;
+import org.irods.jargon.core.pub.IRODSAccessObjectFactory;
+import org.irods.jargon.core.pub.IRODSFileSystem;
+import org.irods.jargon.core.pub.UserAO;
+import org.irods.jargon.idrop.desktop.systraygui.IDROPDesktop;
+import org.irods.jargon.idrop.desktop.systraygui.util.MessageUtil;
+import org.irods.jargon.transfer.dao.domain.LocalIRODSTransfer;
+
+import com.jgoodies.validation.ValidationMessage;
+import com.jgoodies.validation.ValidationResult;
+
+/**
+ *
+ * @author jdr0887
+ *
+ */
+public class ChangePasswordSaveActionListener implements ActionListener {
+
+ private IDROPDesktop desktop;
+
+ public ChangePasswordSaveActionListener(IDROPDesktop desktop) {
+ super();
+ this.desktop = desktop;
+ }
+
+ public void actionPerformed(ActionEvent e) {
+ ValidationResult validationResults = validateLoginForm();
+
+ if (validationResults.hasErrors()) {
+ String msg = "";
+ List<ValidationMessage> errors = validationResults.getErrors();
+ for (ValidationMessage error : errors) {
+ msg += error.formattedText() + "\n";
+ }
+ JOptionPane.showMessageDialog(desktop.changePasswordDialog, msg, "Error", JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
+ String password = new String(desktop.changePasswordDialogPasswordPasswordField.getPassword());
+
+ try {
+ IRODSAccount irodsAccount = desktop.getiDropCore().getIrodsAccount();
+ // List<Transfer> recentQueue = idrop.getTransferManager().getRecentQueue();
+ List<LocalIRODSTransfer> recentQueue = null;
+ if (recentQueue != null) {
+ for (LocalIRODSTransfer transfer : recentQueue) {
+ if (transfer.getTransferHost().equals(irodsAccount.getHost())
+ && transfer.getTransferZone().equals(irodsAccount.getZone())
+ && transfer.getTransferUserName().equals(irodsAccount.getUserName())) {
+ // FIXME: right now, do not differentiate transfers that are comlete, this is a hack right now
+ // if (localIRODSTransfer.getTransferState().equals(localIRODSTransfer.TRANSFER_STATE_COMPLETE))
+ // {
+ // log.info("matched transfer was complete, ignored");
+ // } else {
+ MessageUtil
+ .showMessage(
+ desktop.changePasswordDialog,
+ "Transfers for this account are pending, this account can not be changed until completed and purged",
+ "Transfer Pending");
+ return;
+ // }
+ }
+ }
+ }
+
+ IRODSFileSystem irodsFileSystem = desktop.getiDropCore().getIrodsFileSystem();
+ IRODSAccessObjectFactory irodsAOFactory = irodsFileSystem.getIRODSAccessObjectFactory();
+ UserAO userAO = irodsAOFactory.getUserAO(desktop.getiDropCore().getIrodsAccount());
+ userAO.changeAUserPasswordByThatUser(irodsAccount.getUserName(), irodsAccount.getPassword(), password);
+ IRODSAccount newAccount = new IRODSAccount(irodsAccount.getHost(), irodsAccount.getPort(),
+ irodsAccount.getUserName(), password, irodsAccount.getHomeDirectory(), irodsAccount.getZone(),
+ irodsAccount.getDefaultStorageResource());
+ desktop.getiDropCore().setIrodsAccount(newAccount);
+ desktop.changePasswordDialogPasswordPasswordField.setText("");
+ desktop.changePasswordDialogPasswordConfirmPasswordField.setText("");
+
+ } catch (JargonException ex) {
+ } finally {
+ // idrop.getIrodsFileSystem().closeAndEatExceptions(idrop.getIrodsAccount());
+ }
+
+ MessageUtil.showMessage(desktop.changePasswordDialog, "Password was changed", "Password Changed");
+
+ }
+
+ private ValidationResult validateLoginForm() {
+ ValidationResult result = new ValidationResult();
+
+ String password = new String(desktop.changePasswordDialogPasswordPasswordField.getPassword());
+ String passwordConfirm = new String(desktop.changePasswordDialogPasswordConfirmPasswordField.getPassword());
+
+ if (StringUtils.isEmpty(password)) {
+ desktop.changePasswordDialogPasswordPasswordField.setBackground(Color.red);
+ }
+
+ if (StringUtils.isEmpty(passwordConfirm)) {
+ desktop.changePasswordDialogPasswordConfirmPasswordField.setBackground(Color.red);
+ }
+
+ if (StringUtils.isEmpty(password) || StringUtils.isEmpty(passwordConfirm)) {
+ result.addError("New or confirm password is missing");
+ }
+
+ if (!password.equals(passwordConfirm)) {
+ desktop.changePasswordDialogPasswordPasswordField.setBackground(Color.red);
+ desktop.changePasswordDialogPasswordConfirmPasswordField.setBackground(Color.red);
+ result.addError("Passwords do not match");
+ }
+
+ return result;
+ }
+
+}
diff --git a/idrop-swing/src/main/resources/org/irods/jargon/idrop/changePasswordDialog.xml b/idrop-swing/src/main/resources/org/irods/jargon/idrop/changePasswordDialog.xml
new file mode 100644
index 0000000..f6b7a68
--- /dev/null
+++ b/idrop-swing/src/main/resources/org/irods/jargon/idrop/changePasswordDialog.xml
@@ -0,0 +1,56 @@
+<dialog var="changePasswordDialog" title="Change Password" modal="true" size="460,220" resizable="false" locationrelativeto="mainFrame">
+ <panel>
+ <borderlayout>
+ <constraint location="Center">
+ <panel>
+ <titledborder title="Change Password" titlejustification="LEFT" titleposition="CENTER" titlefont="SansSerif,bold,14">
+ <etchedborder type="LOWERED" />
+ </titledborder>
+ <gridbaglayout>
+ <gridbagconstraints id="gbc" gridx="0" gridy="0" weightx="0.1" weighty="0.0" anchor="EAST" insets="2,2,2,2"
+ ipadx="5" ipady="5">
+ <label text="Current Account:" font="SansSerif,bold,12" />
+ </gridbagconstraints>
+ <idref ctor="gbc" gridx="1" gridy="0" anchor="WEST">
+ <textfield var="changePasswordDialogCurrentAccountTextField" columns="20" font="SansSerif,plain,12" enabled="false"
+ keylistener="changePasswordDialogEnterKeyListener" />
+ </idref>
+ <idref ctor="gbc" gridx="0" gridy="1" anchor="EAST">
+ <label text="New Password:" font="SansSerif,bold,12" />
+ </idref>
+ <idref ctor="gbc" gridx="1" gridy="1" anchor="WEST">
+ <passwordfield var="changePasswordDialogPasswordPasswordField" columns="20" font="SansSerif,plain,12"
+ keylistener="changePasswordDialogEnterKeyListener" />
+ </idref>
+ <idref ctor="gbc" gridx="0" gridy="2" anchor="EAST">
+ <label text="New Password Confirm:" font="SansSerif,bold,12" />
+ </idref>
+ <idref ctor="gbc" gridx="1" gridy="2" anchor="WEST">
+ <passwordfield var="changePasswordDialogPasswordConfirmPasswordField" columns="20" font="SansSerif,plain,12"
+ keylistener="changePasswordDialogEnterKeyListener" />
+ </idref>
+ </gridbaglayout>
+ </panel>
+ </constraint>
+ <constraint location="South">
+ <panel>
+ <gridbaglayout>
+ <gridbagconstraints id="gbc_button" gridx="0" gridy="0" weightx="0.0" weighty="0.1" insets="2,2,2,2">
+ <panel>
+ <gridbaglayout>
+ <gridbagconstraints id="gbc_button_form" gridx="0" gridy="0" weightx="0.1" weighty="0.1" insets="2,2,2,2">
+ <button text="OK" var="changePasswordDialogSaveButton" actionlistener="changePasswordDialogSaveActionListener" font="SansSerif,bold,14" />
+ </gridbagconstraints>
+ <idref ctor="gbc_button_form" gridx="1" gridy="0">
+ <button text="Cancel" var="changePasswordDialogCancelButton" actionlistener="changePasswordDialogCancelActionListener"
+ font="SansSerif,bold,14" />
+ </idref>
+ </gridbaglayout>
+ </panel>
+ </gridbagconstraints>
+ </gridbaglayout>
+ </panel>
+ </constraint>
+ </borderlayout>
+ </panel>
+</dialog> \ No newline at end of file