Search in sources :

Example 11 with BundleFile

use of org.eclipse.osgi.storage.bundlefile.BundleFile in project rt.equinox.framework by eclipse.

the class NativeCodeFinder method searchEclipseVariants.

private String searchEclipseVariants(String path) {
    List<String> ECLIPSE_LIB_VARIANTS = generation.getBundleInfo().getStorage().getConfiguration().ECLIPSE_LIB_VARIANTS;
    for (String variant : ECLIPSE_LIB_VARIANTS) {
        BundleFile baseBundleFile = generation.getBundleFile();
        BundleEntry libEntry = baseBundleFile.getEntry(variant + path);
        if (libEntry != null) {
            File libFile = baseBundleFile.getFile(variant + path, true);
            if (libFile == null)
                return null;
            // see bug 88697 - HP requires libraries to have executable permissions
            if (org.eclipse.osgi.service.environment.Constants.OS_HPUX.equals(generation.getBundleInfo().getStorage().getConfiguration().getOS())) {
                try {
                    // use the string array method in case there is a space in the path
                    // $NON-NLS-1$ //$NON-NLS-2$
                    Runtime.getRuntime().exec(new String[] { "chmod", "755", libFile.getAbsolutePath() }).waitFor();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return libFile.getAbsolutePath();
        }
    }
    return null;
}
Also used : BundleFile(org.eclipse.osgi.storage.bundlefile.BundleFile) File(java.io.File) BundleFile(org.eclipse.osgi.storage.bundlefile.BundleFile) BundleEntry(org.eclipse.osgi.storage.bundlefile.BundleEntry) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException)

Example 12 with BundleFile

use of org.eclipse.osgi.storage.bundlefile.BundleFile in project rt.equinox.framework by eclipse.

the class Storage method findInSystemBundle.

private InputStream findInSystemBundle(Generation systemGeneration, String entry) {
    BundleFile systemContent = systemGeneration.getBundleFile();
    BundleEntry systemEntry = systemContent != null ? systemContent.getEntry(entry) : null;
    InputStream result = null;
    if (systemEntry != null) {
        try {
            result = systemEntry.getInputStream();
        } catch (IOException e) {
        // Do nothing
        }
    }
    if (result == null) {
        // Check the ClassLoader in case we're launched off the Java boot classpath
        ClassLoader loader = getClass().getClassLoader();
        result = loader == null ? ClassLoader.getSystemResourceAsStream(entry) : loader.getResourceAsStream(entry);
    }
    return result;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ReferenceInputStream(org.eclipse.osgi.storage.url.reference.ReferenceInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStream(java.io.DataInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) NestedDirBundleFile(org.eclipse.osgi.storage.bundlefile.NestedDirBundleFile) ZipBundleFile(org.eclipse.osgi.storage.bundlefile.ZipBundleFile) DirBundleFile(org.eclipse.osgi.storage.bundlefile.DirBundleFile) BundleFile(org.eclipse.osgi.storage.bundlefile.BundleFile) BundleEntry(org.eclipse.osgi.storage.bundlefile.BundleEntry)

Example 13 with BundleFile

use of org.eclipse.osgi.storage.bundlefile.BundleFile 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

BundleFile (org.eclipse.osgi.storage.bundlefile.BundleFile)13 File (java.io.File)7 ArrayList (java.util.ArrayList)5 BundleEntry (org.eclipse.osgi.storage.bundlefile.BundleEntry)5 IOException (java.io.IOException)3 URL (java.net.URL)3 DirBundleFile (org.eclipse.osgi.storage.bundlefile.DirBundleFile)3 NestedDirBundleFile (org.eclipse.osgi.storage.bundlefile.NestedDirBundleFile)3 ZipBundleFile (org.eclipse.osgi.storage.bundlefile.ZipBundleFile)3 InputStream (java.io.InputStream)2 MalformedURLException (java.net.MalformedURLException)2 URLClassLoader (java.net.URLClassLoader)2 LinkedHashSet (java.util.LinkedHashSet)2 ModuleClassLoader (org.eclipse.osgi.internal.loader.ModuleClassLoader)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedWriter (java.io.BufferedWriter)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Closeable (java.io.Closeable)1 DataInputStream (java.io.DataInputStream)1 FileInputStream (java.io.FileInputStream)1