本文整理汇总了Java中java.util.jar.JarException类的典型用法代码示例。如果您正苦于以下问题:Java JarException类的具体用法?Java JarException怎么用?Java JarException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JarException类属于java.util.jar包,在下文中一共展示了JarException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import java.util.jar.JarException; //导入依赖的package包/类
/**
* process the signature block file. Goes through the .SF file
* and adds code signers for each section where the .SF section
* hash was verified against the Manifest section.
*
*
*/
public void process(Hashtable<String, CodeSigner[]> signers,
List<Object> manifestDigests)
throws IOException, SignatureException, NoSuchAlgorithmException,
JarException, CertificateException
{
// calls Signature.getInstance() and MessageDigest.getInstance()
// need to use local providers here, see Providers class
Object obj = null;
try {
obj = Providers.startJarVerification();
processImpl(signers, manifestDigests);
} finally {
Providers.stopJarVerification(obj);
}
}
示例2: readVersionInfo
import java.util.jar.JarException; //导入依赖的package包/类
/**
* Pedantic method that requires the next attribute in the Manifest to be the
* "Manifest-Version". This follows the Manifest spec closely but reject some
* jar Manifest files out in the wild.
*/
private static void readVersionInfo(Attributes attr, BufferedReader br)
throws IOException
{
String version_header = Name.MANIFEST_VERSION.toString();
try
{
String value = expectHeader(version_header, br);
attr.putValue(MANIFEST_VERSION, value);
}
catch (IOException ioe)
{
throw new JarException("Manifest should start with a " + version_header
+ ": " + ioe.getMessage());
}
}
示例3: readAttribute
import java.util.jar.JarException; //导入依赖的package包/类
private static void
readAttribute(Attributes attr, String s, BufferedReader br) throws IOException
{
try
{
int colon = s.indexOf(": ");
String name = s.substring(0, colon);
String value_start = s.substring(colon + 2);
String value = readHeaderValue(value_start, br);
attr.putValue(name, value);
}
catch (IndexOutOfBoundsException iobe)
{
throw new JarException("Manifest contains a bad header: " + s);
}
}
示例4: readSectionName
import java.util.jar.JarException; //导入依赖的package包/类
private static Attributes
readSectionName(String s, BufferedReader br, Map entries) throws JarException
{
try
{
String name = expectHeader(NAME, br, s);
Attributes attr = new Attributes();
entries.put(name, attr);
return attr;
}
catch (IOException ioe)
{
throw new JarException("Section should start with a Name header: "
+ ioe.getMessage());
}
}
示例5: expectHeader
import java.util.jar.JarException; //导入依赖的package包/类
private static String expectHeader(String header, BufferedReader br, String s)
throws IOException
{
try
{
String name = s.substring(0, header.length() + 1);
if (name.equalsIgnoreCase(header + ":"))
{
String value_start = s.substring(header.length() + 2);
return readHeaderValue(value_start, br);
}
}
catch (IndexOutOfBoundsException ignored)
{
}
// If we arrive here, something went wrong
throw new JarException("unexpected '" + s + "'");
}
示例6: getJdbcDriver
import java.util.jar.JarException; //导入依赖的package包/类
String getJdbcDriver() throws JarException {
switch (this._DBtype) {
case MS_SQL_Server:
return "com.microsoft.sqlserver.jdbc.SQLServerDriver";
case Oracle:
return "oracle.jdbc.driver.OracleDriver";
case DB2:
return "com.ibm.db2.jcc.DB2Driver";
case MySQL:
return "com.mysql.jdbc.Driver";
case HSQL:
return "org.hsqldb.jdbcDriver";
case Ingres:
return "com.ingres.jdbc.IngresDriver";
case Postgres:
return "org.postgresql.Driver";
default:
break;
}
throw new JarException("The .jar file for " + this._DBtype.ToString() +" Jdbc Driver not found");
}
示例7: readSFManifest
import java.util.jar.JarException; //导入依赖的package包/类
public static void
readSFManifest(Attributes attr, Map entries, InputStream in)
throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
String version_header = Name.SIGNATURE_VERSION.toString();
try
{
String version = expectHeader(version_header, br);
attr.putValue(SIGNATURE_VERSION, version);
if (! DEFAULT_SF_VERSION.equals(version))
log.warning("Unexpected version number: " + version
+ ". Continue (but may fail later)");
}
catch (IOException ioe)
{
throw new JarException("Signature file MUST start with a "
+ version_header + ": " + ioe.getMessage());
}
read_attributes(attr, br);
// read individual sections
String s = br.readLine();
while (s != null && s.length() > 0)
{
Attributes eAttr = readSectionName(s, br, entries);
read_attributes(eAttr, br);
s = br.readLine();
}
}
示例8: writeAttributeEntry
import java.util.jar.JarException; //导入依赖的package包/类
private static void writeAttributeEntry(Map.Entry entry, OutputStream out)
throws IOException
{
String name = entry.getKey().toString();
String value = entry.getValue().toString();
if (name.equalsIgnoreCase(NAME))
throw new JarException("Attributes cannot be called 'Name'");
if (name.startsWith("From"))
throw new JarException("Header cannot start with the four letters 'From'"
+ name);
writeHeader(name, value, out);
}
示例9: modifyTarget
import java.util.jar.JarException; //导入依赖的package包/类
private static void modifyTarget(File originalRuntime, String mergeRenamePrefix, File outputRuntime, boolean watermark, byte[]... classFiles) throws JarException, IOException {
Engine engine = new Engine(originalRuntime, mergeRenamePrefix);
for(byte[] classFile : classFiles){
engine.process(classFile);
}
if(watermark){
engine.addFile(WATERMARK, WATERMARK.getBytes(), true);
}
engine.save(outputRuntime);
}
示例10: test_Constructor
import java.util.jar.JarException; //导入依赖的package包/类
/**
* @tests java.util.jar.JarException#JarException(java.lang.String)
*/
public void test_Constructor() throws Exception {
JarException ex = new JarException();
JarException ex1 = new JarException("Test string");
JarException ex2 = new JarException(null);
assertNotSame(ex, ex1);
assertNotSame(ex.getMessage(), ex1.getMessage());
assertNotSame(ex, ex2);
assertSame(ex.getMessage(), ex2.getMessage());
}
示例11: Engine
import java.util.jar.JarException; //导入依赖的package包/类
public Engine(File jar, String mergeRenamePrefix) throws JarException, IOException {
this.mergeRenamePrefix = mergeRenamePrefix;
this.jarModifier = new JarModifier(jar);
this.jarName = jar.getName();
this.originalEntries = new HashSet<String>(jarModifier.getJarEntrySet());
}