/** * Performs the same function as calling * {@link #getEntryPaths(String, boolean)} with <code>recurse</code> equal * to <code>false</code>. * @param path path of the entry to locate in the bundle * @return an Enumeration of Strings that indicate the paths found or * null if the path does not exist. */ public Enumeration<String> getEntryPaths(String path) { return getEntryPaths(path, false); }
@Override public String toString() { return wrapped.toString(); }
public void close() { synchronized (genMonitor) { if (bundleFile != null) { try { bundleFile.close(); } catch (IOException e) { // ignore } } } }
private void removeInternal(BundleFile bundleFile) { int index = bundleFile.getMruIndex(); bundleFile.setMruIndex(-1); bundleFileList[index] = null; useStampList[index] = -1; numOpen--; }
private void processSigner(BundleFile bf, byte[] manifestBytes, String signer) throws IOException, SignatureException, InvalidKeyException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException { BundleEntry be = bf.getEntry(signer); byte pkcs7Bytes[] = readIntoArray(be); int dotIndex = signer.lastIndexOf('.'); be = bf.getEntry(signer.substring(0, dotIndex) + DOT_SF); byte sfBytes[] = readIntoArray(be); String baseFile = bf.getBaseFile() != null ? bf.getBaseFile().toString() : null; PKCS7Processor processor = new PKCS7Processor(pkcs7Bytes, 0, pkcs7Bytes.length, signer, baseFile); throw new SignatureException(NLS.bind(SignedContentMessages.SF_File_Parsing_Error, new String[] {bf.toString()}));
public URL getEntry(String path) { BundleEntry entry = getBundleFile().getEntry(path); if (entry == null) return null; path = BundleFile.fixTrailingSlash(path, entry); try { //use the constant string for the protocol to prevent duplication return Storage.secureAction.getURL(BundleResourceHandler.OSGI_ENTRY_URL_PROTOCOL, Long.toString(getBundleId()) + BundleResourceHandler.BID_FWKID_SEPARATOR + Integer.toString(getStorage().getModuleContainer().hashCode()), 0, path, new Handler(getStorage().getModuleContainer(), entry)); } catch (MalformedURLException e) { return null; } }
/** * Creates a new ClasspathEntry object for the requested classpath if the source exists. * @param cp the requested classpath. * @param cpGeneration the source generation to search for the classpath * @return a new ClasspathEntry for the requested classpath or null if the source does not exist. */ public ClasspathEntry getClasspath(String cp, Generation cpGeneration) { BundleFile bundlefile = null; File file; BundleEntry cpEntry = cpGeneration.getBundleFile().getEntry(cp); // check for internal library directories in a bundle jar file if (cpEntry != null && cpEntry.getName().endsWith("/")) //$NON-NLS-1$ bundlefile = createBundleFile(cp, cpGeneration); // check for internal library jars else if ((file = cpGeneration.getBundleFile().getFile(cp, false)) != null) bundlefile = createBundleFile(file, cpGeneration); if (bundlefile != null) return createClassPathEntry(bundlefile, cpGeneration); return null; }
@Override public boolean containsDir(String dir) { return bundleFile.containsDir(dir); } }
/** * Creates a new <code>BundleFileWrapper</code> instance wrapping the * given {@link BundleFile bundle file}. * * @param bundleFile - The bundle file to wrap. * @throws NullPointerException - If the bundle file is <code>null</code>. */ public BundleFileWrapper(BundleFile bundleFile) { super(bundleFile.getBaseFile()); this.bundleFile = bundleFile; }
@Override public File getFile(String path, boolean nativeCode) { return bundleFile.getFile(path, nativeCode); }
/** * Finds the resource wiht the specified name. * This handles Multi-Release searching also. * @param name the resource name * @param m the module this classpath entry is for * @param index the index this classpath entry. * @return the resource URL or {@code null} if the resource does not exist. */ public URL findResource(String name, Module m, int index) { for (BundleFile mrFile : mrBundleFiles) { URL mrURL = mrFile.getResourceURL(name, m, index); if (mrURL != null) { return mrURL; } } return bundlefile.getResourceURL(name, m, index); }
/** * Increments the use stamp of a bundle file * @param bundleFile the bundle file to increment the use stamp for */ public void use(BundleFile bundleFile) { if (fileLimit < MIN) return; // MRU is disabled synchronized (this) { int index = bundleFile.getMruIndex(); if ((index >= 0 && index < fileLimit) && bundleFileList[index] == bundleFile) incUseStamp(index); } }
/** * Creates a URL to access the content of the specified entry * @param bundleEntry the bundle entry * @param hostModule the host module * @param index the resource index * @param path * @return a URL to access the contents of the specified entry */ protected URL createResourceURL(BundleEntry bundleEntry, Module hostModule, int index, String path) { long hostBundleID = hostModule.getId(); path = fixTrailingSlash(path, bundleEntry); try { //use the constant string for the protocol to prevent duplication return secureAction.getURL(BundleResourceHandler.OSGI_RESOURCE_URL_PROTOCOL, Long.toString(hostBundleID) + BundleResourceHandler.BID_FWKID_SEPARATOR + Integer.toString(hostModule.getContainer().hashCode()), index, path, new Handler(hostModule.getContainer(), bundleEntry)); } catch (MalformedURLException e) { return null; } }
private void processSigner(BundleFile bf, byte[] manifestBytes, String signer) throws IOException, SignatureException, InvalidKeyException, CertificateException, NoSuchAlgorithmException, NoSuchProviderException { BundleEntry be = bf.getEntry(signer); byte pkcs7Bytes[] = readIntoArray(be); int dotIndex = signer.lastIndexOf('.'); be = bf.getEntry(signer.substring(0, dotIndex) + DOT_SF); byte sfBytes[] = readIntoArray(be); String baseFile = bf.getBaseFile() != null ? bf.getBaseFile().toString() : null; PKCS7Processor processor = new PKCS7Processor(pkcs7Bytes, 0, pkcs7Bytes.length, signer, baseFile); throw new SignatureException(NLS.bind(SignedContentMessages.SF_File_Parsing_Error, new String[] {bf.toString()}));
public URL getEntry(String path) { BundleEntry entry = getBundleFile().getEntry(path); if (entry == null) return null; path = BundleFile.fixTrailingSlash(path, entry); try { //use the constant string for the protocol to prevent duplication return Storage.secureAction.getURL(BundleResourceHandler.OSGI_ENTRY_URL_PROTOCOL, Long.toString(getBundleId()) + BundleResourceHandler.BID_FWKID_SEPARATOR + Integer.toString(getStorage().getModuleContainer().hashCode()), 0, path, new Handler(getStorage().getModuleContainer(), entry)); } catch (MalformedURLException e) { return null; } }
private void removeInternal(BundleFile bundleFile) { int index = bundleFile.getMruIndex(); bundleFile.setMruIndex(-1); bundleFileList[index] = null; useStampList[index] = -1; numOpen--; }
/** * Creates a new ClasspathEntry object for the requested classpath if the source exists. * @param cp the requested classpath. * @param cpGeneration the source generation to search for the classpath * @return a new ClasspathEntry for the requested classpath or null if the source does not exist. */ public ClasspathEntry getClasspath(String cp, Generation cpGeneration) { BundleFile bundlefile = null; File file; BundleEntry cpEntry = cpGeneration.getBundleFile().getEntry(cp); // check for internal library directories in a bundle jar file if (cpEntry != null && cpEntry.getName().endsWith("/")) //$NON-NLS-1$ bundlefile = createBundleFile(cp, cpGeneration); // check for internal library jars else if ((file = cpGeneration.getBundleFile().getFile(cp, false)) != null) bundlefile = createBundleFile(file, cpGeneration); if (bundlefile != null) return createClassPathEntry(bundlefile, cpGeneration); return null; }
@Override public boolean containsDir(String dir) { return bundleFile.containsDir(dir); }
/** * Creates a new <code>BundleFileWrapper</code> instance wrapping the * given {@link BundleFile bundle file}. * * @param bundleFile - The bundle file to wrap. * @throws NullPointerException - If the bundle file is <code>null</code>. */ public BundleFileWrapper(BundleFile bundleFile) { super(bundleFile.getBaseFile()); this.bundleFile = bundleFile; }