diff --git a/lib/installer-exclude/libjitsi.jar b/lib/installer-exclude/libjitsi.jar index 5c659ad7b..aad00a5c8 100644 Binary files a/lib/installer-exclude/libjitsi.jar and b/lib/installer-exclude/libjitsi.jar differ diff --git a/src/net/java/sip/communicator/impl/configuration/JdbcConfigService.java b/src/net/java/sip/communicator/impl/configuration/JdbcConfigService.java index e75068b70..d2905039c 100644 --- a/src/net/java/sip/communicator/impl/configuration/JdbcConfigService.java +++ b/src/net/java/sip/communicator/impl/configuration/JdbcConfigService.java @@ -354,7 +354,7 @@ public synchronized void removeProperty(String propertyName) //remove all properties for (String child : this.getPropertyNamesByPrefix(propertyName, false)) { - removeProperty(child); + this.setProperty(child, null, false); } this.setProperty(propertyName, null, false); @@ -411,15 +411,17 @@ public List getPropertyNamesByPrefix(String prefix, while (q.next()) { String key = q.getString(1); - int ix = key.lastIndexOf('.'); - if(ix == -1) - { - continue; - } - String keyPrefix = key.substring(0, ix); if(exactPrefixMatch) { + int ix = key.lastIndexOf('.'); + if(ix == -1) + { + continue; + } + + String keyPrefix = key.substring(0, ix); + if(prefix.equals(keyPrefix)) { resultSet.add(key); @@ -427,7 +429,7 @@ public List getPropertyNamesByPrefix(String prefix, } else { - if(keyPrefix.startsWith(prefix)) + if(key.startsWith(prefix)) { resultSet.add(key); } @@ -772,7 +774,6 @@ public String getConfigurationFilename() { return "props.hsql.script"; } - /** * Loads the specified default properties maps from the Jitsi installation diff --git a/src/net/java/sip/communicator/plugin/desktoputil/presence/AbstractStatusMessageMenu.java b/src/net/java/sip/communicator/plugin/desktoputil/presence/AbstractStatusMessageMenu.java index 227294053..97946c321 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/presence/AbstractStatusMessageMenu.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/presence/AbstractStatusMessageMenu.java @@ -536,9 +536,13 @@ private int getLastCustomStatusMessageIndex() DesktopUtilActivator.getConfigurationService() .getPropertyNamesByPrefix(CUSTOM_MESSAGES_PREFIX, false); + int prefixLen = CUSTOM_MESSAGES_PREFIX.length() + 1; for(String p : customMessagesProps) { - String s = p.substring(CUSTOM_MESSAGES_PREFIX.length() + 1); + if(prefixLen > p.length()) + continue; + + String s = p.substring(prefixLen); try { diff --git a/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/SavedPasswordsDialog.java b/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/SavedPasswordsDialog.java index 42837801f..cbebc43f7 100644 --- a/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/SavedPasswordsDialog.java +++ b/src/net/java/sip/communicator/plugin/securityconfig/masterpassword/SavedPasswordsDialog.java @@ -485,7 +485,7 @@ private void initContent() protocol, accID.getUserID())); } - + for(Map.Entry entry : SecurityConfigActivator.getChatRoomsWithSavedPasswords() .entrySet()) @@ -498,7 +498,7 @@ private void initContent() resources.getI18NString("service.gui.CHAT_ROOM"), description)); } - + // load provisioning passwords String PROVISIONING_PROPERTIES_PREFIX = "net.java.sip.communicator.plugin.provisioning.auth"; @@ -523,17 +523,18 @@ private void initContent() configurationService.getPropertyNamesByPrefix( HTTP_PROPERTIES_PREFIX, false); + int prefLen = HTTP_PROPERTIES_PREFIX.length() + 1; for(String prop: httpPasses) { // we skip the entry containing the encoded password - if(prop.contains("PASSWORD")) + if(prop.contains("PASSWORD") + || prefLen > prop.length()) continue; model.savedPasswords.add( new PasswordsTableRow( prop, - "http://" + prop.substring( - HTTP_PROPERTIES_PREFIX.length() + 1), + "http://" + prop.substring(prefLen), configurationService.getString(prop))); } } diff --git a/src/net/java/sip/communicator/service/protocol/AccountManager.java b/src/net/java/sip/communicator/service/protocol/AccountManager.java index b7b977389..9f0f21143 100644 --- a/src/net/java/sip/communicator/service/protocol/AccountManager.java +++ b/src/net/java/sip/communicator/service/protocol/AccountManager.java @@ -151,6 +151,7 @@ private void doLoadStoredAccounts(ProtocolProviderFactory factory) bundleContext, CredentialsStorageService.class); + int prefLen = storedAccount.length() + 1; for (Iterator storedAccountPropertyIter = storedAccountProperties.iterator(); storedAccountPropertyIter.hasNext();) @@ -159,7 +160,10 @@ private void doLoadStoredAccounts(ProtocolProviderFactory factory) String value = configService.getString(property); //strip the package prefix - property = property.substring(storedAccount.length() + 1); + if(prefLen > property.length()) + continue; + + property = property.substring(prefLen); if (ProtocolProviderFactory.IS_ACCOUNT_DISABLED.equals(property)) disabled = Boolean.parseBoolean(value); diff --git a/test/net/java/sip/communicator/slick/configuration/TestConfigurationService.java b/test/net/java/sip/communicator/slick/configuration/TestConfigurationService.java index 1cccd8c83..b5fe9b5b5 100644 --- a/test/net/java/sip/communicator/slick/configuration/TestConfigurationService.java +++ b/test/net/java/sip/communicator/slick/configuration/TestConfigurationService.java @@ -153,6 +153,57 @@ public void testSetGetProperty() throws PropertyVetoException property, actualReturn); } + /** + * Tests whether removing and getting properties works correctly. + * @throws PropertyVetoException in case someone wrongfully vetoes the + * property change. + */ + public void testRemoveProperty() throws PropertyVetoException + { + String propertyName = "my.test.property.acc1234"; + Object property = new String("my.test.property's value"); + configurationService.setProperty(propertyName, property); + + Object actualReturn = configurationService.getProperty(propertyName); + assertEquals("a property was not properly stored", + property, actualReturn); + + configurationService.removeProperty(propertyName); + Object actualReturn2 = configurationService.getProperty(propertyName); + + assertNull("a property was not properly removed", + actualReturn2); + } + + /** + * Tests whether removing and getting properties works correctly. + * @throws PropertyVetoException in case someone wrongfully vetoes the + * property change. + */ + public void testRemovePrefixedProperty() throws PropertyVetoException + { + // this one is used in provisioning, if we have account info like: + // net.java.sip.communicator.impl.protocol.sip.acc1sip1322067404000=acc1sip1322067404000 + // we need to remove it by provisioning this: + // net.java.sip.communicator.impl.protocol.sip.acc1sip=${null} + + String propertyName = "my.test.property.acc1234"; + String propertyPrefixName = "my.test.property.acc"; + + Object property = new String("my.test.property's value"); + configurationService.setProperty(propertyName, property); + + Object actualReturn = configurationService.getProperty(propertyName); + assertEquals("a property was not properly stored", + property, actualReturn); + + configurationService.removeProperty(propertyPrefixName); + Object actualReturn2 = configurationService.getProperty(propertyName); + + assertNull("a property was not properly removed by prefix", + actualReturn2); + } + /** * Tests whether setting and getting works alright for properties declared * as system and whether resolving and retrieving from the system property