aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2010-07-26 09:07:31 +0000
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2010-07-26 09:07:31 +0000
commit0390847848081e20d94c02cd790cffcd8cc88f81 (patch)
treeae3248b7d78e35581cf71e8d5a37a71ab849ae5d
parentba6f54e6fc4bb594dc228bfeab3a0441c864c599 (diff)
downloadjitsi-0390847848081e20d94c02cd790cffcd8cc88f81.zip
jitsi-0390847848081e20d94c02cd790cffcd8cc88f81.tar.gz
jitsi-0390847848081e20d94c02cd790cffcd8cc88f81.tar.bz2
Commits a part of the fix.patch provided by Dmitri Melnikov in the dev maling list thread "password storage exception" in order to try to address NullPointerExceptions.
-rw-r--r--src/net/java/sip/communicator/impl/credentialsstorage/CredentialsStorageServiceImpl.java13
-rw-r--r--src/net/java/sip/communicator/impl/protocol/AccountManagerImpl.java44
2 files changed, 30 insertions, 27 deletions
diff --git a/src/net/java/sip/communicator/impl/credentialsstorage/CredentialsStorageServiceImpl.java b/src/net/java/sip/communicator/impl/credentialsstorage/CredentialsStorageServiceImpl.java
index 217f4b3..a199eab 100644
--- a/src/net/java/sip/communicator/impl/credentialsstorage/CredentialsStorageServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/credentialsstorage/CredentialsStorageServiceImpl.java
@@ -311,11 +311,16 @@ public class CredentialsStorageServiceImpl
if (idx != -1)
{
String prefix = prop.substring(0, idx);
- String password
- = new String(Base64.decode(getUnencrypted(prefix)));
-
- if (!movePasswordProperty(prefix, password))
+ String encodedPassword = getUnencrypted(prefix);
+
+ if ((encodedPassword == null) || (encodedPassword.length() == 0))
+ setUnencrypted(prefix, null);
+ else if (!movePasswordProperty(
+ prefix,
+ new String(Base64.decode(encodedPassword))))
+ {
logger.warn("Failed to move password for prefix " + prefix);
+ }
}
}
}
diff --git a/src/net/java/sip/communicator/impl/protocol/AccountManagerImpl.java b/src/net/java/sip/communicator/impl/protocol/AccountManagerImpl.java
index c13157b..ec550d1 100644
--- a/src/net/java/sip/communicator/impl/protocol/AccountManagerImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/AccountManagerImpl.java
@@ -137,12 +137,15 @@ public class AccountManagerImpl
configService.getPropertyNamesByPrefix(storedAccount, true);
Map<String, String> accountProperties =
new Hashtable<String, String>();
-
- boolean isDisabled = false;
-
- for (Iterator<String> storedAccountPropertyIter =
- storedAccountProperties.iterator(); storedAccountPropertyIter
- .hasNext();)
+ boolean disabled = false;
+ CredentialsStorageService credentialsStorage
+ = ServiceUtils.getService(
+ bundleContext,
+ CredentialsStorageService.class);
+
+ for (Iterator<String> storedAccountPropertyIter
+ = storedAccountProperties.iterator();
+ storedAccountPropertyIter.hasNext();)
{
String property = storedAccountPropertyIter.next();
String value = configService.getString(property);
@@ -150,17 +153,12 @@ public class AccountManagerImpl
property = stripPackagePrefix(property);
if (ProtocolProviderFactory.IS_ACCOUNT_DISABLED.equals(property))
- {
- isDisabled = new Boolean(value).booleanValue();
- }
+ disabled = Boolean.parseBoolean(value);
// Decode passwords.
- else if (ProtocolProviderFactory.PASSWORD.equals(property))
+ else if (ProtocolProviderFactory.PASSWORD.equals(property)
+ && !credentialsStorage.isStoredEncrypted(storedAccount))
{
- if (value == null)
- {
- value = "";
- }
- else if (value.length() != 0)
+ if ((value != null) && value.length() != 0)
{
/*
@@ -172,9 +170,7 @@ public class AccountManagerImpl
}
if (value != null)
- {
accountProperties.put(property, value);
- }
}
try
@@ -190,10 +186,8 @@ public class AccountManagerImpl
{
storedAccounts.add(accountID);
}
- if (!isDisabled)
- {
+ if (!disabled)
factory.loadAccount(accountID);
- }
}
catch (Exception ex)
{
@@ -599,11 +593,15 @@ public class AccountManagerImpl
= ServiceUtils.getService(
bundleContext,
CredentialsStorageService.class);
+ String accountPrefix = factoryPackage + "." + accountNodeName;
// encrypt and store
- if (!credentialsStorage.storePassword(
- factoryPackage + "." + accountNodeName,
- value))
+ if ((value != null)
+ && (value.length() != 0)
+ && !credentialsStorage.isStoredEncrypted(accountPrefix)
+ && !credentialsStorage.storePassword(
+ accountPrefix,
+ value))
{
throw
new OperationFailedException(