use of org.eclipse.osgi.storage.bundlefile.BundleFileWrapperChain in project rt.equinox.framework by eclipse.
the class Storage method wrapBundleFile.
public BundleFile wrapBundleFile(BundleFile bundleFile, Generation generation, boolean isBase) {
// try creating a wrapper bundlefile out of it.
List<BundleFileWrapperFactoryHook> wrapperFactories = getConfiguration().getHookRegistry().getBundleFileWrapperFactoryHooks();
BundleFileWrapperChain wrapped = wrapperFactories.isEmpty() ? null : new BundleFileWrapperChain(bundleFile, null);
for (BundleFileWrapperFactoryHook wrapperFactory : wrapperFactories) {
BundleFileWrapper wrapperBundle = wrapperFactory.wrapBundleFile(bundleFile, generation, isBase);
if (wrapperBundle != null && wrapperBundle != bundleFile)
bundleFile = wrapped = new BundleFileWrapperChain(wrapperBundle, wrapped);
}
return bundleFile;
}
use of org.eclipse.osgi.storage.bundlefile.BundleFileWrapperChain in project rt.equinox.framework by eclipse.
the class ModuleClassLoader method createProtectionDomain.
/**
* Creates a ProtectionDomain which uses specified BundleFile and the permissions of the baseDomain
* @param bundlefile The source bundlefile the domain is for.
* @param domainGeneration the source generation for the domain
* @return a ProtectionDomain which uses specified BundleFile and the permissions of the baseDomain
*/
@SuppressWarnings("deprecation")
protected ProtectionDomain createProtectionDomain(BundleFile bundlefile, Generation domainGeneration) {
// create a protection domain which knows about the codesource for this classpath entry (bug 89904)
ProtectionDomain baseDomain = domainGeneration.getDomain();
try {
// use the permissions supplied by the domain passed in from the framework
PermissionCollection permissions;
if (baseDomain != null) {
permissions = baseDomain.getPermissions();
} else {
// no domain specified. Better use a collection that has all permissions
// this is done just incase someone sets the security manager later
permissions = ALLPERMISSIONS;
}
Certificate[] certs = null;
SignedContent signedContent = null;
if (bundlefile instanceof BundleFileWrapperChain) {
BundleFileWrapperChain wrapper = (BundleFileWrapperChain) bundlefile;
while (wrapper != null && (!(wrapper.getWrapped() instanceof SignedContent))) wrapper = wrapper.getNext();
signedContent = wrapper == null ? null : (SignedContent) wrapper.getWrapped();
}
if (getConfiguration().CLASS_CERTIFICATE && signedContent != null && signedContent.isSigned()) {
SignerInfo[] signers = signedContent.getSignerInfos();
if (signers.length > 0)
certs = signers[0].getCertificateChain();
}
File file = bundlefile.getBaseFile();
// Bug 477787: file will be null when the osgi.framework configuration property contains an invalid value.
return new GenerationProtectionDomain(file == null ? null : new CodeSource(file.toURL(), certs), permissions, getGeneration());
// return new ProtectionDomain(new CodeSource(bundlefile.getBaseFile().toURL(), certs), permissions);
} catch (MalformedURLException e) {
// Failed to create our own domain; just return the baseDomain
return baseDomain;
}
}
Aggregations