Moved the CertificateVerificationService to its own bundle.

Moved SIPCommHTMLEditorKit and SIPCommHTMLEditorPane to the util package.
cusax-fix
Yana Stamcheva 15 years ago
parent fcfaa29301
commit 24ed71d202

@ -931,7 +931,7 @@
bundle-replacement,bundle-youtube,bundle-dailymotion,bundle-smiley,
bundle-vimeo,bundle-vbox7,bundle-metacafe,bundle-flickr,bundle-hulu,
bundle-twitpic,bundle-directimage,bundle-bliptv,bundle-viddler,
bundle-plugin-chatconfig"/>
bundle-plugin-chatconfig,bundle-certificate"/>
<!--BUNDLE-SC-LAUNCHER-->
<target name="bundle-sc-launcher">
@ -2525,4 +2525,14 @@ org.apache.http.util"/>
prefix="net/java/sip/communicator/plugin/chatconfig" />
</jar>
</target>
<target name="bundle-certificate">
<jar compress="false" destfile="${bundles.dest}/certificate.jar"
manifest="${src}/net/java/sip/communicator/impl/certificate/certificate.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/service/certificate"
prefix="net/java/sip/communicator/service/certificate" />
<zipfileset dir="${dest}/net/java/sip/communicator/impl/certificate"
prefix="net/java/sip/communicator/impl/certificate" />
</jar>
</target>
</project>

@ -51,7 +51,8 @@ felix.auto.start.45= \
reference:file:sc-bundles/argdelegation-service.jar \
reference:file:sc-bundles/version.jar \
reference:file:sc-bundles/version-impl.jar \
reference:file:sc-bundles/branding.jar
reference:file:sc-bundles/branding.jar \
reference:file:sc-bundles/certificate.jar
felix.auto.start.49= \
reference:file:sc-bundles/bouncycastle.jar \

@ -0,0 +1,128 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.certificate;
import net.java.sip.communicator.service.certificate.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.fileaccess.*;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
/**
* The certificate verification bundle activator.
*
* @author Yana Stamcheva
*/
public class CertificateVerificationActivator
implements BundleActivator
{
/**
* The bundle context for this bundle.
*/
static BundleContext bundleContext;
/**
* The configuration service.
*/
private static ConfigurationService configService;
/**
* The service giving access to files.
*/
private static FileAccessService fileAccessService;
/**
* The service giving access to all resources.
*/
private static ResourceManagementService resourcesService;
/**
* Called when this bundle is started.
*
* @param bc The execution context of the bundle being started.
* @throws Exception if the bundle is not correctly started
*/
public void start(BundleContext bc) throws Exception
{
bundleContext = bc;
bundleContext.registerService(
CertificateVerificationService.class.getName(),
new CertificateVerificationServiceImpl(),
null);
}
/**
* Called when this bundle is stopped so the Framework can perform the
* bundle-specific activities necessary to stop the bundle.
*
* @param bc The execution context of the bundle being stopped.
* @throws Exception If this method throws an exception, the bundle is
* still marked as stopped, and the Framework will remove the bundle's
* listeners, unregister all services registered by the bundle, and
* release all services used by the bundle.
*/
public void stop(BundleContext bc) throws Exception
{
}
/**
* Returns the <tt>ConfigurationService</tt> obtained from the bundle
* context.
* @return the <tt>ConfigurationService</tt> obtained from the bundle
* context
*/
public static ConfigurationService getConfigurationService()
{
if(configService == null)
{
configService
= ServiceUtils.getService(
bundleContext,
ConfigurationService.class);
}
return configService;
}
/**
* Returns the <tt>FileAccessService</tt> obtained from the bundle context.
*
* @return the <tt>FileAccessService</tt> obtained from the bundle context
*/
public static FileAccessService getFileAccessService()
{
if (fileAccessService == null)
{
fileAccessService
= ServiceUtils.getService(
bundleContext,
FileAccessService.class);
}
return fileAccessService;
}
/**
* Returns the <tt>ResourceManagementService</tt>, through which we will
* access all resources.
*
* @return the <tt>ResourceManagementService</tt>, through which we will
* access all resources.
*/
public static ResourceManagementService getResources()
{
if (resourcesService == null)
{
resourcesService
= ServiceUtils.getService(
bundleContext,
ResourceManagementService.class);
}
return resourcesService;
}
}

