[jitsi-dev] Stored password desynchronization on account load


#1

Hi all,

I don't know if currently someone is working on forgotten passwords
problem, but I've been able to reproduce one issue on Android.

When the account is loaded using following code in AccountManager.loadAccount():
if(providerFactory.loadAccount(accountID))
    {
        accountID.putAccountProperty(
            ProtocolProviderFactory.IS_ACCOUNT_DISABLED,
            String.valueOf(false));
        // Finally store the modified properties.
        storeAccount(providerFactory, accountID);
    }

When protocolFactory.loadAccount is fired it registers protocol
provider and starts connecting process in another thread(I'm not sure
if it's the same on desktop).

Then it comes to storeAccount code. In this function there is
inconsistency about storing password. Each time account is stored at
first the password is removed here:

// clear the password if missing property, modification can request
// password delete
if(!accountProperties.containsKey(ProtocolProviderFactory.PASSWORD))
{
    CredentialsStorageService credentialsStorage
        = ServiceUtils.getService(
                bundleContext,
                CredentialsStorageService.class);
    credentialsStorage.removePassword(
        factoryPackage + "." + accountNodeName);
}

And just after that it is restored directly through configuration
property ENCRYPTED_PASSWORD contained in configurationProperties:

if (configurationProperties.size() > 0)
    configurationService.setProperties(configurationProperties);

On my tablet when I switch the account on/off it seems to be
forgetting the password, because connecting phase is executed after
the password is removed, but before the property is restored.

I can't easily repoduce it only PC, because it stores the properties
much faster. So in order to fix it I also check if ENCRYPTED_PASSWORD
is contained in configurationProperties, before removing the password.
I'll commit this change soon after some more tests.

Regards,
Pawel