InputStream inputStream = null;
try {
NamingEnumeration wne = dirContext.listBindings("/META-INF/");
Binding binding = (Binding) wne.nextElement();
if (binding.getName().toUpperCase().equals("MANIFEST.MF")) {
Resource resource = (Resource)dirContext.lookup
("/META-INF/" + binding.getName());
inputStream = resource.streamContent();
Manifest manifest = new Manifest(inputStream);
inputStream.close();
inputStream = null;
ManifestResource mre = new ManifestResource
(sm.getString("extensionValidator.web-application-manifest"),
manifest, ManifestResource.WAR);
appManifestResources.add(mre);
}
} catch (NamingException nex) {
// Application does not contain a MANIFEST.MF file
} catch (NoSuchElementException nse) {
// Application does not contain a MANIFEST.MF file
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable t) {
// Ignore
}
}
}
// Locate the Manifests for all bundled JARs
NamingEnumeration ne = null;
try {
if (dirContext != null) {
ne = dirContext.listBindings("WEB-INF/lib/");
}
while ((ne != null) && ne.hasMoreElements()) {
Binding binding = (Binding)ne.nextElement();
if (!binding.getName().toLowerCase().endsWith(".jar")) {
continue;
}
Object obj =
dirContext.lookup("/WEB-INF/lib/" + binding.getName());
if (!(obj instanceof Resource)) {
// Probably a directory named xxx.jar - ignore it
continue;
}
Resource resource = (Resource) obj;
Manifest jmanifest = getManifest(resource.streamContent());
if (jmanifest != null) {
ManifestResource mre = new ManifestResource(
binding.getName(),
jmanifest,
ManifestResource.APPLICATION);