Search in sources :

Example 1 with BundleFileWrapperChain

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;
}
Also used : BundleFileWrapperChain(org.eclipse.osgi.storage.bundlefile.BundleFileWrapperChain) BundleFileWrapperFactoryHook(org.eclipse.osgi.internal.hookregistry.BundleFileWrapperFactoryHook) BundleFileWrapper(org.eclipse.osgi.storage.bundlefile.BundleFileWrapper)

Example 2 with BundleFileWrapperChain

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;
    }
}
Also used : BundleFileWrapperChain(org.eclipse.osgi.storage.bundlefile.BundleFileWrapperChain) SignedContent(org.eclipse.osgi.signedcontent.SignedContent) SignerInfo(org.eclipse.osgi.signedcontent.SignerInfo) MalformedURLException(java.net.MalformedURLException) File(java.io.File) BundleFile(org.eclipse.osgi.storage.bundlefile.BundleFile) Certificate(java.security.cert.Certificate)

Aggregations

BundleFileWrapperChain (org.eclipse.osgi.storage.bundlefile.BundleFileWrapperChain)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 Certificate (java.security.cert.Certificate)1 BundleFileWrapperFactoryHook (org.eclipse.osgi.internal.hookregistry.BundleFileWrapperFactoryHook)1 SignedContent (org.eclipse.osgi.signedcontent.SignedContent)1 SignerInfo (org.eclipse.osgi.signedcontent.SignerInfo)1 BundleFile (org.eclipse.osgi.storage.bundlefile.BundleFile)1 BundleFileWrapper (org.eclipse.osgi.storage.bundlefile.BundleFileWrapper)1