Store STUN password via credentials storage service.

cusax-fix
Sebastien Vincent 16 years ago
parent 9d1cd93f42
commit 4009ab1741

@ -1655,6 +1655,8 @@ private class CloseButton
extends Label
implements MouseListener
{
private static final long serialVersionUID = 0L;
Image image = ImageLoader.getImage(ImageLoader.CLOSE_VIDEO);
public CloseButton()

@ -351,7 +351,7 @@ public void setPriority(MediaFormat encoding, int priority)
* by associating it with a property name/key based on encoding and
* clock rate only, it does not make sense to store the MediaFormat in
* encodingPreferences because MediaFormat is much more specific than
* just encoding and clock rate.
* just encoding and clock rate.
*/
setEncodingPreference(
encodingEncoding, encoding.getClockRate(),

@ -11,6 +11,7 @@
import org.osgi.framework.*;
import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.service.credentialsstorage.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
@ -24,6 +25,9 @@ public class JabberAccRegWizzActivator
implements BundleActivator
{
/**
* The OSGi bundle context.
*/
public static BundleContext bundleContext;
private static final Logger logger =
@ -31,6 +35,8 @@ public class JabberAccRegWizzActivator
private static BrowserLauncherService browserLauncherService;
private static CredentialsStorageService credentialsService = null;
private static WizardContainer wizardContainer;
private static JabberAccountRegistrationWizard jabberWizard;
@ -103,22 +109,24 @@ public static ProtocolProviderFactory getJabberProtocolProviderFactory()
/**
* Returns the <tt>UIService</tt>.
*
*
* @return the <tt>UIService</tt>
*/
public static UIService getUIService()
{
return uiService;
}
/**
* Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
* context.
* @return the <tt>BrowserLauncherService</tt> obtained from the bundle
* context
*/
public static BrowserLauncherService getBrowserLauncher() {
if (browserLauncherService == null) {
public static BrowserLauncherService getBrowserLauncher()
{
if (browserLauncherService == null)
{
ServiceReference serviceReference = bundleContext
.getServiceReference(BrowserLauncherService.class.getName());
@ -128,4 +136,24 @@ public static BrowserLauncherService getBrowserLauncher() {
return browserLauncherService;
}
/**
* Returns the <tt>CredentialsStorageService</tt> obtained from the bundle
* context.
* @return the <tt>CredentialsStorageService</tt> obtained from the bundle
* context
*/
public static CredentialsStorageService getCredentialsService()
{
if (credentialsService == null)
{
ServiceReference serviceReference = bundleContext
.getServiceReference(CredentialsStorageService.class.getName());
credentialsService = (CredentialsStorageService)bundleContext
.getService(serviceReference);
}
return credentialsService;
}
}

@ -574,7 +574,8 @@ public void setUseUPNP(boolean isUseUPNP)
/**
* Is resource auto generate enabled.
* @return
*
* @return true if resource is auto generated
*/
public boolean isResourceAutogenerated()
{

@ -6,6 +6,7 @@
import javax.swing.*;
import net.java.sip.communicator.service.credentialsstorage.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.swing.*;
@ -380,6 +381,14 @@ public void loadAccount(AccountID accountID)
if (stunServer == null)
break;
String stunPassword = loadStunPassword(accountID,
ProtocolProviderFactory.STUN_PREFIX + i);
if(stunPassword != null)
{
stunServer.setPassword(stunPassword);
}
iceConfigPanel.addStunServer(stunServer);
}
@ -536,4 +545,40 @@ protected String getHomeLinkLabel()
{
return wizard.getHomeLinkLabel();
}
/**
* Load password for this STUN descriptor.
*
* @param accountID account ID
* @param namePrefix name prefix
* @return password or null if empty
*/
private static String loadStunPassword(AccountID accountID,
String namePrefix)
{
ProtocolProviderFactory providerFactory =
JabberAccRegWizzActivator.getJabberProtocolProviderFactory();
String password = null;
String className = providerFactory.getClass().getName();
String packageSourceName = className.substring(0, className.lastIndexOf('.'));
String accountPrefix = ProtocolProviderFactory.findAccountPrefix(
JabberAccRegWizzActivator.bundleContext,
accountID, packageSourceName);
CredentialsStorageService credentialsService =
JabberAccRegWizzActivator.getCredentialsService();
try
{
password = credentialsService.
loadPassword(accountPrefix + "." + namePrefix);
}
catch(Exception e)
{
return null;
}
return password;
}
}

@ -361,10 +361,10 @@ protected ProtocolProviderService installAccount(
ProtocolProviderFactory.AUTO_DISCOVER_JINGLE_NODES,
String.valueOf(registration.isAutoDiscoverJingleNodes()));
serverIndex = -1;
List<JingleNodeDescriptor> jnRelays
List<JingleNodeDescriptor> jnRelays
= registration.getAdditionalJingleNodes();
serverIndex = -1;
for(JingleNodeDescriptor jnRelay : jnRelays)
{
serverIndex ++;

@ -8,6 +8,7 @@ Export-package: net.java.sip.communicator.plugin.jabberaccregwizz
Import-Package: org.osgi.framework,
net.java.sip.communicator.service.browserlauncher,
net.java.sip.communicator.service.configuration,
net.java.sip.communicator.service.credentialsstorage,
net.java.sip.communicator.service.contactlist,
net.java.sip.communicator.service.contactlist.event,
net.java.sip.communicator.service.fileaccess,

@ -582,21 +582,32 @@ public void storeAccount(
{
String property = entry.getKey();
String value = entry.getValue();
String secureStorePrefix = null;
// If the property is a password, store it securely.
if (property.equals(ProtocolProviderFactory.PASSWORD))
{
CredentialsStorageService credentialsStorage
= ServiceUtils.getService(
bundleContext,
CredentialsStorageService.class);
String accountPrefix = factoryPackage + "." + accountNodeName;
secureStorePrefix = accountPrefix;
}
else if(property.endsWith("." + ProtocolProviderFactory.PASSWORD))
{
secureStorePrefix = factoryPackage + "." + accountNodeName +
"." + property.substring(0, property.lastIndexOf("."));
}
if(secureStorePrefix != null)
{
CredentialsStorageService credentialsStorage
= ServiceUtils.getService(
bundleContext,
CredentialsStorageService.class);
// encrypt and store
if ((value != null)
&& (value.length() != 0)
&& !credentialsStorage.storePassword(
accountPrefix,
secureStorePrefix,
value))
{
throw

@ -208,7 +208,11 @@ public void storeDescriptor(Map<String, String> props, String namePrefix)
StringUtils.getUTF8String(getUsername()));
if (getPassword() != null && getPassword().length > 0)
props.put(namePrefix + STUN_PASSWORD, new String(getPassword()));
{
//props.put(namePrefix + STUN_PASSWORD, new String(getPassword()));
props.put(namePrefix + "." + STUN_PASSWORD,
new String(getPassword()));
}
props.put(namePrefix + STUN_IS_TURN_SUPPORTED,
Boolean.toString( isTurnSupported() ));

Loading…
Cancel
Save