@Test public void asciiBytesToChars() throws Exception { String asciiCharStr = "abcdefghijklmnop\n\t\r1234567890!@#$%^&*()`\'\"<>?:{}[];,./"; byte[] asciiBytes = asciiCharStr.getBytes(StandardCharsets.US_ASCII); char[] asciiChars = JreKeystoreGenerator.asciiBytesToChars(asciiBytes); assertArrayEquals("chars -> bytes -> chars", asciiCharStr.toCharArray(), asciiChars); }
@VisibleForTesting static char[] asciiBytesToChars(byte[] asciiBytes) { char[] chars = new char[asciiBytes.length]; for (int i = 0; i < chars.length; i++) { checkArgument(asciiBytes[i] >= 0 && asciiBytes[i] < 128, "char at index %s is not ascii: %s", i, asciiBytes[i]); chars[i] = (char) asciiBytes[i]; } return chars; }
JreKeystoreGenerator implements KeystoreGenerator { @VisibleForTesting static char[] asciiBytesToChars(byte[] asciiBytes) { char[] chars = new char[asciiBytes.length]; for (int i = 0; i < chars.length; i++) { checkArgument(asciiBytes[i] >= 0 && asciiBytes[i] < 128, "char at index %s is not ascii: %s", i, asciiBytes[i]); chars[i] = (char) asciiBytes[i]; } return chars; } }
JreKeystoreGenerator implements KeystoreGenerator { @VisibleForTesting static char[] asciiBytesToChars(byte[] asciiBytes) { char[] chars = new char[asciiBytes.length]; for (int i = 0; i < chars.length; i++) { checkArgument(asciiBytes[i] >= 0 && asciiBytes[i] < 128, "char at index %s is not ascii: %s", i, asciiBytes[i]); chars[i] = (char) asciiBytes[i]; } return chars; } JreKeystoreGenerator(KeystoreType keystoreType, Random random);  JreKeystoreGenerator(KeystoreType keystoreType); }
JreKeystoreGenerator implements KeystoreGenerator { @VisibleForTesting static char[] asciiBytesToChars(byte[] asciiBytes) { char[] chars = new char[asciiBytes.length]; for (int i = 0; i < chars.length; i++) { checkArgument(asciiBytes[i] >= 0 && asciiBytes[i] < 128, "char at index %s is not ascii: %s", i, asciiBytes[i]); chars[i] = (char) asciiBytes[i]; } return chars; } JreKeystoreGenerator(KeystoreType keystoreType, Random random);  JreKeystoreGenerator(KeystoreType keystoreType); @Override KeystoreData generate(); KeystoreData generate(@Nullable String certificateCommonName); }
JreKeystoreGenerator implements KeystoreGenerator { @VisibleForTesting static char[] asciiBytesToChars(byte[] asciiBytes) { char[] chars = new char[asciiBytes.length]; for (int i = 0; i < chars.length; i++) { checkArgument(asciiBytes[i] >= 0 && asciiBytes[i] < 128, "char at index %s is not ascii: %s", i, asciiBytes[i]); chars[i] = (char) asciiBytes[i]; } return chars; } JreKeystoreGenerator(KeystoreType keystoreType, Random random);  JreKeystoreGenerator(KeystoreType keystoreType); @Override KeystoreData generate(); KeystoreData generate(@Nullable String certificateCommonName);  }