use of org.eclipse.osgi.signedcontent.SignedContentFactory in project rt.equinox.framework by eclipse.
the class EquinoxBundle method getSignerCertificates.
@Override
public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType) {
SignedContentFactory factory = equinoxContainer.getSignedContentFactory();
if (factory == null) {
return Collections.emptyMap();
}
try {
SignerInfo[] infos = signerInfos;
if (infos == null) {
SignedContent signedContent = factory.getSignedContent(this);
infos = signedContent.getSignerInfos();
signerInfos = infos;
}
if (infos.length == 0)
return Collections.emptyMap();
Map<X509Certificate, List<X509Certificate>> results = new HashMap<>(infos.length);
for (int i = 0; i < infos.length; i++) {
if (signersType == SIGNERS_TRUSTED && !infos[i].isTrusted())
continue;
Certificate[] certs = infos[i].getCertificateChain();
if (certs == null || certs.length == 0)
continue;
List<X509Certificate> certChain = new ArrayList<>();
for (int j = 0; j < certs.length; j++) certChain.add((X509Certificate) certs[j]);
results.put((X509Certificate) certs[0], certChain);
}
return results;
} catch (Exception e) {
return Collections.emptyMap();
}
}
use of org.eclipse.osgi.signedcontent.SignedContentFactory in project rt.equinox.framework by eclipse.
the class BaseSecurityTest method getSignedContentFactory.
protected SignedContentFactory getSignedContentFactory() {
ServiceReference ref = OSGiTestsActivator.getContext().getServiceReference(SignedContentFactory.class.getName());
assertNotNull("No SignedContentFactory service", ref);
SignedContentFactory factory = (SignedContentFactory) OSGiTestsActivator.getContext().getService(ref);
OSGiTestsActivator.getContext().ungetService(ref);
return factory;
}
Aggregations