try {
NamingEnumeration<Binding> wne =
dirContext.listBindings("/META-INF/");
Binding binding = wne.nextElement();
if (binding.getName().toUpperCase(Locale.ENGLISH).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) {
ExceptionUtils.handleThrowable(t);
}
}
}
// Locate the Manifests for all bundled JARs
NamingEnumeration<Binding> ne = null;
try {
ne = dirContext.listBindings("WEB-INF/lib/");
while ((ne != null) && ne.hasMoreElements()) {
Binding binding = ne.nextElement();
if (!binding.getName().toLowerCase(Locale.ENGLISH).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;
inputStream = resource.streamContent();
Manifest jmanifest = getManifest(inputStream);
if (jmanifest != null) {
ManifestResource mre = new ManifestResource(
binding.getName(),
jmanifest,