@Test public void testMissingPassword() throws Exception { try { PVK.parse(new File("src/test/resources/keystores/privatekey-encrypted.pvk"), null); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException e) { assertEquals("exception message", "Unable to decrypt the PVK key, please verify the password", e.getMessage()); } }
public static PrivateKey parse(File file, String password) throws GeneralSecurityException, IOException { ByteBuffer buffer = ByteBuffer.allocate((int) file.length()); try (FileInputStream in = new FileInputStream(file)) { in.getChannel().read(buffer); return parse(buffer, password); } }
PVK { public static PrivateKey parse(File file, String password) throws GeneralSecurityException, IOException { ByteBuffer buffer = ByteBuffer.allocate((int) file.length()); try (FileInputStream in = new FileInputStream(file)) { in.getChannel().read(buffer); return parse(buffer, password); } } }
PVK { public static PrivateKey parse(File file, String password) throws GeneralSecurityException, IOException { ByteBuffer buffer = ByteBuffer.allocate((int) file.length()); try (FileInputStream in = new FileInputStream(file)) { in.getChannel().read(buffer); return parse(buffer, password); } } private  PVK(); }
PVK { public static PrivateKey parse(File file, String password) throws GeneralSecurityException, IOException { ByteBuffer buffer = ByteBuffer.allocate((int) file.length()); try (FileInputStream in = new FileInputStream(file)) { in.getChannel().read(buffer); return parse(buffer, password); } } private  PVK(); static PrivateKey parse(File file, String password); static PrivateKey parse(ByteBuffer buffer, String password); }
PVK { public static PrivateKey parse(File file, String password) throws GeneralSecurityException, IOException { ByteBuffer buffer = ByteBuffer.allocate((int) file.length()); try (FileInputStream in = new FileInputStream(file)) { in.getChannel().read(buffer); return parse(buffer, password); } } private  PVK(); static PrivateKey parse(File file, String password); static PrivateKey parse(ByteBuffer buffer, String password);  }