exceptionfactory commented on code in PR #8890:
URL: https://github.com/apache/nifi/pull/8890#discussion_r1619437365
##########
nifi-extension-bundles/nifi-github-bundle/nifi-github-extensions/src/main/java/org/apache/nifi/github/GitHubRepositoryClient.java:
##########
@@ -379,6 +392,41 @@ public GHContent deleteContent(final String filePath,
final String commitMessage
});
}
+ /**
+ * Creates the JwtToken for Authentication with Private Key
+ *
+ * @param pemString is the PKCS#1 String
+ * @return the JwtToken
+ *
+ * @throws Exception if an error occurs parsing key
+ */
+ private static String loadPrivateKeyFromPEM(String pemString) throws
Exception {
+ long nowMillis = System.currentTimeMillis();
+ long expMillis = nowMillis + 600000; // Token validity 10 minutes
+ Date now = new Date(nowMillis);
+ Date exp = new Date(expMillis);
+ PEMParser pemParser = new PEMParser(new StringReader(pemString));
+ Object object = pemParser.readObject();
+ pemParser.close();
+
+ if (object instanceof PEMKeyPair) {
+ PEMKeyPair keyPair = (PEMKeyPair) object;
+ RSAPrivateKey rsaPrivateKey =
RSAPrivateKey.getInstance(keyPair.getPrivateKeyInfo().parsePrivateKey());
+ PKCS8EncodedKeySpec keySpec = new
PKCS8EncodedKeySpec(rsaPrivateKey.getEncoded());
Review Comment:
On further research, there are some options for reading PKCS 1 RSA private
keys with standard Java `KeyFactory` methods. If you can address some of the
other comments, I could add a commit to implement that element of key parsing,
which would still enable using the utility method from the github-api library,
using `PrivateKey` objects.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]