maybevanshh commented on code in PR #8890:
URL: https://github.com/apache/nifi/pull/8890#discussion_r1622321295
##########
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:
I removed the seperate function for jwt and used JWTTokenProvider for token
generation.
--
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]