/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class is used to verify each entry in a jar file with its
* manifest value.
*/
public class ManifestEntryVerifier {
/**
* Holder class to lazily load Sun provider. NOTE: if
* Providers.getSunProvider returned a cached provider, we could avoid the
* need for caching the provider with this holder class; we should try to
* revisit this in JDK 8.
*/
private static class SunProviderHolder {
}
/** the created digest objects */
/** the digests in use for a given entry*/
/** the manifest hashes for the digests in use */
private boolean skip = true;
/**
* Create a new ManifestEntryVerifier object.
*/
{
manifestHashes = new ArrayList<byte[]>();
decoder = new BASE64Decoder();
}
/**
* Find the hashes in the
* manifest for this entry, save them, and set the MessageDigest
* objects to calculate the hashes on the fly. If name is
*/
throws IOException
{
skip = true;
return;
}
/* get the headers from the manifest for this entry */
/* if there aren't any, we can't verify any digests for this entry */
// ugh. we should be able to remove this at some point.
// there are broken jars floating around with ./name and /name
return;
}
}
// 7 is length of "-Digest"
try {
} catch (NoSuchAlgorithmException nsae) {
// ignore
}
}
skip = false;
}
}
}
}
/**
* update the digests for the digests we are interested in
*/
if (skip) return;
}
}
/**
* update the digests for the digests we are interested in
*/
if (skip) return;
}
}
/**
* get the JarEntry for this object
*/
{
return entry;
}
/**
* go through all the digests, calculating the final digest
* and comparing it to the one in the manifest. If this is
* the first time we have verified this object, remove its
* code signers from sigFileSigners and place in verifiedSigners.
*
*
*/
throws JarException
{
if (skip) {
return null;
}
return signers;
}
" digest error for "+name);
}
// take it out of sigFileSigners and put it in verifiedSigners...
}
return signers;
}
// for the toHex function
private static final char[] hexc =
{'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
/**
* convert a byte array to a hex string for debugging purposes
* @param data the binary data to be converted to a hex string
* @return an ASCII hex string
*/
}
}
}