### Question:
KeystoreManager { public PrivateKey readPlainPKCS8PrivateKey(File keyFile) throws IOException, InvalidKeySpecException, NoSuchAlgorithmException { KeyFactory keyFactory = KeyFactory.getInstance("RSA"); return keyFactory.generatePrivate(new PKCS8EncodedKeySpec(extractPrivateKeyBytes(Files.lines(keyFile.toPath())))); }  void copyCert(final File keyStore, final File trustStore, final String alias, final String masterPassword); KeyStore openKeyStore(File source, String storeType, char[] pw); void saveKeyStore(KeyStore keyStore, File dest, char[] pw); void addKeyPair(File keyStore, String storeType, char[] storePw, PrivateKey privKey, Certificate[] certChain, String alias); void addKeyPair(File keyStore, String storeType, char[] storePw, PrivateKey privKey, char[] keyPw, Certificate[] certChain,
            String alias); void changeKeyStorePassword(File keyStore, String storeType, char[] oldPw, char[] newPw); void changeKeyStorePassword(File keyStore, String storeType, char[] oldPw, char[] newPw, boolean changeKeyPasswords); void changeKeyPassword(File keyStore, String storeType, char[] storePw, String alias, char[] oldKeyPw, char[] newKeyPw); PrivateKey readPlainPKCS8PrivateKey(File keyFile); PrivateKey readPlainPKCS8PrivateKey(InputStream is, String algo); Collection<? extends Certificate> readPemCertificateChain(File pemFile); static String getDASCertDN(final RepositoryConfig cfg); static String getInstanceCertDN(final RepositoryConfig cfg); static final String CERTIFICATE_ALIAS; static final String INSTANCE_SECURE_ADMIN_ALIAS; static final String DEFAULT_MASTER_PASSWORD; }### Answer:
@Test public void testReadPemPrivateKeyAsInputStream() throws Exception { PrivateKey readPemPrivateKey = manager.readPlainPKCS8PrivateKey( this.getClass().getResourceAsStream("privatekey.key"), "RSA"); assertNotNull(readPemPrivateKey); }
@Test public void testReadPemPrivateKeyAsFile() throws Exception { PrivateKey readPemPrivateKey = manager.readPlainPKCS8PrivateKey( new File(this.getClass().getResource("privatekey.key").getFile())); assertNotNull(readPemPrivateKey); }