@ -4,7 +4,7 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.main.login;
package net.java.sip.communicator.impl.certificate;
import java.awt.*;
import java.awt.event.*;
@ -24,19 +24,17 @@
import javax.net.ssl.*;
import javax.security.auth.x500.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.service.certificate.*;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
/**
* Asks the user for permission for the
* certificates which are for some reason not valid and not globally trusted.
*
* @author Damian Minkov
* @author Yana Stamcheva
*/
public class CertificateVerificationServiceImpl
implements CertificateVerificationService
@ -88,11 +86,11 @@ public class CertificateVerificationServiceImpl
private File getKeyStoreLocation()
throws Exception
{
String keyStoreFile = GuiActivator.getConfigurationService()
.getString(KEYSTORE_FILE_PROP);
String keyStoreFile = CertificateVerificationActivator.
getConfigurationService().getString(KEYSTORE_FILE_PROP);
if(keyStoreFile == null || keyStoreFile.length() == 0)
return GuiActivator.getFileAccessService()
return CertificateVerificationActivator.getFileAccessService()
.getPrivatePersistentFile(KEY_STORE_FILE_NAME);
File f = new File(keyStoreFile);
@ -106,10 +104,10 @@ private File getKeyStoreLocation()
// An old version used to store the whole path to the file
// and if the user changes location of its home dir
// it breaks things.
GuiActivator.getConfigurationService().removeProperty(
KEYSTORE_FILE_PROP);
CertificateVerificationActivator.getConfigurationService()
.removeProperty(KEYSTORE_FILE_PROP);
return GuiActivator.getFileAccessService()
return CertificateVerificationActivator.getFileAccessService()
.getPrivatePersistentFile(KEY_STORE_FILE_NAME);
}
}
@ -211,6 +209,8 @@ public X509TrustManager getTrustManager(String toHost, int toPort)
* @param toHost the host we are connecting.
* @param toPort the port used when connecting.
* @return SSL context object
*
* @throws IOException if the SSLContext could not be initialized
*/
public SSLContext getSSLContext(String toHost, int toPort)
throws IOException
@ -351,7 +351,8 @@ private static class VerifyCertificateDialog
* which will be always trusted.
*/
SIPCommCheckBox alwaysTrustCheckBox = new SIPCommCheckBox(
GuiActivator.getResources().getI18NString("service.gui.ALWAYS_TRUST"),
CertificateVerificationActivator.getResources()
.getI18NString("service.gui.ALWAYS_TRUST"),
false);
/**
@ -361,16 +362,19 @@ private static class VerifyCertificateDialog
/**
* Creates the dialog.
* @param certs
* @param host
* @param port
*
* @param certs the certificates list
* @param host the host
* @param port the port
*/
public VerifyCertificateDialog(Certificate[] certs, String host, int port)
public VerifyCertificateDialog( Certificate[] certs,
String host,
int port)
{
super(GuiActivator.getUIService().getMainFrame(), false);
super(false);
setTitle(GuiActivator.getResources().getI18NString(
"service.gui.CERT_DIALOG_TITLE"));
setTitle(CertificateVerificationActivator.getResources()
.getI18NString("service.gui.CERT_DIALOG_TITLE"));
setModal(true);
// for now shows only the first certificate from the chain
@ -400,17 +404,17 @@ private void init()
northPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));
JLabel imgLabel = new JLabel(
GuiActivator.getResources().getImage(
CertificateVerificationActivator.getResources().getImage(
"impl.media.security.zrtp.CONF_ICON"));
imgLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
northPanel.add(imgLabel, BorderLayout.WEST);
String descriptionTxt = GuiActivator.getResources()
.getI18NString(
String descriptionTxt = CertificateVerificationActivator
.getResources().getI18NString(
"service.gui.CERT_DIALOG_DESCRIPTION_TXT",
new String[]{
GuiActivator.getResources().getSettingsString(
"service.gui.APPLICATION_NAME"),
CertificateVerificationActivator.getResources()
.getSettingsString("service.gui.APPLICATION_NAME"),
host,
String.valueOf(port)});
@ -436,8 +440,8 @@ private void init()
contentPane.add(southPanel, BorderLayout.SOUTH);
certButton = new JButton();
certButton.setText(GuiActivator.getResources()
.getI18NString("service.gui.SHOW_CERT"));
certButton.setText(CertificateVerificationActivator
.getResources().getI18NString("service.gui.SHOW_CERT"));
certButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
@ -453,7 +457,9 @@ public void actionPerformed(ActionEvent e)
TransparentPanel secondButonPanel =
new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
JButton cancelButton = new JButton(
GuiActivator.getResources().getI18NString("service.gui.CANCEL"));
CertificateVerificationActivator.getResources()
.getI18NString("service.gui.CANCEL"));
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
@ -462,7 +468,9 @@ public void actionPerformed(ActionEvent e)
}
});
JButton continueButton = new JButton(
GuiActivator.getResources().getI18NString("service.gui.CONTINUE"));
CertificateVerificationActivator.getResources()
.getI18NString("service.gui.CONTINUE"));
continueButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
@ -487,8 +495,9 @@ private void actionShowCertificate()
if(certOpened)
{
certPanel.removeAll();
certButton.setText(GuiActivator.getResources()
.getI18NString("service.gui.SHOW_CERT"));
certButton.setText(
CertificateVerificationActivator.getResources()
.getI18NString("service.gui.SHOW_CERT"));
certPanel.revalidate();
certPanel.repaint();
@ -527,9 +536,10 @@ public void run()
}
});
certButton.setText(GuiActivator.getResources()
.getI18NString("service.gui.HIDE_CERT"));
certButton.setText(
CertificateVerificationActivator.getResources()
.getI18NString("service.gui.HIDE_CERT"));
certPanel.revalidate();
certPanel.repaint();
// restore default values for prefered size,
@ -569,9 +579,10 @@ protected void close(boolean isEscaped)
}
/**
* Returns the display component for X509 certificate.
*
* @param certificate
* @return
* @param certificate the certificate to show
* @return the created component
*/
private static Component getX509DisplayComponent(
X509Certificate certificate)
@ -579,10 +590,11 @@ private static Component getX509DisplayComponent(
Insets valueInsets = new Insets(2,10,0,0);
Insets titleInsets = new Insets(10,5,0,0);
ResourceManagementService resources = GuiActivator.getResources();
ResourceManagementService resources
= CertificateVerificationActivator.getResources();
TransparentPanel certDisplayPanel =
new TransparentPanel(new GridBagLayout());
TransparentPanel certDisplayPanel
= new TransparentPanel(new GridBagLayout());
int currentRow = 0;
@ -1016,9 +1028,10 @@ private class HostTrustManager
/**
* Not used.
* @return
* @return UnsupportedOperationException
*/
public X509Certificate[] getAcceptedIssuers() {
public X509Certificate[] getAcceptedIssuers()
{
throw new UnsupportedOperationException();
}
@ -1044,16 +1057,20 @@ public void checkClientTrusted(X509Certificate[] chain, String authType)
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException
{
if(GuiActivator.getConfigurationService().getBoolean(
CertificateVerificationService.ALWAYS_TRUST_MODE_ENABLED_PROP_NAME,
false))
return;
if(CertificateVerificationActivator.getConfigurationService()
.getBoolean(CertificateVerificationService
.ALWAYS_TRUST_MODE_ENABLED_PROP_NAME,
false))
{
return;
}
try
{
tm.checkServerTrusted(chain, authType);
// everything is fine certificate is globally trusted
} catch (CertificateException certificateException)
}
catch (CertificateException certificateException)
{
KeyStore kStore = getKeyStore();

@ -0,0 +1,18 @@
Bundle-Activator: net.java.sip.communicator.impl.certificate.CertificateVerificationActivator
Bundle-Name: Certificate Verification Activator
Bundle-Description: A bundle that offers certificate verification
Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
System-Bundle: yes
Export-Package: net.java.sip.communicator.service.certificate
Import-Package: org.osgi.framework,
net.java.sip.communicator.util,
net.java.sip.communicator.service.resources,
net.java.sip.communicator.service.fileaccess,
net.java.sip.communicator.service.configuration,
net.java.sip.communicator.util.swing,
javax.net.ssl,
javax.security.auth.x500,
javax.naming,
javax.naming.ldap,
javax.swing

@ -138,11 +138,6 @@ public void start(BundleContext bContext)
(ShutdownService) uiService,
null);
bundleContext.registerService(
CertificateVerificationService.class.getName(),
new CertificateVerificationServiceImpl(),
null);
logger.logEntry();
}
finally

@ -231,7 +231,7 @@ private ImageIcon getProtocolIcon(ProtocolProviderService protocolProvider)
{
ProtocolIcon protocolIcon = protocolProvider.getProtocolIcon();
Image protocolImage
= GuiUtils.getBytesInImage(
= ImageUtils.getBytesInImage(
protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_32x32));
if (protocolImage != null)
@ -240,12 +240,12 @@ private ImageIcon getProtocolIcon(ProtocolProviderService protocolProvider)
}
else
{
protocolImage = GuiUtils.getBytesInImage(
protocolImage = ImageUtils.getBytesInImage(
protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_48x48));
if (protocolImage == null)
protocolImage
= GuiUtils.getBytesInImage(
= ImageUtils.getBytesInImage(
protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_64x64));
if (protocolImage != null)

@ -161,7 +161,7 @@ public Image createTransportStatusImage(ChatTransport chatTransport)
{
return
ImageLoader.badgeImageWithProtocolIndex(
GuiUtils.getBytesInImage(
ImageUtils.getBytesInImage(
chatTransport.getStatus().getStatusIcon()),
chatTransport.getProtocolProvider());
}

@ -461,7 +461,7 @@ else if (value instanceof ProtocolProviderService)
if (provider != null)
{
Image protocolImg
= GuiUtils.getBytesInImage(provider.getProtocolIcon()
= ImageUtils.getBytesInImage(provider.getProtocolIcon()
.getIcon(ProtocolIcon.ICON_SIZE_16x16));
if (protocolImg != null)

@ -753,7 +753,7 @@ public Image createContactStatusImage(Contact protoContact)
{
return
ImageLoader.badgeImageWithProtocolIndex(
GuiUtils.getBytesInImage(
ImageUtils.getBytesInImage(
protoContact.getPresenceStatus().getStatusIcon()),
protoContact.getProtocolProvider());
}

@ -40,17 +40,24 @@ public class SimpleStatusMenu
/**
* Creates an instance of <tt>SimpleStatusMenu</tt>.
*
* @param protocolProvider The protocol provider.
* @param protocolProvider the protocol provider
*/
public SimpleStatusMenu(ProtocolProviderService protocolProvider)
{
this(protocolProvider,
protocolProvider.getAccountID().getDisplayName(),
GuiUtils.getBytesInImage(
ImageUtils.getBytesInImage(
protocolProvider.getProtocolIcon().getIcon(
ProtocolIcon.ICON_SIZE_16x16)));
}
/**
* Creates an instance of <tt>SimpleStatusMenu</tt>.
*
* @param protocolProvider the protocol provider
* @param displayName the display name for the menu
* @param onlineImage the image used for the online state
*/
private SimpleStatusMenu(ProtocolProviderService protocolProvider,
String displayName,
Image onlineImage)
@ -167,13 +174,13 @@ public void updateStatus()
public void loadSkin()
{
super.loadSkin();
setIcon(new ImageIcon(GuiUtils.getBytesInImage(
setIcon(new ImageIcon(ImageUtils.getBytesInImage(
protocolProvider.getProtocolIcon().getIcon(
ProtocolIcon.ICON_SIZE_16x16))));
onlineItem.setIcon(getIcon());
offlineItem.setIcon(
new ImageIcon(LightGrayFilter.createDisabledImage(
GuiUtils.getBytesInImage(
ImageUtils.getBytesInImage(
protocolProvider.getProtocolIcon().getIcon(
ProtocolIcon.ICON_SIZE_16x16)))));
}

@ -1305,13 +1305,13 @@ public static ImageIcon getAccountStatusImage(ProtocolProviderService pps)
Image statusImage;
if (presence != null)
{
statusImage = GuiUtils.getBytesInImage(
statusImage = ImageUtils.getBytesInImage(
presence.getPresenceStatus().getStatusIcon());
}
else
{
statusImage
= GuiUtils.getBytesInImage(pps.getProtocolIcon().getIcon(
= ImageUtils.getBytesInImage(pps.getProtocolIcon().getIcon(
ProtocolIcon.ICON_SIZE_16x16));
if (!pps.isRegistered())
@ -1427,10 +1427,10 @@ public static ImageIcon getAuthenticationWindowIcon(
ProtocolIcon protocolIcon = protocolProvider.getProtocolIcon();
if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_64x64))
image = GuiUtils.getBytesInImage(
image = ImageUtils.getBytesInImage(
protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_64x64));
else if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_48x48))
image = GuiUtils.getBytesInImage(
image = ImageUtils.getBytesInImage(
protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_48x48));
}

@ -20,7 +20,7 @@
import net.java.sip.communicator.impl.protocol.jabber.extensions.jingle.*;
import net.java.sip.communicator.impl.protocol.jabber.extensions.inputevt.*;
import net.java.sip.communicator.impl.protocol.jabber.sasl.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.certificate.*;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.packet.*;

@ -15,7 +15,7 @@
import gov.nist.core.net.*;
import net.java.sip.communicator.impl.protocol.sip.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.certificate.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;

@ -38,7 +38,7 @@ Import-Package: org.apache.log4j,
net.java.sip.communicator.service.configuration,
net.java.sip.communicator.service.credentialsstorage,
net.java.sip.communicator.service.configuration.event,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.certificate,
net.java.sip.communicator.service.neomedia,
net.java.sip.communicator.service.neomedia.device,
net.java.sip.communicator.service.neomedia.event,

@ -4,7 +4,7 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.service.gui;
package net.java.sip.communicator.service.certificate;
import java.io.*;
import java.security.*;

@ -9,10 +9,8 @@
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.io.*;
import java.util.*;
import javax.imageio.*;
import javax.swing.*;
/**
@ -25,11 +23,6 @@
*/
public class GuiUtils
{
/**
* The logger for this class.
*/
private static Logger logger = Logger.getLogger(GuiUtils.class);
/**
* List of all windows owned by the app.
*/
@ -505,25 +498,4 @@ else if (c instanceof java.awt.Container)
}
}
}
/**
* Loads an image from a given bytes array.
* @param imageBytes The bytes array to load the image from.
* @return The image for the given bytes array.
*/
public static Image getBytesInImage(byte[] imageBytes)
{
Image image = null;
try
{
image = ImageIO.read(
new ByteArrayInputStream(imageBytes));
}
catch (Exception e)
{
logger.error("Failed to convert bytes to image.", e);
}
return image;
}
}

@ -283,7 +283,9 @@ else if (source instanceof BufferedImage)
int width = source.getWidth(null);
int height = source.getHeight(null);
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
BufferedImage image
= new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics graphics = image.createGraphics();
graphics.drawImage(source, 0, 0, null);
graphics.dispose();
@ -311,4 +313,25 @@ public static byte[] toByteArray(BufferedImage image)
return out.toByteArray();
}
/**
* Loads an image from a given bytes array.
* @param imageBytes The bytes array to load the image from.
* @return The image for the given bytes array.
*/
public static Image getBytesInImage(byte[] imageBytes)
{
Image image = null;
try
{
image = ImageIO.read(
new ByteArrayInputStream(imageBytes));
}
catch (Exception e)
{
logger.error("Failed to convert bytes to image.", e);
}
return image;
}
}

@ -5,7 +5,7 @@
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.utils;
package net.java.sip.communicator.util.swing;
import java.awt.*;
@ -24,6 +24,12 @@ public class SIPCommHTMLEditorKit extends HTMLEditorKit
{
private final JComponent container;
/**
* Creates an instance of <tt>SIPCommHTMLEditorKit</tt> by specifying the
* container, where the editor kit would be used.
*
* @param container
*/
public SIPCommHTMLEditorKit(JComponent container)
{
this.container = container;
@ -31,6 +37,8 @@ public SIPCommHTMLEditorKit(JComponent container)
/**
* Returns the extended <tt>HTMLFactory</tt> defined here.
*
* @return the extended view factory
*/
public ViewFactory getViewFactory()
{
@ -62,6 +70,10 @@ else if (view instanceof ComponentView)
}
}
/**
* An extended component view, which provides horizontal and vertical
* filling.
*/
private class MyComponentView extends ComponentView
{
/**
@ -153,6 +165,11 @@ public float getMaximumSpan(int axis)
*/
static class ParagraphViewX extends ParagraphView
{
/**
* Creates an instance of <tt>ParagraphViewX</tt>.
*
* @param elem the element that this view is responsible for
*/
public ParagraphViewX(Element elem)
{
super(elem);
@ -163,6 +180,10 @@ public ParagraphViewX(Element elem)
* is implemented to forward the request to the logical
* view by calling getMinimumSpan, getPreferredSpan, and
* getMaximumSpan on it.
*
* @param axis the axis, for which we calculate size requirements
* @param sizeRequirements the initial size requirements
* @return the recalculated size requirements for the given axis
*/
protected SizeRequirements calculateMinorAxisRequirements (
int axis, SizeRequirements sizeRequirements)

@ -4,7 +4,7 @@
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.impl.gui.customcontrols;
package net.java.sip.communicator.util.swing;
import java.io.*;
@ -12,20 +12,39 @@
import javax.swing.text.*;
import javax.swing.text.html.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.util.*;
/**
* A custom styled HTML editor pane.
*
* @author Yana Stamcheva
*/
public class StyledHTMLEditorPane
extends JEditorPane
{
/**
* The serial version id.
*/
private static final long serialVersionUID = 1L;
/**
* The logger for this class.
*/
private final Logger logger = Logger.getLogger(StyledHTMLEditorPane.class);
/**
* The editor kit of this editor pane.
*/
private final HTMLEditorKit editorKit;
/**
* The document of this editor pane.
*/
private final HTMLDocument document;
/**
* Creates an instance of <tt>StyledHTMLEditorPane</tt>.
*/
public StyledHTMLEditorPane()
{
editorKit = new SIPCommHTMLEditorKit(this);
@ -38,14 +57,18 @@ public StyledHTMLEditorPane()
this.setDocument(document);
putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
Constants.loadSimpleStyle(document.getStyleSheet(), getFont());
}
/**
* Appends text to end of the editor pane.
*
* @param text the text to append
*/
public void appendToEnd(String text)
{
Element root = document.getDefaultRootElement();
try
{
{
document.insertAfterEnd(root
.getElement(root.getElementCount() - 1), text);
}
@ -58,17 +81,27 @@ public void appendToEnd(String text)
logger.error("Insert in the HTMLDocument failed.", e);
}
}
/**
* Inserts the given text in the beginning of the editor pane.
*
* @param text the text to insert
*/
public void insertAfterStart(String text)
{
Element root = this.document.getDefaultRootElement();
try {
try
{
this.document.insertBeforeStart(root
.getElement(0), text);
} catch (BadLocationException e) {
.getElement(0), text);
}
catch (BadLocationException e)
{
logger.error("Insert in the HTMLDocument failed.", e);
} catch (IOException e) {
}
catch (IOException e)
{
logger.error("Insert in the HTMLDocument failed.", e);
}
}

@ -10,14 +10,19 @@
import org.osgi.framework.*;
import junit.framework.*;
import net.java.sip.communicator.service.certificate.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
/**
* Test for account installation.
*
* @author Damian Minkov
* @author Valentin Martinet
*/
public class TestAccountInstallation
extends TestCase
{
/**
* Creates the test with the specified method name.
* @param name the name of the method to execute.
@ -73,7 +78,9 @@ public void testInstallAccount()
= JabberSlickFixture.bc.getServiceReference(
ConfigurationService.class.getName());
ConfigurationService configurationService
= (ConfigurationService) JabberSlickFixture.bc.getService(confReference);
= (ConfigurationService) JabberSlickFixture.
bc.getService(confReference);
configurationService.setProperty(
CertificateVerificationService.ALWAYS_TRUST_MODE_ENABLED_PROP_NAME,
Boolean.TRUE);
@ -90,12 +97,15 @@ public void testInstallAccount()
//Prepare the properties of the first jabber account.
Hashtable<String, String> jabberAccount1Properties = getAccountProperties(
JabberProtocolProviderServiceLick.ACCOUNT_1_PREFIX);
Hashtable<String, String> jabberAccount2Properties = getAccountProperties(
JabberProtocolProviderServiceLick.ACCOUNT_2_PREFIX);
Hashtable<String, String> jabberAccount3Properties = getAccountProperties(
JabberProtocolProviderServiceLick.ACCOUNT_3_PREFIX);
Hashtable<String, String> jabberAccount1Properties
= getAccountProperties(
JabberProtocolProviderServiceLick.ACCOUNT_1_PREFIX);
Hashtable<String, String> jabberAccount2Properties
= getAccountProperties(
JabberProtocolProviderServiceLick.ACCOUNT_2_PREFIX);
Hashtable<String, String> jabberAccount3Properties
= getAccountProperties(
JabberProtocolProviderServiceLick.ACCOUNT_3_PREFIX);
//try to install an account with a null account id
try{
@ -212,8 +222,9 @@ private Hashtable<String, String> getAccountProperties(String accountPrefix)
table.put(ProtocolProviderFactory.PASSWORD, passwd);
String serverAddress = System.getProperty(
accountPrefix + ProtocolProviderFactory.SERVER_ADDRESS, null);
String serverAddress
= System.getProperty(accountPrefix
+ ProtocolProviderFactory.SERVER_ADDRESS, null);
// optional
if(serverAddress != null)

Loading…
Cancel
Save