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;
}
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;
}
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;
}
}
Aggregations