src/com/esotericsoftware/scar/Jar.java
static public String unsign (String jarFile) throws IOException {
		if (jarFile == null) throw new IllegalArgumentException("jarFile cannot be null.");

		if (DEBUG) debug("scar", "Removing signature from JAR: " + jarFile);

		File tempFile = File.createTempFile("scar", "removejarsig");
		JarOutputStream jarOutput = null;
		JarInputStream jarInput = null;
		try {
			jarOutput = new JarOutputStream(new FileOutputStream(tempFile));
			jarOutput.setLevel(Deflater.BEST_COMPRESSION);
			jarInput = new JarInputStream(new FileInputStream(jarFile));
			Manifest manifest = jarInput.getManifest();
			if (manifest != null) {
				// Remove manifest file entries.
				manifest.getEntries().clear();
				jarOutput.putNextEntry(new JarEntry(manifestFileName));
				manifest.write(jarOutput);
			}
			byte[] buffer = new byte[4096];
			while (true) {
				JarEntry entry = jarInput.getNextJarEntry();
				if (entry == null) break;
				String name = entry.getName();
				// Skip signature files.
				if (name.startsWith("META-INF") && (name.endsWith(".SF") || name.endsWith(".DSA") || name.endsWith(".RSA"))) continue;
				jarOutput.putNextEntry(new JarEntry(name));
				while (true) {
					int length = jarInput.read(buffer);
					if (length == -1) break;
					jarOutput.write(buffer, 0, length);
				}
			}
			jarInput.close();
			jarOutput.close();
			copyFile(tempFile.getAbsolutePath(), jarFile);
		} catch (IOException ex) {
			throw new IOException("Error unsigning JAR file: " + jarFile, ex);
		} finally {
			try {
				if (jarInput != null) jarInput.close();
			} catch (Exception ignored) {
			}
			try {
				if (jarOutput != null) jarOutput.close();
			} catch (Exception ignored) {
			}
			tempFile.delete();
		}
		return jarFile;
	}
/** Removes any code signatures on the specified JAR. Removes any signature files in the META-INF directory and removes any
	 * signature entries from the JAR's manifest.
	 * @return The path to the JAR file. */
Removes any code signatures on the specified JAR. Removes any signature files in the META-INF directory and removes any
signature entries from the JAR's manifest.
@return The path to the JAR file.
Removes any code signatures on the specified JAR . Removes any signature files in the META - INF directory and removes any signature entries from the JAR ' s manifest . @return The path to the JAR file .
static public String unsign (String jarFile) throws IOException {
		if (jarFile == null) throw new IllegalArgumentException("jarFile cannot be null.");
		if (DEBUG) debug("scar", "Removing signature from JAR: " + jarFile);
		File tempFile = File.createTempFile("scar", "removejarsig");
		JarOutputStream jarOutput = null;
		JarInputStream jarInput = null;
		try {
			jarOutput = new JarOutputStream(new FileOutputStream(tempFile));
			jarOutput.setLevel(Deflater.BEST_COMPRESSION);
			jarInput = new JarInputStream(new FileInputStream(jarFile));
			Manifest manifest = jarInput.getManifest();
			if (manifest != null) {
				manifest.getEntries().clear();
				jarOutput.putNextEntry(new JarEntry(manifestFileName));
				manifest.write(jarOutput);
			}
			byte[] buffer = new byte[4096];
			while (true) {
				JarEntry entry = jarInput.getNextJarEntry();
				if (entry == null) break;
				String name = entry.getName();
				if (name.startsWith("META-INF") && (name.endsWith(".SF") || name.endsWith(".DSA") || name.endsWith(".RSA"))) continue;
				jarOutput.putNextEntry(new JarEntry(name));
				while (true) {
					int length = jarInput.read(buffer);
					if (length == -1) break;
					jarOutput.write(buffer, 0, length);
				}
			}
			jarInput.close();
			jarOutput.close();
			copyFile(tempFile.getAbsolutePath(), jarFile);
		} catch (IOException ex) {
			throw new IOException("Error unsigning JAR file: " + jarFile, ex);
		} finally {
			try {
				if (jarInput != null) jarInput.close();
			} catch (Exception ignored) {
			}
			try {
				if (jarOutput != null) jarOutput.close();
			} catch (Exception ignored) {
			}
			tempFile.delete();
		}
		return jarFile;
	}
static public String unsign ( String jarFile ) throws IOException { if ( jarFile == null ) throw new IllegalArgumentException ( "jarFile cannot be null." ) ; if ( DEBUG ) debug ( "scar" , "Removing signature from JAR: " + jarFile ) ; File tempFile = File . createTempFile ( "scar" , "removejarsig" ) ; JarOutputStream jarOutput = null ; JarInputStream jarInput = null ; try { jarOutput = new JarOutputStream ( new FileOutputStream ( tempFile ) ) ; jarOutput . setLevel ( Deflater . BEST_COMPRESSION ) ; jarInput = new JarInputStream ( new FileInputStream ( jarFile ) ) ; Manifest manifest = jarInput . getManifest ( ) ; if ( manifest != null ) { manifest . getEntries ( ) . clear ( ) ; jarOutput . putNextEntry ( new JarEntry ( manifestFileName ) ) ; manifest . write ( jarOutput ) ; } byte [ ] buffer = new byte [ 4096 ] ; while ( true ) { JarEntry entry = jarInput . getNextJarEntry ( ) ; if ( entry == null ) break ; String name = entry . getName ( ) ; if ( name . startsWith ( "META-INF" ) && ( name . endsWith ( ".SF" ) || name . endsWith ( ".DSA" ) || name . endsWith ( ".RSA" ) ) ) continue ; jarOutput . putNextEntry ( new JarEntry ( name ) ) ; while ( true ) { int length = jarInput . read ( buffer ) ; if ( length == - 1 ) break ; jarOutput . write ( buffer , 0 , length ) ; } } jarInput . close ( ) ; jarOutput . close ( ) ; copyFile ( tempFile . getAbsolutePath ( ) , jarFile ) ; } catch ( IOException ex ) { throw new IOException ( "Error unsigning JAR file: " + jarFile , ex ) ; } finally { try { if ( jarInput != null ) jarInput . close ( ) ; } catch ( Exception ignored ) { } try { if ( jarOutput != null ) jarOutput . close ( ) ; } catch ( Exception ignored ) { } tempFile . delete ( ) ; } return jarFile ; }
Removes any code signatures on the specified JAR.
Removes any code signatures on the specified JAR .
// Remove manifest file entries. // Skip signature files.