Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Storage/Retrieval of IDs, IContainers using Equinox Secure Preferences

Revision as of 16:36, 22 May 2008 by Slewis.composent.com (Talk | contribs) (New page: In the Platform 3.4M6a release, secure storage was introduced in Equinox. (See secure storage section on [http://download.eclipse.org/eclipse/downloads/drops/S-3.4M6a-200804091425/eclipse...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In the Platform 3.4M6a release, secure storage was introduced in Equinox. (See secure storage section on [http://download.eclipse.org/eclipse/downloads/drops/S-3.4M6a-200804091425/eclipse-news-M6.html Platform 3.4M6a).

ECF IDs can represent many things: from user accounts, to target files/URIs, to remote services. IDs are fully extensible: plugins can extend ECF's notion of ID by introducing new Namespaces (org.eclipse.ecf.namespace extension point), which then construct IDs of appropriate types.

To connect an ECF IContainer to a corresponding network service, a target ID must be provided, along with an IConnectContext to specify credentials (e.g. passwords). Typically, in ECF connection is done in a manner something like this

IContainer container = ...
ID targetID = IDFactory.getDefault().createID(container.getConnectNamespace(),"fliwatuet@ecf.eclipse.org");
// connect to target
IConnectContext connectContext = ConnectContextFactory.createPasswordConnectContext("password");
container.connect(targetID,connectContext);

A common use case is to securely persist account information (username/ID and associated password) and upon Eclipse/ECF startup restore the information and use it to connect to a remote service.

In ECF terms, this requires storing and restoring the targetID, credentials like password associated with the targetID, and possibly the container instance as well.

To make this possible, I've implemented two new services: org.eclipse.ecf.storage.IIDStore and org.eclipse.ecf.storage.IContainerStore. See the complete source for these interfaces here. These two stores allow the storage and retrieval of ECF Namespaces/IDs and IContainers, respectively.

Here's some example code that shows how to save and restore an ID and associated password with the IIDStore

IDStore idStore = getIDStoreOSGiService();
// Create and store an ID
ID newGUID = IDFactory.getDefault().createGUID();
IIDEntry newGUIDEntry = idStore.store(newGUID);
newGUIDEntry.getPreferences().put("password",password,true);

// Retrieve an ID and password from storage
INamespaceEntry restoredNamespace = idStore.getNamespaceEntry(guidNamespace);
IIDEntry[] idEntries = namespaceEntry.getIDEntries();
ID restoredNewGUID = idEntries[0].createID();
String password = (String) idEntries[0].get("password");

Back to the top