Skip to content
Browse files

upgraded jargon

set irods to use PAM authentication scheme
saved authenticated IRODSAccount object in session instead of actual credentials, i.e. workbench no longer stores any passwords
  • Loading branch information...
1 parent 569d6d4 commit 45f1132a937b9f16b82adc0453406717eda1b9d9 @gregjan gregjan committed Dec 11, 2012
View
4 irods-efs.plugin/.classpath
@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src/"/>
- <classpathentry exported="true" kind="lib" path="lib/jargon-core-3.2.0.jar" sourcepath="lib/jargon-core-3.2.0-sources.jar"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="lib" path="lib/jargon-core-3.2.1.3.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
View
2 irods-efs.plugin/META-INF/MANIFEST.MF
@@ -13,6 +13,6 @@ Require-Bundle: org.eclipse.ui,
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
- lib/jargon-core-3.2.0.jar
+ lib/jargon-core-3.2.1.3.jar
Import-Package: org.eclipse.core.filesystem
Export-Package: irods.efs.plugin
View
2 irods-efs.plugin/build.properties
@@ -3,7 +3,7 @@ output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
- lib/jargon-core-3.2.0.jar
+ lib/jargon-core-3.2.1.3.jar
src.includes = lib/slf4j-api-1.6.0.jar,\
lib/log4j-1.2.16.jar,\
lib/slf4j-api-1.6.0-javadoc.jar,\
View
BIN irods-efs.plugin/lib/jargon-core-3.2.0-sources.jar
Binary file not shown.
View
BIN irods-efs.plugin/lib/jargon-core-3.2.0.jar
Binary file not shown.
View
BIN irods-efs.plugin/lib/jargon-core-3.2.1.3.jar
Binary file not shown.
View
35 irods-efs.plugin/src/irods/efs/plugin/IrodsEFSFileSystem.java
@@ -30,6 +30,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.irods.jargon.core.connection.IRODSAccount;
+import org.irods.jargon.core.connection.IRODSAccount.AuthScheme;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,7 +39,7 @@
@SuppressWarnings("unused")
private static final Logger LOG = LoggerFactory.getLogger(IrodsEFSFileSystem.class);
private static Object lock = new Object();
- private static Map<String, String[]> sessionCredentials = new HashMap<String, String[]>();
+ private static Map<String, IRODSAccount> sessionCredentials = new HashMap<String, IRODSAccount>();
public IrodsEFSFileSystem() {
super();
@@ -74,7 +75,7 @@ public static URI storeConnectionDetails(IRODSAccount a) {
try {
URI serverURI = new URI("irods", a.getUserName(), a.getHost(), a.getPort(), "/" + a.getZone() + "/", null,
null);
- sessionCredentials.put(makeServerPreferenceKey(serverURI), new String[] {a.getUserName(), a.getPassword()});
+ sessionCredentials.put(makeServerPreferenceKey(serverURI), a);
return serverURI;
} catch (URISyntaxException e) {
throw new Error(e);
@@ -95,22 +96,13 @@ protected static IRODSAccount getAccount(final URI uri) throws CoreException {
String baseKey = makeServerPreferenceKey(uri);
// do we have credentials stored?
- String[] credentials = sessionCredentials.get(baseKey);
+ result = sessionCredentials.get(baseKey);
- if (!sessionCredentials.containsKey(baseKey)) {
- System.out.println("No stored credentials");
- // are there sufficient credentials on the URI?
- if (uri.getUserInfo() != null && uri.getUserInfo().contains(":")) {
- // we may have username and password in URI
- credentials = uri.getUserInfo().split(":");
- }
- }
-
- if (credentials == null || credentials[0] == null || credentials[1] == null) { // prompt
+ if (result == null) { // prompt
synchronized (lock) {
- credentials = sessionCredentials.get(baseKey);
- LOG.info(Thread.currentThread().getId()+" in sync and got initial creds: "+credentials);
- if (credentials == null || credentials[0] == null || credentials[1] == null) {
+ result = sessionCredentials.get(baseKey);
+ LOG.info(Thread.currentThread().getId()+" in sync and got initial account: "+result);
+ if (result == null) {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
public void run() {
String baseKey = makeServerPreferenceKey(uri);
@@ -126,23 +118,22 @@ public void run() {
} catch (URISyntaxException e) {
throw new Error(e);
}
- LoginInputDialog d = new LoginInputDialog(s, message, serverURI, promptName, zone);
+ LoginInputDialog d = new LoginInputDialog(s, message, serverURI, promptName, zone, AuthScheme.PAM);
if (Dialog.OK == d.open()) {
- sessionCredentials.put(baseKey, new String[] {d.getUsername(), d.getPassword()});
+ sessionCredentials.put(baseKey, d.getAuthenticatedIRODSAccount());
}
}
});
- credentials = sessionCredentials.get(baseKey);
- LOG.info(Thread.currentThread().getId()+" exiting sync with creds: "+credentials[1]);
+ result = sessionCredentials.get(baseKey);
+ LOG.info(Thread.currentThread().getId()+" exiting sync with creds: "+result);
}
}
}
- if (credentials[0] == null || credentials[1] == null) {
+ if (result == null) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID,
"Cannot obtain credentials for irods connection: " + uri.toString()));
}
- result = new IRODSAccount(uri.getHost(), uri.getPort(), credentials[0], credentials[1], "", zone, "fake");
return result;
}
View
40 irods-efs.plugin/src/irods/efs/plugin/LoginInputDialog.java
@@ -33,9 +33,10 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.irods.jargon.core.connection.IRODSAccount;
+import org.irods.jargon.core.connection.IRODSAccount.AuthScheme;
+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.core.pub.ResourceAO;
import org.irods.jargon.core.pub.io.IRODSFile;
import org.irods.jargon.core.pub.io.IRODSFileFactory;
@@ -56,18 +57,22 @@
String username = null;
String password = null;
+ AuthScheme authScheme = null;
+ IRODSAccount authenticatedIrodsAccount = null;
/**
* @param parentShell
+ * @param pam
*/
- protected LoginInputDialog(Shell parentShell, String message, URI irodsURI, String defaultUsername, String zone) {
+ protected LoginInputDialog(Shell parentShell, String message, URI irodsURI, String defaultUsername, String zone, AuthScheme scheme) {
super(parentShell);
this.message = message;
this.irodsURI = irodsURI;
this.defaultUsername = defaultUsername;
this.textPassword = null;
this.textUsername = null;
this.zone = zone;
+ this.authScheme = scheme;
}
@Override
@@ -165,6 +170,7 @@ public void widgetSelected(SelectionEvent e) {
protected IRODSAccount makeAccount() {
IRODSAccount result = new IRODSAccount(this.irodsURI.getHost(), this.irodsURI.getPort(), textUsername.getText(),
textPassword.getText(), "", zone, "fake");
+ result.setAuthenticationScheme(authScheme);
return result;
}
@@ -222,17 +228,16 @@ public String getPassword() {
}
private boolean testConnection(IRODSAccount account) {
- boolean result = false;
try {
+ this.authenticatedIrodsAccount = null;
IRODSFileSystem irodsFileSystem = IRODSFileSystem.instance();
- IRODSFileFactory ff = irodsFileSystem.getIRODSFileFactory(account);
- String testPath = "/lakjsdf/asdfl/asdf/thispathisgarbage";
- // System.out.println("testing path:"+testPath);
- IRODSFile file = ff.instanceIRODSFile(testPath);
-
- file.exists();
- result = true;
- setMessage("Connection succeeded.", IMessageProvider.INFORMATION);
+ AuthResponse ar = irodsFileSystem.getIRODSAccessObjectFactory().authenticateIRODSAccount(account);
+ if(ar.isSuccessful()) {
+ this.authenticatedIrodsAccount = ar.getAuthenticatedIRODSAccount();
+ setMessage("Connection succeeded.", IMessageProvider.INFORMATION);
+ this.okButton.setEnabled(true);
+ return true;
+ }
} catch (JargonException e) {
String msg = null;
if (e.getCause() != null) {
@@ -246,13 +251,12 @@ private boolean testConnection(IRODSAccount account) {
setMessage("Connection failed due to an error: " + msg, IMessageProvider.ERROR);
}
}
- if (result) {
- setMessage("Connection succeeded", IMessageProvider.INFORMATION);
- this.okButton.setEnabled(true);
- } else {
- this.okButton.setEnabled(false);
- }
- return result;
+ this.okButton.setEnabled(false);
+ return false;
+ }
+
+ public IRODSAccount getAuthenticatedIRODSAccount() {
+ return this.authenticatedIrodsAccount;
}
}

0 comments on commit 45f1132

Please sign in to comment.
Something went wrong with that request. Please try again.