src/com/esotericsoftware/scar/Jar.java
static public String keystore (String keystoreFile, String alias, String password, String company, String title)
		throws IOException {
		if (keystoreFile == null) throw new IllegalArgumentException("keystoreFile cannot be null.");
		if (fileExists(keystoreFile)) return keystoreFile;
		if (alias == null) throw new IllegalArgumentException("alias cannot be null.");
		if (password == null) throw new IllegalArgumentException("password cannot be null.");
		if (password.length() < 6) throw new IllegalArgumentException("password must be 6 or more characters.");
		if (company == null) throw new IllegalArgumentException("company cannot be null.");
		if (title == null) throw new IllegalArgumentException("title cannot be null.");

		if (DEBUG)
			debug("scar", "Creating keystore (" + alias + ":" + password + ", " + company + ", " + title + "): " + keystoreFile);

		File file = new File(keystoreFile);
		file.delete();
		Process process = Runtime.getRuntime()
			.exec(new String[] {resolvePath("keytool"), "-genkey", "-keystore", keystoreFile, "-alias", alias});
		OutputStreamWriter writer = new OutputStreamWriter(process.getOutputStream());
		writer.write(password + "\n"); // Enter keystore password:
		writer.write(password + "\n"); // Re-enter new password:
		writer.write(company + "\n"); // What is your first and last name?
		writer.write(title + "\n"); // What is the name of your organizational unit?
		writer.write(title + "\n"); // What is the name of your organization?
		writer.write("\n"); // What is the name of your City or Locality? [Unknown]
		writer.write("\n"); // What is the name of your State or Province? [Unknown]
		writer.write("\n"); // What is the two-letter country code for this unit? [Unknown]
		writer.write("yes\n"); // Correct?
		writer.write("\n"); // Return if same alias key password as keystore.
		writer.flush();
		process.getOutputStream().close();
		process.getInputStream().close();
		process.getErrorStream().close();
		try {
			process.waitFor();
		} catch (InterruptedException ignored) {
		}
		if (!file.exists()) throw new RuntimeException("Error creating keystore.");
		return keystoreFile;
	}
/** Creates a new keystore for signing JARs. If the keystore file already exists, no action will be taken.
	 * @return The path to the keystore file. */
Creates a new keystore for signing JARs. If the keystore file already exists, no action will be taken.
@return The path to the keystore file.
Creates a new keystore for signing JARs . If the keystore file already exists no action will be taken . @return The path to the keystore file .
static public String keystore (String keystoreFile, String alias, String password, String company, String title)
		throws IOException {
		if (keystoreFile == null) throw new IllegalArgumentException("keystoreFile cannot be null.");
		if (fileExists(keystoreFile)) return keystoreFile;
		if (alias == null) throw new IllegalArgumentException("alias cannot be null.");
		if (password == null) throw new IllegalArgumentException("password cannot be null.");
		if (password.length() < 6) throw new IllegalArgumentException("password must be 6 or more characters.");
		if (company == null) throw new IllegalArgumentException("company cannot be null.");
		if (title == null) throw new IllegalArgumentException("title cannot be null.");
		if (DEBUG)
			debug("scar", "Creating keystore (" + alias + ":" + password + ", " + company + ", " + title + "): " + keystoreFile);
		File file = new File(keystoreFile);
		file.delete();
		Process process = Runtime.getRuntime()
			.exec(new String[] {resolvePath("keytool"), "-genkey", "-keystore", keystoreFile, "-alias", alias});
		OutputStreamWriter writer = new OutputStreamWriter(process.getOutputStream());
		writer.write(password + "\n"); 
		writer.write(password + "\n"); 
		writer.write(company + "\n"); 
		writer.write(title + "\n"); 
		writer.write(title + "\n"); 
		writer.write("\n"); 
		writer.write("\n"); 
		writer.write("\n"); 
		writer.write("yes\n"); 
		writer.write("\n"); 
		writer.flush();
		process.getOutputStream().close();
		process.getInputStream().close();
		process.getErrorStream().close();
		try {
			process.waitFor();
		} catch (InterruptedException ignored) {
		}
		if (!file.exists()) throw new RuntimeException("Error creating keystore.");
		return keystoreFile;
	}
static public String keystore ( String keystoreFile , String alias , String password , String company , String title ) throws IOException { if ( keystoreFile == null ) throw new IllegalArgumentException ( "keystoreFile cannot be null." ) ; if ( fileExists ( keystoreFile ) ) return keystoreFile ; if ( alias == null ) throw new IllegalArgumentException ( "alias cannot be null." ) ; if ( password == null ) throw new IllegalArgumentException ( "password cannot be null." ) ; if ( password . length ( ) < 6 ) throw new IllegalArgumentException ( "password must be 6 or more characters." ) ; if ( company == null ) throw new IllegalArgumentException ( "company cannot be null." ) ; if ( title == null ) throw new IllegalArgumentException ( "title cannot be null." ) ; if ( DEBUG ) debug ( "scar" , "Creating keystore (" + alias + ":" + password + ", " + company + ", " + title + "): " + keystoreFile ) ; File file = new File ( keystoreFile ) ; file . delete ( ) ; Process process = Runtime . getRuntime ( ) . exec ( new String [ ] { resolvePath ( "keytool" ) , "-genkey" , "-keystore" , keystoreFile , "-alias" , alias } ) ; OutputStreamWriter writer = new OutputStreamWriter ( process . getOutputStream ( ) ) ; writer . write ( password + "\n" ) ; writer . write ( password + "\n" ) ; writer . write ( company + "\n" ) ; writer . write ( title + "\n" ) ; writer . write ( title + "\n" ) ; writer . write ( "\n" ) ; writer . write ( "\n" ) ; writer . write ( "\n" ) ; writer . write ( "yes\n" ) ; writer . write ( "\n" ) ; writer . flush ( ) ; process . getOutputStream ( ) . close ( ) ; process . getInputStream ( ) . close ( ) ; process . getErrorStream ( ) . close ( ) ; try { process . waitFor ( ) ; } catch ( InterruptedException ignored ) { } if ( ! file . exists ( ) ) throw new RuntimeException ( "Error creating keystore." ) ; return keystoreFile ; }
Creates a new keystore for signing JARs.
Creates a new keystore for signing JARs .
// Enter keystore password: // Re-enter new password: // What is your first and last name? // What is the name of your organizational unit? // What is the name of your organization? // What is the name of your City or Locality? [Unknown] // What is the name of your State or Province? [Unknown] // What is the two-letter country code for this unit? [Unknown] // Correct? // Return if same alias key password as keystore.