Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] [p2-dev] Best way to contribute values (eg PGP keys) with OSGi?

If all you need is a path to some resource in a bundle then there is no need for a custom header or a custom service interface.  I recommend you define your own capability namespace and define a set of attributes that describe the capability for such a namespace.
 
For example, define a new capability namespace called "org.eclipse.equinox.p2.pgp.key".  I'm not sure what sorts of attributes you need to describe the pgp key outside of just the path to the file in the resource.  But you could have an attribute "path" to describe the path:
 
Bundle-Capability: org.eclipse.equinox.p2.pgp.key; path="/path/to/pgp/key/file"
 
This uses the standard Bundle-Capability header which allows the capability to be reflected with the FrameworkWiring API to discover the available capabilities.
 
Then from p2 you would find the capabilities available in the running framework with code like this:
 
BundleContext bc = ...;
FrameworkWiring fwkWiring = bc.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).adapt(FrameworkWiring.class);
fwlWiring.findCapabilities(pgpReq).forEach(c -> {
    URL key = c.getRevision().getBundle().getEntry(c.getAttributes().get("path");
    // do something with the key
});
 
Where pgpReq is a simple Requirement implementation that uses the org.eclipse.equinox.p2.pgp.key namespace and has empty attributes and directives and a null resource.  Obtaining the URLs will not activate (lazy or otherwise) or even require such bundles to be resolved.  They only need to be installed.

Tom
 
 
 
----- Original message -----
From: "Mickael Istria" <mistria@xxxxxxxxxx>
Sent by: "p2-dev" <p2-dev-bounces@xxxxxxxxxxx>
To: "Equinox development mailing list" <equinox-dev@xxxxxxxxxxx>, "P2 developer discussions" <p2-dev@xxxxxxxxxxx>
Cc:
Subject: [EXTERNAL] [p2-dev] Best way to contribute values (eg PGP keys) with OSGi?
Date: Wed, Dec 1, 2021 9:43 AM
 
Hi all, In the context of https://bugs.eclipse.org/bugs/show_bug.cgi?id=577248 , we need a way for bundles (that were preliminary approved by user) to be capable of contributing some PGP public keys as being "trusted by default". ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Hi all,
 
In the context of https://bugs.eclipse.org/bugs/show_bug.cgi?id=577248 , we need a way for bundles (that were preliminary approved by user) to be capable of contributing some PGP public keys as being "trusted by default". I'm wondering what would be the best way to contribute such extensibility in p2. p2 doesn't define extension points, but uses OSGi Services; but here we only want to contribute a value (that could be the armoured keys, or a path to a resource in the bundle containing such keys...). As far as I am aware -ie not much-, I see 3 possible approaches:
 
1. Define a service interface and let bundles contribute extensions to this interface, eg via OSGI-INF/component.xml
  * Requires to create 1 service/API interace
  * Would consuming the service from a bundle automatically trigger bundle activation? That would be undesired.
 
2. Add support for a custom MANIFEST header, something like `Eclipse-P2-PGP-TrustedKey`.
  * Seems a bit alien, would require some support in tools
 
Are there other solutions you think could fit? What should be preferred?
 
Thanks in advance
--
Mickael Istria
Eclipse IDE developer, for Red Hat Developers
_______________________________________________
p2-dev mailing list
p2-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/p2-dev
 



Back to the top