Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugene Tarassov2011-11-11 18:51:51 +0000
committerEugene Tarassov2011-11-11 18:51:51 +0000
commit9587c5ddf0b78aa00883d5cac15ce23dd116df9e (patch)
treed1f1e47b0fb5950ba40881d82f2c4a5f3bb1cfca /plugins/org.eclipse.tm.tcf/src/org/eclipse/tm
parentf8bdfbc8174a8255d41b8e03183aab2205304243 (diff)
downloadorg.eclipse.tcf-9587c5ddf0b78aa00883d5cac15ce23dd116df9e.tar.gz
org.eclipse.tcf-9587c5ddf0b78aa00883d5cac15ce23dd116df9e.tar.xz
org.eclipse.tcf-9587c5ddf0b78aa00883d5cac15ce23dd116df9e.zip
TCF Java package names changed: org.eclipse.tm.tcf.* -> org.eclipse.tcf.*
Diffstat (limited to 'plugins/org.eclipse.tm.tcf/src/org/eclipse/tm')
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/Activator.java159
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/EventQueue.java129
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfAbstractExtensionPointManager.java202
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfExtensionPointComparator.java67
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfExtensionProxy.java123
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/extensions/TcfServiceProvidersExtensionPointManager.java67
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/nls/TcfPluginMessages.java37
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/nls/TcfPluginMessages.properties18
-rw-r--r--plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/ssl/TCFSecurityManager.java231
9 files changed, 0 insertions, 1033 deletions
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/Activator.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/Activator.java
deleted file mode 100644
index a106d9c42..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/Activator.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.tcf;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tm.tcf.internal.extensions.TcfServiceProvidersExtensionPointManager;
-import org.eclipse.tm.tcf.core.ChannelTCP;
-import org.eclipse.tm.tcf.protocol.ILogger;
-import org.eclipse.tm.tcf.protocol.Protocol;
-import org.eclipse.tm.tcf.ssl.TCFSecurityManager;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends Plugin {
-
- public static final String PLUGIN_ID = "org.eclipse.tm.tcf"; //$NON-NLS-1$
-
- private static Activator plugin;
- private static boolean debug;
- private static final EventQueue queue = new EventQueue();
- private static final BundleListener bundle_listener = new BundleListener() {
- private boolean started = false;
- public void bundleChanged(BundleEvent event) {
- if (plugin != null && !started && event.getBundle() == plugin.getBundle() &&
- plugin.getBundle().getState() == Bundle.ACTIVE) {
- queue.start();
- started = true;
- }
- }
- };
-
- /** Eclipse tracing option, plug-in wide */
- private static boolean TRACE;
-
- /**
- * Constructor.
- */
- public Activator() {
- plugin = this;
- }
-
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- debug = Platform.inDebugMode();
-
- TRACE = "true".equals(Platform.getDebugOption("org.eclipse.tm.tcf/debug")); //$NON-NLS-1$
- if (TRACE && "true".equals(Platform.getDebugOption("org.eclipse.tm.tcf/debug/discovery"))) {
- System.setProperty("org.eclipse.tm.tcf.core.tracing.discovery", "true");
- }
-
- ChannelTCP.setSSLContext(TCFSecurityManager.createSSLContext());
- Protocol.setLogger(new ILogger() {
-
- public void log(String msg, Throwable x) {
- // Normally, we hook the TCF logging service (ILogger) to the
- // Plug-in logger. Trace hooks in the code use the TCF logger.
- // The Plug-in logger isn't really designed for large amounts of
- // trace data, though, so redirect to stdout when tracing is
- // enabled.
- if (TRACE) {
- System.out.println(msg);
- if (x != null) x.printStackTrace();
- }
- else {
- if (debug) {
- System.err.println(msg);
- if (x != null) x.printStackTrace();
- }
- if (plugin != null && getLog() != null) {
- getLog().log(new Status(IStatus.ERROR,
- getBundle().getSymbolicName(), IStatus.OK, msg, x));
- }
- }
- }
- });
- Protocol.setEventQueue(queue);
- Protocol.invokeLater(new Runnable() {
- public void run() {
- runTCFStartup();
- }
- });
- context.addBundleListener(bundle_listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- context.removeBundleListener(bundle_listener);
- queue.shutdown();
- plugin = null;
- super.stop(context);
- }
-
- private void runTCFStartup() {
- try {
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(PLUGIN_ID, "startup"); //$NON-NLS-1$
- IExtension[] extensions = point.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- try {
- Bundle bundle = Platform.getBundle(extensions[i].getNamespaceIdentifier());
- bundle.start(Bundle.START_TRANSIENT);
- IConfigurationElement[] e = extensions[i].getConfigurationElements();
- for (int j = 0; j < e.length; j++) {
- String nm = e[j].getName();
- if (nm.equals("class")) { //$NON-NLS-1$
- Class<?> c = bundle.loadClass(e[j].getAttribute("name")); //$NON-NLS-1$
- Class.forName(c.getName(), true, c.getClassLoader());
- }
- }
- }
- catch (Throwable x) {
- Protocol.log("TCF startup error", x); //$NON-NLS-1$
- }
- }
- }
- catch (Exception x) {
- Protocol.log("TCF startup error", x); //$NON-NLS-1$
- }
-
- // Register service providers contributed via Eclipse extension point
- TcfServiceProvidersExtensionPointManager.getInstance().registerServiceProviders();
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/EventQueue.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/EventQueue.java
deleted file mode 100644
index e24f7a73d..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/EventQueue.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2010 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.tcf;
-
-import java.util.LinkedList;
-
-import org.eclipse.core.runtime.jobs.IJobChangeEvent;
-import org.eclipse.core.runtime.jobs.IJobChangeListener;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.tm.tcf.protocol.IEventQueue;
-import org.eclipse.tm.tcf.protocol.Protocol;
-
-
-/**
- * Implementation of Target Communication Framework event queue.
- * This implementation is intended for Eclipse environment.
- */
-class EventQueue implements IEventQueue, Runnable {
-
- private final LinkedList<Runnable> queue = new LinkedList<Runnable>();
- private final Thread thread;
- private boolean waiting;
- private boolean shutdown;
- private int job_cnt;
-
- EventQueue() {
- thread = new Thread(this);
- thread.setDaemon(true);
- thread.setName("TCF Event Dispatcher"); //$NON-NLS-1$
- // Need to monitor jobs to detect congestion
- Job.getJobManager().addJobChangeListener(new IJobChangeListener() {
-
- public void aboutToRun(IJobChangeEvent event) {
- }
-
- public void awake(IJobChangeEvent event) {
- }
-
- public void done(IJobChangeEvent event) {
- job_cnt--;
- }
-
- public void running(IJobChangeEvent event) {
- }
-
- public void scheduled(IJobChangeEvent event) {
- job_cnt++;
- }
-
- public void sleeping(IJobChangeEvent event) {
- }
- });
- }
-
- void start() {
- thread.start();
- }
-
- void shutdown() {
- try {
- synchronized (this) {
- shutdown = true;
- if (waiting) {
- waiting = false;
- notifyAll();
- }
- }
- thread.join();
- }
- catch (Exception e) {
- Protocol.log("Failed to shutdown TCF event dispatch thread", e); //$NON-NLS-1$
- }
- }
-
- private void error(Throwable x) {
- Protocol.log("Unhandled exception in TCF event dispatch", x); //$NON-NLS-1$
- }
-
- public void run() {
- for (;;) {
- try {
- Runnable r = null;
- synchronized (this) {
- while (queue.size() == 0) {
- if (shutdown) return;
- waiting = true;
- wait();
- }
- r = queue.removeFirst();
- }
- r.run();
- }
- catch (Throwable x) {
- error(x);
- }
- }
- }
-
- public synchronized void invokeLater(final Runnable r) {
- assert r != null;
- if (shutdown) throw new IllegalStateException("TCF event dispatcher has shut down"); //$NON-NLS-1$
- queue.add(r);
- if (waiting) {
- waiting = false;
- notifyAll();
- }
- }
-
- public boolean isDispatchThread() {
- return Thread.currentThread() == thread;
- }
-
- public synchronized int getCongestion() {
- if (Job.getJobManager().isIdle()) job_cnt = 0;
- int l0 = job_cnt / 10 - 100;
- int l1 = queue.size() / 10 - 100;
- if (l1 > l0) l0 = l1;
- if (l0 > 100) l0 = 100;
- return l0;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfAbstractExtensionPointManager.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfAbstractExtensionPointManager.java
deleted file mode 100644
index 75cf854d4..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfAbstractExtensionPointManager.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.tcf.extensions;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tm.tcf.Activator;
-import org.eclipse.tm.tcf.internal.nls.TcfPluginMessages;
-
-
-/**
- * Abstract extension point manager base implementation.
- */
-public abstract class TcfAbstractExtensionPointManager<V> {
- // Flag to mark the extension point manager initialized (extensions loaded).
- private boolean fInitialized = false;
- // The map of loaded extension listed by their unique ids
- private Map<String, TcfExtensionProxy<V>> fExtensions = new LinkedHashMap<String, TcfExtensionProxy<V>>();
- // The extension point comparator
- private TcfExtensionPointComparator fComparator = null;
-
- /**
- * Constructor.
- */
- public TcfAbstractExtensionPointManager() {
- }
-
- /**
- * Returns if or if not the service provider extension point manager
- * got initialized. Initialized means that the manager read the
- * contributions for the managed extension point.
- *
- * @return <code>True</code> if already initialized, <code>false</code> otherwise.
- */
- protected boolean isInitialized() {
- return fInitialized;
- }
-
- /**
- * Sets if or if not the service provider extension point manager
- * is initialized. Initialized means that the manager has read
- * the contributions for the managed extension point.
- *
- * @return <code>True</code> to set the extension point manager is initialized, <code>false</code> otherwise.
- */
- protected void setInitialized(boolean initialized) {
- fInitialized = initialized;
- }
-
- /**
- * Returns the map of managed extensions. If not loaded before,
- * this methods trigger the loading of the extensions to the managed
- * extension point.
- *
- * @return The map of contributions.
- */
- protected Map<String, TcfExtensionProxy<V>> getExtensions() {
- if (!isInitialized()) { loadExtensions(); setInitialized(true); }
- return fExtensions;
- }
-
- /**
- * Returns the extensions of the specified extension point sorted.
- * For the order of the extensions, see {@link WRLaunchExtensionPointComparator}.
- *
- * @param point The extension point. Must be not <code>null</code>.
- * @return The extensions in sorted order or an empty array if the extension point has no extensions.
- */
- protected IExtension[] getExtensionsSorted(IExtensionPoint point) {
- assert point != null;
-
- List<IExtension> extensions = new ArrayList<IExtension>(Arrays.asList(point.getExtensions()));
- if (extensions.size() > 0) {
- Collections.sort(extensions, getExtensionPointComparator());
- }
-
- return extensions.toArray(new IExtension[extensions.size()]);
- }
-
- /**
- * Returns the extension point comparator instance. If not available,
- * {@link #doCreateExtensionPointComparator()} is called to create a new instance.
- *
- * @return The extension point comparator or <code>null</code> if the instance creation fails.
- */
- protected final TcfExtensionPointComparator getExtensionPointComparator() {
- if (fComparator == null) {
- fComparator = doCreateExtensionPointComparator();
- }
- return fComparator;
- }
-
- /**
- * Creates a new extension point comparator instance.
- *
- * @return The extension point comparator instance. Must never be <code>null</code>.
- */
- protected TcfExtensionPointComparator doCreateExtensionPointComparator() {
- return new TcfExtensionPointComparator();
- }
-
- /**
- * Returns the extension point id to read. The method
- * must return never <code>null</code>.
- *
- * @return The extension point id.
- */
- protected abstract String getExtensionPointId();
-
- /**
- * Returns the configuration element name. The method
- * must return never <code>null</code>.
- *
- * @return The configuration element name.
- */
- protected abstract String getConfigurationElementName();
-
- /**
- * Creates the extension proxy instance.
- *
- * @param element The configuration element of the extension. Must be not <code>null</code>.
- * @return The extension proxy instance.
- *
- * @throws CoreException If the extension proxy instantiation failed.
- */
- protected TcfExtensionProxy<V> doCreateExtensionProxy(IConfigurationElement element) throws CoreException {
- assert element != null;
- return new TcfExtensionProxy<V>(element);
- }
-
- /**
- * Loads the extensions for the managed extenions point.
- */
- protected void loadExtensions() {
- // If already initialized, this method will do nothing.
- if (isInitialized()) return;
-
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint point = registry.getExtensionPoint(getExtensionPointId());
- if (point != null) {
- IExtension[] extensions = getExtensionsSorted(point);
- for (IExtension extension : extensions) {
- IConfigurationElement[] elements = extension.getConfigurationElements();
- for (IConfigurationElement element : elements) {
- if (getConfigurationElementName().equals(element.getName())) {
- try {
- TcfExtensionProxy<V> candidate = doCreateExtensionProxy(element);
- if (candidate.getId() != null) {
- // If no contribution with this id had been registered before, register now.
- if (!fExtensions.containsKey(candidate.getId())) {
- fExtensions.put(candidate.getId(), candidate);
- }
- else {
- throw new CoreException(new Status(IStatus.ERROR,
- Activator.PLUGIN_ID,
- 0,
- NLS.bind(TcfPluginMessages.Extension_error_duplicateExtension, candidate.getId(), element.getContributor().getName()),
- null));
- }
- }
- else {
- throw new CoreException(new Status(IStatus.ERROR,
- Activator.PLUGIN_ID,
- 0,
- NLS.bind(TcfPluginMessages.Extension_error_missingRequiredAttribute, "id", element.getAttribute("label")), //$NON-NLS-1$ //$NON-NLS-2$
- null));
- }
- }
- catch (CoreException e) {
- IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- NLS.bind(TcfPluginMessages.Extension_error_invalidExtensionPoint, element.getDeclaringExtension().getUniqueIdentifier()),
- e);
- Activator.getDefault().getLog().log(status);
- }
- }
- }
- }
- }
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfExtensionPointComparator.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfExtensionPointComparator.java
deleted file mode 100644
index a6b71ecd0..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfExtensionPointComparator.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.tcf.extensions;
-
-import java.util.Comparator;
-
-import org.eclipse.core.runtime.IExtension;
-
-/**
- * TCF extension point comparator. Used to asure that extension are
- * always read in the same order.
- * <p>
- * The order of the extensions is defined as following:<br>
- * <ul><li>Extensions contributed by the TCF core plug-ins (<code>org.eclipse.tm.tcf.*</code>)
- * in ascending alphabetic order and</li>
- * <li>Extensions contributed by any other plug-in in ascending alphabetic order.</li>
- * <li>Extensions contributed by the same plug-in in ascending alphabetic order by the
- * extensions unique id</li>
- * </ul>
- */
-public class TcfExtensionPointComparator implements Comparator<IExtension> {
- private final static String TCF_PLUGIN_PATTERN = "org.eclipse.tm.tcf.*"; //$NON-NLS-1$
-
- /* (non-Javadoc)
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compare(IExtension o1, IExtension o2) {
- // We ignore any comparison with null and
- if (o1 == null || o2 == null) return 0;
- // Check if it is the exact same element
- if (o1 == o2) return 0;
-
- // The extensions are compared by the unique id of the contributing plugin first
- String contributor1 = o1.getContributor().getName();
- String contributor2 = o2.getContributor().getName();
-
- // Contributions from TCF core plugins comes before 3rdParty Plugins
- if (contributor1.startsWith(TCF_PLUGIN_PATTERN) && !contributor2.startsWith(TCF_PLUGIN_PATTERN))
- return -1;
- if (!contributor1.startsWith(TCF_PLUGIN_PATTERN) && contributor2.startsWith(TCF_PLUGIN_PATTERN))
- return 1;
- if (contributor1.startsWith(TCF_PLUGIN_PATTERN) && contributor2.startsWith(TCF_PLUGIN_PATTERN)) {
- int value = contributor1.compareTo(contributor2);
- // Within the same plugins, the extension are sorted by their unique id (if available)
- if (value == 0 && o1.getUniqueIdentifier() != null && o2.getUniqueIdentifier() != null)
- return o1.getUniqueIdentifier().compareTo(o2.getUniqueIdentifier());
- // Otherwise, just return the comparison result from the contributors
- return value;
- }
-
- // Contributions from all other plugins are sorted alphabetical
- int value = contributor1.compareTo(contributor2);
- // Within the same plugins, the extension are sorted by thier unique id (if available)
- if (value == 0 && o1.getUniqueIdentifier() != null && o2.getUniqueIdentifier() != null)
- return o1.getUniqueIdentifier().compareTo(o2.getUniqueIdentifier());
- // Otherwise, just return the comparison result from the contributors
- return value;
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfExtensionProxy.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfExtensionProxy.java
deleted file mode 100644
index ebf20726b..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/extensions/TcfExtensionProxy.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.tcf.extensions;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tm.tcf.Activator;
-import org.eclipse.tm.tcf.internal.nls.TcfPluginMessages;
-
-/**
- * TCF extension proxy implementation. The use of the proxy asures the
- * lazy plug-in activation policy for the contributing plug-in.
- */
-public class TcfExtensionProxy<V> {
- // The extension instance. Create on first access
- private V fInstance;
- // The configuration element
- private final IConfigurationElement fElement;
- // The unique id of the extension.
- private String fId;
-
- /**
- * Constructor.
- *
- * @param element The configuration element. Must be not <code>null</code>.
- *
- * @throws CoreException In case the configuration element attribute <i>id</i> is <code>null</code> or empty.
- */
- public TcfExtensionProxy(IConfigurationElement element) throws CoreException {
- assert element != null;
- fElement = element;
-
- // The <id> attribute is mandatory.
- fId = element.getAttribute("id"); //$NON-NLS-1$
- if (fId == null || fId.trim().length() == 0) {
- throw new CoreException(new Status(IStatus.ERROR,
- Activator.PLUGIN_ID,
- 0,
- NLS.bind(TcfPluginMessages.Extension_error_missingRequiredAttribute, "id", element.getContributor().getName()), //$NON-NLS-1$
- null));
- }
-
- fInstance = null;
- }
-
- /**
- * Returns the extensions unique id.
- *
- * @return The unique id.
- */
- public String getId() {
- return fId;
- }
-
- /**
- * Returns the configuration element for this extension.
- *
- * @return The configuration element.
- */
- protected IConfigurationElement getConfigurationElement() {
- return fElement;
- }
-
- /**
- * Returns the extension class instance. The contributing
- * plug-in will be activated if not yet activated anyway.
- *
- * @return The extension class instance. Might be <code>null</code> if the instanciation fails.
- */
- @SuppressWarnings("unchecked")
- public V getInstance() {
- if (fInstance == null) {
- IConfigurationElement element = getConfigurationElement();
- assert element != null;
- if (element != null && element.getAttribute("class") != null) { //$NON-NLS-1$
- try {
- fInstance = (V)element.createExecutableExtension("class"); //$NON-NLS-1$
- } catch (Exception e) {
- // Possible exceptions: CoreException, ClassCastException.
- IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- NLS.bind(TcfPluginMessages.Extension_error_invalidExtensionPoint, element.getDeclaringExtension().getUniqueIdentifier()),
- e);
- Activator.getDefault().getLog().log(status);
- }
- }
- }
- return fInstance;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- // Proxies are equal if they have encapsulate an element
- // with the same unique id
- if (obj instanceof TcfExtensionProxy<?>) {
- return getId().equals(((TcfExtensionProxy<?>)obj).getId());
- }
- return super.equals(obj);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- // The hash code of a proxy is the one from the id
- return getId().hashCode();
- }
-
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/extensions/TcfServiceProvidersExtensionPointManager.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/extensions/TcfServiceProvidersExtensionPointManager.java
deleted file mode 100644
index 39d0ce0b9..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/extensions/TcfServiceProvidersExtensionPointManager.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.tcf.internal.extensions;
-
-import java.util.Map;
-
-import org.eclipse.tm.tcf.extensions.TcfAbstractExtensionPointManager;
-import org.eclipse.tm.tcf.extensions.TcfExtensionProxy;
-import org.eclipse.tm.tcf.protocol.IServiceProvider;
-import org.eclipse.tm.tcf.protocol.Protocol;
-
-/**
- * Extension point manager implementation for "org.eclipse.tm.tcf.serviceProviders".
- */
-public class TcfServiceProvidersExtensionPointManager extends TcfAbstractExtensionPointManager<IServiceProvider> {
- /*
- * Thread save singleton instance creation.
- */
- private static class LazyInstanceHolder {
- public static TcfServiceProvidersExtensionPointManager fInstance = new TcfServiceProvidersExtensionPointManager();
- }
-
- /**
- * Returns the singleton instance for the manager.
- */
- public static TcfServiceProvidersExtensionPointManager getInstance() {
- return LazyInstanceHolder.fInstance;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tm.tcf.extensions.TcfAbstractExtensionPointManager#getExtensionPointId()
- */
- @Override
- protected String getExtensionPointId() {
- return "org.eclipse.tm.tcf.serviceProviders"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tm.tcf.extensions.TcfAbstractExtensionPointManager#getConfigurationElementName()
- */
- @Override
- protected String getConfigurationElementName() {
- return "serviceProvider"; //$NON-NLS-1$
- }
-
- /**
- * Register the contributed service provider extensions with the framework.
- */
- public void registerServiceProviders() {
- // Load the extensions
- Map<String, TcfExtensionProxy<IServiceProvider>> extensions = getExtensions();
- // Loop the extensions and get the service provider instance.
- // This will activate the contributing plugin.
- for (TcfExtensionProxy<IServiceProvider> proxy : extensions.values()) {
- IServiceProvider provider = proxy.getInstance();
- if (provider != null) Protocol.addServiceProvider(provider);
- }
- }
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/nls/TcfPluginMessages.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/nls/TcfPluginMessages.java
deleted file mode 100644
index ddd68a1f8..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/nls/TcfPluginMessages.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.tcf.internal.nls;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * TCF plugin externalized strings management.
- */
-public class TcfPluginMessages extends NLS {
-
- // The plug-in resouce bundle name
- private static final String BUNDLE_NAME = "org.eclipse.tm.tcf.internal.tcf.TcfPluginMessages"; //$NON-NLS-1$
-
- /**
- * Static constructor.
- */
- static {
- // Load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, TcfPluginMessages.class);
- }
-
- // **** Declare externalized string id's down here *****
-
- public static String Extension_error_missingRequiredAttribute;
- public static String Extension_error_duplicateExtension;
- public static String Extension_error_invalidExtensionPoint;
-
-}
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/nls/TcfPluginMessages.properties b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/nls/TcfPluginMessages.properties
deleted file mode 100644
index a16b7c2bf..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/internal/nls/TcfPluginMessages.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-###############################################################################
-# Copyright (c) 2010 Wind River Systems, Inc. and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Wind River Systems - initial API and implementation
-###############################################################################
-#
-# org.eclipse.tm.tcf
-# Externalized Strings.
-#
-
-Extension_error_missingRequiredAttribute=Required attribute "{0}" missing for extension "{1}"!
-Extension_error_duplicateExtension=Duplicate extension with id ''{0}''. Ignoring duplicated contribution from contributor ''{1}''!
-Extension_error_invalidExtensionPoint=Failed to instanciate the executable extension from extension point ''{0}''.
diff --git a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/ssl/TCFSecurityManager.java b/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/ssl/TCFSecurityManager.java
deleted file mode 100644
index 55974d7b5..000000000
--- a/plugins/org.eclipse.tm.tcf/src/org/eclipse/tm/tcf/ssl/TCFSecurityManager.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 Wind River Systems, Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tm.tcf.ssl;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.Socket;
-import java.security.KeyFactory;
-import java.security.Principal;
-import java.security.PrivateKey;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.X509Certificate;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.util.ArrayList;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509ExtendedKeyManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.eclipse.tm.tcf.Activator;
-import org.eclipse.tm.tcf.core.Base64;
-import org.eclipse.tm.tcf.protocol.Protocol;
-
-
-/**
- * This class implements keys and certificates management for secure TCF channels.
- */
-public class TCFSecurityManager {
-
- public static File getCertificatesDirectory() {
- File certs;
- try {
- certs = Activator.getDefault().getStateLocation().append("certificates").toFile(); //$NON-NLS-1$
- }
- catch (IllegalStateException e) {
- // An RCP workspace-less environment (-data @none)
- certs = new File(System.getProperty("user.home"), ".tcf");
- certs = new File(certs, "certificates");
- }
- if (!certs.exists()) certs.mkdirs();
- return certs;
- }
-
- public static File getSysCertificatesDirectory() {
- File file = null;
- String osname = System.getProperty("os.name", "");
- if (osname.startsWith("Windows")) {
- try {
- String sys_root = "SystemRoot";
- Process prs = Runtime.getRuntime().exec(new String[]{ "cmd", "/c", "set", sys_root }, null);
- BufferedReader inp = new BufferedReader(new InputStreamReader(prs.getInputStream()));
- for (;;) {
- String s = inp.readLine();
- if (s == null) break;
- int i = s.indexOf('=');
- if (i > 0) {
- String name = s.substring(0, i);
- if (name.equalsIgnoreCase(sys_root)) {
- File root = new File(s.substring(i + 1));
- if (root.exists()) file = new File(root, "TCF/ssl");
- }
- }
- }
- try {
- prs.getErrorStream().close();
- prs.getOutputStream().close();
- inp.close();
- }
- catch (IOException x) {
- }
- prs.waitFor();
- }
- catch (Throwable x) {
- }
- }
- else {
- file = new File("/etc/tcf/ssl");
- }
- if (file == null) return null;
- if (!file.exists()) return null;
- if (!file.isDirectory()) return null;
- return file;
- }
-
- public static SSLContext createSSLContext() {
- try {
- final File usr_certs = getCertificatesDirectory();
- final File sys_certs = getSysCertificatesDirectory();
- if (!usr_certs.exists()) usr_certs.mkdirs();
- final CertificateFactory cf = CertificateFactory.getInstance("X.509"); //$NON-NLS-1$
- SSLContext context = SSLContext.getInstance("TLS"); //$NON-NLS-1$
-
- X509ExtendedKeyManager km = new X509ExtendedKeyManager() {
-
- public X509Certificate[] getCertificateChain(String alias) {
- File f = new File(usr_certs, "local.cert"); //$NON-NLS-1$
- if (!f.exists() && sys_certs != null) f = new File(sys_certs, "local.cert"); //$NON-NLS-1$
- try {
- InputStream inp = new BufferedInputStream(new FileInputStream(f));
- X509Certificate cert = (X509Certificate)cf.generateCertificate(inp);
- inp.close();
- return new X509Certificate[] { cert };
- }
- catch (Exception x) {
- Protocol.log("Cannot read certificate: " + f, x); //$NON-NLS-1$
- return null;
- }
- }
-
- public PrivateKey getPrivateKey(String alias) {
- File f = new File(usr_certs, "local.priv"); //$NON-NLS-1$
- if (!f.exists() && sys_certs != null) f = new File(sys_certs, "local.priv"); //$NON-NLS-1$
- try {
- BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(f), "ASCII")); //$NON-NLS-1$
- StringBuffer bf = new StringBuffer();
- boolean app = false;
- for (;;) {
- String s = r.readLine();
- if (s == null) new Exception("Invalid format"); //$NON-NLS-1$
- else if (s.indexOf("-----BEGIN ") == 0) app = true; //$NON-NLS-1$
- else if (s.indexOf("-----END ") == 0) break; //$NON-NLS-1$
- else if (app) bf.append(s);
- }
- r.close();
- KeyFactory kf = KeyFactory.getInstance("RSA"); //$NON-NLS-1$
- byte[] bytes = Base64.toByteArray(bf.toString().toCharArray());
- return kf.generatePrivate(new PKCS8EncodedKeySpec(bytes));
- }
- catch (Exception x) {
- Protocol.log("Cannot read private key: " + f, x); //$NON-NLS-1$
- return null;
- }
- }
-
- public String[] getClientAliases(String keyType, Principal[] issuers) {
- return new String[] { "TCF" }; //$NON-NLS-1$
- }
-
- public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) {
- return "TCF"; //$NON-NLS-1$
- }
-
- public String[] getServerAliases(String keyType, Principal[] issuers) {
- return new String[] { "TCF" }; //$NON-NLS-1$
- }
-
- public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) {
- return "TCF"; //$NON-NLS-1$
- }
- };
-
- X509TrustManager tm = new X509TrustManager() {
-
- public void checkClientTrusted(X509Certificate[] chain, String auth_type) throws CertificateException {
- if ("RSA".equals(auth_type) && chain != null && chain.length == 1) { //$NON-NLS-1$
- for (X509Certificate cert : getAcceptedIssuers()) {
- if (cert.equals(chain[0])) return;
- }
- }
- throw new CertificateException("Client certificate validation failed"); //$NON-NLS-1$
- }
-
- public void checkServerTrusted(X509Certificate[] chain, String auth_type) throws CertificateException {
- if ("RSA".equals(auth_type) && chain != null && chain.length == 1) { //$NON-NLS-1$
- for (X509Certificate cert : getAcceptedIssuers()) {
- if (cert.equals(chain[0])) return;
- }
- }
- throw new CertificateException("Server certificate validation failed"); //$NON-NLS-1$
- }
-
- public X509Certificate[] getAcceptedIssuers() {
- ArrayList<X509Certificate> list = new ArrayList<X509Certificate>();
- for (String fnm : usr_certs.list()) {
- if (!fnm.endsWith(".cert")) continue; //$NON-NLS-1$
- try {
- InputStream inp = new BufferedInputStream(new FileInputStream(new File(usr_certs, fnm)));
- X509Certificate cert = (X509Certificate)cf.generateCertificate(inp);
- inp.close();
- list.add(cert);
- }
- catch (Throwable x) {
- Protocol.log("Cannot load certificate: " + fnm, x); //$NON-NLS-1$
- }
- }
- if (sys_certs != null) {
- String[] arr = sys_certs.list();
- if (arr != null) {
- for (String fnm : arr) {
- if (!fnm.endsWith(".cert")) continue; //$NON-NLS-1$
- try {
- InputStream inp = new BufferedInputStream(new FileInputStream(new File(sys_certs, fnm)));
- X509Certificate cert = (X509Certificate)cf.generateCertificate(inp);
- inp.close();
- list.add(cert);
- }
- catch (Throwable x) {
- Protocol.log("Cannot load certificate: " + fnm, x); //$NON-NLS-1$
- }
- }
- }
- }
- return list.toArray(new X509Certificate[list.size()]);
- }
- };
-
- context.init(new KeyManager[] { km }, new TrustManager[] { tm }, null);
- return context;
- }
- catch (Throwable x) {
- Protocol.log("Cannot initialize SSL context", x); //$NON-NLS-1$
- return null;
- }
- }
-}

Back to the top