use of org.eclipse.osgi.internal.signedcontent.SignedStorageHook.StorageHookImpl in project rt.equinox.framework by eclipse.
the class SignedBundleHook method wrapBundleFile.
public BundleFileWrapper wrapBundleFile(BundleFile bundleFile, Generation generation, boolean base) {
try {
if (bundleFile != null) {
StorageHookImpl hook = generation.getStorageHook(SignedStorageHook.class);
SignedBundleFile signedBaseFile;
if (base && hook != null) {
signedBaseFile = new SignedBundleFile(bundleFile, hook.signedContent, supportSignedBundles, this);
if (hook.signedContent == null) {
signedBaseFile.initializeSignedContent();
SignedContentImpl signedContent = signedBaseFile.getSignedContent();
hook.signedContent = signedContent != null && signedContent.isSigned() ? signedContent : null;
}
} else
signedBaseFile = new SignedBundleFile(bundleFile, null, supportSignedBundles, this);
signedBaseFile.initializeSignedContent();
SignedContentImpl signedContent = signedBaseFile.getSignedContent();
if (signedContent != null && signedContent.isSigned()) {
// only use the signed file if there are certs
signedContent.setContent(signedBaseFile);
return new BundleFileWrapper(signedBaseFile);
}
}
} catch (IOException e) {
// $NON-NLS-1$
log("Bad bundle file: " + bundleFile.getBaseFile(), FrameworkLogEntry.WARNING, e);
} catch (GeneralSecurityException e) {
// $NON-NLS-1$
log("Bad bundle file: " + bundleFile.getBaseFile(), FrameworkLogEntry.WARNING, e);
}
return null;
}
use of org.eclipse.osgi.internal.signedcontent.SignedStorageHook.StorageHookImpl in project rt.equinox.framework by eclipse.
the class SignedBundleHook method getSignedContent.
public SignedContent getSignedContent(Bundle bundle) throws IOException, InvalidKeyException, SignatureException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException, IllegalArgumentException {
final Generation generation = (Generation) ((EquinoxBundle) bundle).getModule().getCurrentRevision().getRevisionInfo();
StorageHookImpl hook = generation.getStorageHook(SignedStorageHook.class);
SignedContent result = hook != null ? hook.signedContent : null;
if (result != null)
// just reuse the signed content the storage hook
return result;
// must create a new signed content using the raw file
if (System.getSecurityManager() == null)
return getSignedContent(generation.getBundleFile().getBaseFile());
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<SignedContent>() {
public SignedContent run() throws Exception {
return getSignedContent(generation.getBundleFile().getBaseFile());
}
});
} catch (PrivilegedActionException e) {
if (e.getException() instanceof IOException)
throw (IOException) e.getException();
if (e.getException() instanceof InvalidKeyException)
throw (InvalidKeyException) e.getException();
if (e.getException() instanceof SignatureException)
throw (SignatureException) e.getException();
if (e.getException() instanceof CertificateException)
throw (CertificateException) e.getException();
if (e.getException() instanceof NoSuchAlgorithmException)
throw (NoSuchAlgorithmException) e.getException();
if (e.getException() instanceof NoSuchProviderException)
throw (NoSuchProviderException) e.getException();
// $NON-NLS-1$
throw new RuntimeException("Unknown error.", e.getException());
}
}
use of org.eclipse.osgi.internal.signedcontent.SignedStorageHook.StorageHookImpl in project rt.equinox.framework by eclipse.
the class TrustEngineListener method getSignedContent.
private SignedContentImpl getSignedContent(Bundle bundle) {
Generation generation = (Generation) ((EquinoxBundle) bundle).getModule().getCurrentRevision().getRevisionInfo();
StorageHookImpl hook = generation.getStorageHook(SignedStorageHook.class);
return hook != null ? hook.signedContent : null;
}
Aggregations