@Test public void testLoadWrongPEMObject() throws Exception { try { PrivateKeyUtils.load(new File("target/test-classes/keystores/jsign-test-certificate.pem"), null); fail("No exception thrown"); } catch (KeyException e) { Throwable cause = e.getCause(); assertEquals("exception message", "Unsupported PEM object: X509CertificateHolder", cause.getMessage()); } }
public static PrivateKey load(File file, String password) throws KeyException { try { if (file.getName().endsWith(".pvk")) { return PVK.parse(file, password); } else if (file.getName().endsWith(".pem")) { return readPrivateKeyPEM(file, password); } } catch (Exception e) { throw new KeyException("Failed to load the private key from " + file, e); } throw new IllegalArgumentException("Unsupported private key format (PEM or PVK file expected"); }
PrivateKeyUtils { public static PrivateKey load(File file, String password) throws KeyException { try { if (file.getName().endsWith(".pvk")) { return PVK.parse(file, password); } else if (file.getName().endsWith(".pem")) { return readPrivateKeyPEM(file, password); } } catch (Exception e) { throw new KeyException("Failed to load the private key from " + file, e); } throw new IllegalArgumentException("Unsupported private key format (PEM or PVK file expected"); } }
PrivateKeyUtils { public static PrivateKey load(File file, String password) throws KeyException { try { if (file.getName().endsWith(".pvk")) { return PVK.parse(file, password); } else if (file.getName().endsWith(".pem")) { return readPrivateKeyPEM(file, password); } } catch (Exception e) { throw new KeyException("Failed to load the private key from " + file, e); } throw new IllegalArgumentException("Unsupported private key format (PEM or PVK file expected"); } private  PrivateKeyUtils(); }
PrivateKeyUtils { public static PrivateKey load(File file, String password) throws KeyException { try { if (file.getName().endsWith(".pvk")) { return PVK.parse(file, password); } else if (file.getName().endsWith(".pem")) { return readPrivateKeyPEM(file, password); } } catch (Exception e) { throw new KeyException("Failed to load the private key from " + file, e); } throw new IllegalArgumentException("Unsupported private key format (PEM or PVK file expected"); } private  PrivateKeyUtils(); static PrivateKey load(File file, String password); }
PrivateKeyUtils { public static PrivateKey load(File file, String password) throws KeyException { try { if (file.getName().endsWith(".pvk")) { return PVK.parse(file, password); } else if (file.getName().endsWith(".pem")) { return readPrivateKeyPEM(file, password); } } catch (Exception e) { throw new KeyException("Failed to load the private key from " + file, e); } throw new IllegalArgumentException("Unsupported private key format (PEM or PVK file expected"); } private  PrivateKeyUtils(); static PrivateKey load(File file, String password);  }