private JarFile getNestedJarFile(JarFile jarFile, String name) throws IOException { JarEntry jarEntry = jarFile.getJarEntry(name); return jarFile.getNestedJarFile(jarEntry); }
void setupEntryCertificates(JarEntry entry) { // Fallback to JarInputStream to obtain certificates, not fast but hopefully not // happening that often. try { try (JarInputStream inputStream = new JarInputStream( getData().getInputStream())) { java.util.jar.JarEntry certEntry = inputStream.getNextJarEntry(); while (certEntry != null) { inputStream.closeEntry(); if (entry.getName().equals(certEntry.getName())) { setCertificates(entry, certEntry); } setCertificates(getJarEntry(certEntry.getName()), certEntry); certEntry = inputStream.getNextJarEntry(); } } } catch (IOException ex) { throw new IllegalStateException(ex); } }
@Override public void connect() throws IOException { if (this.jarFile == null) { throw FILE_NOT_FOUND_EXCEPTION; } if (!this.jarEntryName.isEmpty() && this.jarEntry == null) { this.jarEntry = this.jarFile.getJarEntry(getEntryName()); if (this.jarEntry == null) { throwFileNotFound(this.jarEntryName, this.jarFile); } } this.connected = true; }
static JarURLConnection get(URL url, JarFile jarFile) throws IOException { StringSequence spec = new StringSequence(url.getFile()); int index = indexOfRootSpec(spec, jarFile.getPathFromRoot()); if (index == -1) { return (Boolean.TRUE.equals(useFastExceptions.get()) ? NOT_FOUND_CONNECTION : new JarURLConnection(url, null, EMPTY_JAR_ENTRY_NAME)); } int separator; while ((separator = spec.indexOf(SEPARATOR, index)) > 0) { JarEntryName entryName = JarEntryName.get(spec.subSequence(index, separator)); JarEntry jarEntry = jarFile.getJarEntry(entryName.toCharSequence()); if (jarEntry == null) { return JarURLConnection.notFound(jarFile, entryName); } jarFile = jarFile.getNestedJarFile(jarEntry); index = separator + SEPARATOR.length(); } JarEntryName jarEntryName = JarEntryName.get(spec, index); if (Boolean.TRUE.equals(useFastExceptions.get()) && !jarEntryName.isEmpty() && !jarFile.containsEntry(jarEntryName.toString())) { return NOT_FOUND_CONNECTION; } return new JarURLConnection(url, jarFile, jarEntryName); }