diff options
author | Damian Minkov <damencho@jitsi.org> | 2010-09-27 15:10:40 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2010-09-27 15:10:40 +0000 |
commit | 8f7582b1785d9c40ecb306a6d4ed0a6cafc66be4 (patch) | |
tree | b8e40bac8e2df7f216f1f6bb2eea57f73b62790b /src/net/java/sip/communicator/impl | |
parent | aad068098463aa87250b26fd34fc0033c6a4ad43 (diff) | |
download | jitsi-8f7582b1785d9c40ecb306a6d4ed0a6cafc66be4.zip jitsi-8f7582b1785d9c40ecb306a6d4ed0a6cafc66be4.tar.gz jitsi-8f7582b1785d9c40ecb306a6d4ed0a6cafc66be4.tar.bz2 |
Fix issue#861 XCAP password prompts for master password when the SIP account is offline.
Diffstat (limited to 'src/net/java/sip/communicator/impl')
-rw-r--r-- | src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java | 54 | ||||
-rw-r--r-- | src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java | 25 |
2 files changed, 38 insertions, 41 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java index 2a6df8a..43f6656 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java @@ -34,21 +34,6 @@ public class ProtocolProviderFactorySipImpl } /** - * Ovverides the original in order not to load the XCAP_PASSWORD field. - * - * @param accountID the account identifier. - */ - public boolean loadAccount(AccountID accountID) - { - boolean result = super.loadAccount(accountID); - if (result) - { - loadXCapPassword(accountID); - } - return result; - } - - /** * Ovverides the original in order not to save the XCAP_PASSWORD field. * * @param accountID the account identifier. @@ -57,7 +42,6 @@ public class ProtocolProviderFactorySipImpl { storeXCapPassword(accountID); super.storeAccount(accountID); - loadXCapPassword(accountID); } /** @@ -67,37 +51,25 @@ public class ProtocolProviderFactorySipImpl */ private void storeXCapPassword(AccountID accountID) { - CredentialsStorageService credentialsStorage - = ServiceUtils.getService( - getBundleContext(), - CredentialsStorageService.class); - String accountPrefix = accountID.getAccountUniqueID() + ".xcap"; - String password = accountID.getAccountPropertyString( + // don't use getAccountPropertyString as it will query + // credential storage, use getAccountProperty to see is there such + // property in the account properties provided. + // if xcap password property exist, store it through credentialsStorage + // service + Object password = accountID.getAccountProperty( ProtocolProviderServiceSipImpl.XCAP_PASSWORD); if (password != null) { - credentialsStorage.storePassword(accountPrefix, password); - accountID.removeAccountProperty( - ProtocolProviderServiceSipImpl.XCAP_PASSWORD); - } - } - - /** - * Loads XCAP_PASSWORD property. - * - * @param accountID the AccountID corresponding to the account that we would - * like to store. - */ - private void loadXCapPassword(AccountID accountID) - { - CredentialsStorageService credentialsStorage + CredentialsStorageService credentialsStorage = ServiceUtils.getService( getBundleContext(), CredentialsStorageService.class); - String accountPrefix = accountID.getAccountUniqueID() + ".xcap"; - accountID.putAccountProperty( - ProtocolProviderServiceSipImpl.XCAP_PASSWORD, - credentialsStorage.loadPassword(accountPrefix)); + String accountPrefix = accountID.getAccountUniqueID() + ".xcap"; + credentialsStorage.storePassword(accountPrefix, (String)password); + // remove unsecured property + accountID.removeAccountProperty( + ProtocolProviderServiceSipImpl.XCAP_PASSWORD); + } } /** diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java b/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java index 5496e2f..6ca38d8 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java @@ -8,7 +8,9 @@ package net.java.sip.communicator.impl.protocol.sip; import java.util.*; +import net.java.sip.communicator.service.credentialsstorage.*; import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.*; /** * A SIP extension of the account ID property. @@ -123,4 +125,27 @@ public class SipAccountID && (getService() != null ? getService().equals(((SipAccountID)obj).getService()) : true); } + + /** + * Returns the account property string corresponding to the given key. + * If property is xcap password obtain it from credential storage. + * + * @param key the key, corresponding to the property string we're looking + * for + * @return the account property string corresponding to the given key + */ + public String getAccountPropertyString(Object key) + { + if(key.equals(ProtocolProviderServiceSipImpl.XCAP_PASSWORD)) + { + CredentialsStorageService credentialsStorage + = ServiceUtils.getService(SipActivator.getBundleContext(), + CredentialsStorageService.class); + + return credentialsStorage.loadPassword( + getAccountUniqueID() + ".xcap"); + } + else + return super.getAccountPropertyString(key); + } } |