Author: xcoulon
Date: 2012-02-22 15:28:31 -0500 (Wed, 22 Feb 2012)
New Revision: 39013
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
Log:
Fixed - JBIDE-10993 - Error when connecting into the OpenShift Express Console for the
first time
https://issues.jboss.org/browse/JBIDE-10993
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java 2012-02-22
20:20:19 UTC (rev 39012)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/OpenShiftPasswordStorageKey.java 2012-02-22
20:28:31 UTC (rev 39013)
@@ -29,8 +29,8 @@
private String userName;
public OpenShiftPasswordStorageKey(String platform, String userName) {
- this.userName = platform;
- this.platform = userName;
+ this.platform = platform;
+ this.userName = userName;
}
@Override
@@ -47,8 +47,8 @@
if (!key.getClass().isAssignableFrom(OpenShiftPasswordStorageKey.class)) {
return false;
}
- OpenShiftPasswordStorageKey deltaCloudKey = (OpenShiftPasswordStorageKey) key;
- return userName.equals(deltaCloudKey.userName)
- && platform.equals(deltaCloudKey.platform);
+ OpenShiftPasswordStorageKey openshiftKey = (OpenShiftPasswordStorageKey) key;
+ return (userName != null && openshiftKey.userName != null &&
userName.equals(openshiftKey.userName))
+ && (platform != null && openshiftKey.platform != null &&
platform.equals(openshiftKey.platform));
}
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java 2012-02-22
20:20:19 UTC (rev 39012)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/utils/SecurePasswordStore.java 2012-02-22
20:28:31 UTC (rev 39013)
@@ -48,11 +48,13 @@
}
}
- public void setPassword(String password) throws SecurePasswordStoreException {
+ public void setPassword(String password)
+ throws SecurePasswordStoreException {
update(storageKey, password);
}
- public void update(IStorageKey key, String password) throws SecurePasswordStoreException
{
+ public void update(IStorageKey key, String password)
+ throws SecurePasswordStoreException {
if (!storageKey.equals(key) || isPasswordChanged(password)) {
storeInPreferences(this.password = password, this.storageKey = key);
}
@@ -62,7 +64,8 @@
if (this.password == null && password == null) {
return false;
} else {
- return (this.password == null && password != null) || (this.password != null
&& password == null)
+ return (this.password == null && password != null)
+ || (this.password != null && password == null)
|| !password.equals(this.password);
}
}
@@ -71,15 +74,18 @@
try {
ISecurePreferences node = getNode(storageKey);
if (node == null) {
- throw new SecurePasswordStoreException("Could not remove password");
+ throw new SecurePasswordStoreException(
+ "Could not remove password");
}
node.clear();
} catch (Exception e) {
- throw new SecurePasswordStoreException("Could not remove password", e);
+ throw new SecurePasswordStoreException("Could not remove password",
+ e);
}
}
- private String getFromPreferences(IStorageKey key) throws StorageException,
UnsupportedEncodingException {
+ private String getFromPreferences(IStorageKey key) throws StorageException,
+ UnsupportedEncodingException {
ISecurePreferences node = getNode(key);
String password = node.get("password", null); //$NON-NLS-1$
if (password == null) {
@@ -88,16 +94,22 @@
return new String(EncodingUtils.decodeBase64(password));
}
- private void storeInPreferences(String password, IStorageKey key) throws
SecurePasswordStoreException {
- try {
- ISecurePreferences node = getNode(key);
- node.put("password", EncodingUtils.encodeBase64(password.getBytes()), true
/* encrypt */); //$NON-NLS-1$
- } catch (Exception e) {
- throw new SecurePasswordStoreException("Could not store password", e);
+ private void storeInPreferences(String password, IStorageKey key)
+ throws SecurePasswordStoreException {
+ if (password != null) {
+ try {
+ ISecurePreferences node = getNode(key);
+ node.put(
+ "password", EncodingUtils.encodeBase64(password.getBytes()), true /*
encrypt */); //$NON-NLS-1$
+ } catch (Exception e) {
+ throw new SecurePasswordStoreException(
+ "Could not store password", e);
+ }
}
}
- private ISecurePreferences getNode(IStorageKey key) throws UnsupportedEncodingException
{
+ private ISecurePreferences getNode(IStorageKey key)
+ throws UnsupportedEncodingException {
if (key == null) {
return null;
}
Modified:
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java
===================================================================
---
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-02-22
20:20:19 UTC (rev 39012)
+++
trunk/openshift/plugins/org.jboss.tools.openshift.express.ui/src/org/jboss/tools/openshift/express/internal/ui/wizard/CredentialsWizardPageModel.java 2012-02-22
20:28:31 UTC (rev 39013)
@@ -225,6 +225,8 @@
} catch (Exception e) {
status = OpenShiftUIActivator.createErrorStatus(NLS.bind(
"Could not check user credentials: {0}.", e.getMessage()));
+ } catch(Throwable e) {
+ Logger.error("Failed to validate credentials", e);
}
return status;
}