/** * Convenience method to determine if the current JVM is at least Java 1.4. * * @return <code>true</code> if the current JVM is at least Java 1.4 * @see #getMajorVersion() * @see #JAVA_14 * @see #JAVA_15 * @see #JAVA_16 * @see #JAVA_17 * @see #JAVA_18 */ public static boolean isAtLeastVersion14() { return getMajorVersion() >= JAVA_14; }
private static char[] readPassword(boolean confirm) { if (!JavaEnvironment.isAtLeastVersion16()) { String msg = "Password hashing (prompt without echo) uses the java.io.Console to read passwords " + "safely. This is only available on Java 1.6 platforms and later."; throw new IllegalArgumentException(msg); } java.io.Console console = System.console(); if (console == null) { throw new IllegalStateException("java.io.Console is not available on the current JVM. Cannot read passwords."); } char[] first = console.readPassword("%s", "Password to hash: "); if (first == null || first.length == 0) { throw new IllegalArgumentException("No password specified."); } if (confirm) { char[] second = console.readPassword("%s", "Password to hash (confirm): "); if (!Arrays.equals(first, second)) { String msg = "Password entries do not match."; throw new IllegalArgumentException(msg); } } return first; }
/** * Convenience method to determine if the current JVM is at least * Java 1.5 (Java 5). * * @return <code>true</code> if the current JVM is at least Java 1.5 * @see #getMajorVersion() * @see #JAVA_15 * @see #JAVA_16 * @see #JAVA_17 * @see #JAVA_18 */ public static boolean isAtLeastVersion15() { return getMajorVersion() >= JAVA_15; }
private static char[] readPassword(boolean confirm) { if (!JavaEnvironment.isAtLeastVersion16()) { String msg = "Password hashing (prompt without echo) uses the java.io.Console to read passwords " + "safely. This is only available on Java 1.6 platforms and later."; throw new IllegalArgumentException(msg); } java.io.Console console = System.console(); if (console == null) { throw new IllegalStateException("java.io.Console is not available on the current JVM. Cannot read passwords."); } char[] first = console.readPassword("%s", "Password to hash: "); if (first == null || first.length == 0) { throw new IllegalArgumentException("No password specified."); } if (confirm) { char[] second = console.readPassword("%s", "Password to hash (confirm): "); if (!Arrays.equals(first, second)) { String msg = "Password entries do not match."; throw new IllegalArgumentException(msg); } } return first; }
/** * Convenience method to determine if the current JVM is at least * Java 1.6 (Java 6). * * @return <code>true</code> if the current JVM is at least Java 1.6 * @see #getMajorVersion() * @see #JAVA_15 * @see #JAVA_16 * @see #JAVA_17 * @see #JAVA_18 * * @since 1.2 */ public static boolean isAtLeastVersion16() { return getMajorVersion() >= JAVA_16; } }
/** * Convenience method to determine if the current JVM is at least * Java 1.5 (Java 5). * * @return <code>true</code> if the current JVM is at least Java 1.5 * @see #getMajorVersion() * @see #JAVA_15 * @see #JAVA_16 * @see #JAVA_17 * @see #JAVA_18 */ public static boolean isAtLeastVersion15() { return getMajorVersion() >= JAVA_15; }
/** * Convenience method to determine if the current JVM is at least Java 1.4. * * @return <code>true</code> if the current JVM is at least Java 1.4 * @see #getMajorVersion() * @see #JAVA_14 * @see #JAVA_15 * @see #JAVA_16 * @see #JAVA_17 * @see #JAVA_18 */ public static boolean isAtLeastVersion14() { return getMajorVersion() >= JAVA_14; }
/** * Convenience method to determine if the current JVM is at least * Java 1.6 (Java 6). * * @return <code>true</code> if the current JVM is at least Java 1.6 * @see #getMajorVersion() * @see #JAVA_15 * @see #JAVA_16 * @see #JAVA_17 * @see #JAVA_18 * * @since 1.2 */ public static boolean isAtLeastVersion16() { return getMajorVersion() >= JAVA_16; } }
/** * Convenience method to determine if the current JVM is at least Java 1.4. * * @return <code>true</code> if the current JVM is at least Java 1.4 * @see #getMajorVersion() * @see #JAVA_14 * @see #JAVA_15 * @see #JAVA_16 * @see #JAVA_17 */ public static boolean isAtLeastVersion14() { return getMajorVersion() >= JAVA_14; }
/** * Convenience method to determine if the current JVM is at least * Java 1.5 (Java 5). * * @return <code>true</code> if the current JVM is at least Java 1.5 * @see #getMajorVersion() * @see #JAVA_15 * @see #JAVA_16 * @see #JAVA_17 */ public static boolean isAtLeastVersion15() { return getMajorVersion() >= JAVA_15; } }