exceptionfactory commented on code in PR #8890:
URL: https://github.com/apache/nifi/pull/8890#discussion_r1622354948


##########
nifi-extension-bundles/nifi-github-bundle/nifi-github-extensions/src/main/java/org/apache/nifi/github/GitHubRepositoryClient.java:
##########
@@ -19,7 +19,12 @@
 
 package org.apache.nifi.github;
 
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
 import org.apache.nifi.registry.flow.FlowRegistryException;
+import org.bouncycastle.asn1.pkcs.RSAPrivateKey;
+import org.bouncycastle.openssl.PEMKeyPair;
+import org.bouncycastle.openssl.PEMParser;

Review Comment:
   These imports can be removed.



##########
nifi-extension-bundles/nifi-github-bundle/nifi-github-extensions/src/main/java/org/apache/nifi/github/GitHubRepositoryClient.java:
##########
@@ -74,6 +81,15 @@ private GitHubRepositoryClient(final Builder builder) throws 
IOException, FlowRe
         switch (authenticationType) {
             case PERSONAL_ACCESS_TOKEN -> 
gitHubBuilder.withOAuthToken(builder.personalAccessToken);
             case APP_INSTALLATION_TOKEN -> 
gitHubBuilder.withAppInstallationToken(builder.appInstallationToken);
+            case APP_INSTALLATION_ID_AND_PRIVATE_KEY -> {
+                try {
+                    JWTTokenProvider jwtTokenProvider = new 
JWTTokenProvider(builder().appId, builder().privateKey);
+                    String token = jwtTokenProvider.getEncodedAuthorization();
+                    gitHubBuilder.withJwtToken(token);
+                } catch (Exception e) {
+                    throw new FlowRegistryException(e.getMessage());

Review Comment:
   A custom message should be set, and the exception passed to the constructor 
to preserve the stack trace.
   ```suggestion
                       throw new FlowRegistryException("Failed to generate JWT 
from App ID and Private Key", e);
   ```



-- 
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]

Reply via email to