@@ -42,11 +42,15 @@ public class JWTTokenProvider implements AuthorizationProvider {
4242 private final String applicationId ;
4343
4444 public JWTTokenProvider (String applicationId , File keyFile ) throws GeneralSecurityException , IOException {
45- this (applicationId , loadPrivateKey ( keyFile .toPath () ));
45+ this (applicationId , keyFile .toPath ());
4646 }
4747
4848 public JWTTokenProvider (String applicationId , Path keyPath ) throws GeneralSecurityException , IOException {
49- this (applicationId , loadPrivateKey (keyPath ));
49+ this (applicationId , new String (Files .readAllBytes (keyPath ), StandardCharsets .UTF_8 ));
50+ }
51+
52+ public JWTTokenProvider (String applicationId , String keyString ) throws GeneralSecurityException {
53+ this (applicationId , getPrivateKeyFromString (keyString ));
5054 }
5155
5256 public JWTTokenProvider (String applicationId , PrivateKey privateKey ) {
@@ -64,18 +68,6 @@ public String getEncodedAuthorization() throws IOException {
6468 }
6569 }
6670
67- /**
68- * add dependencies for a jwt suite You can generate a key to load in this method with:
69- *
70- * <pre>
71- * openssl pkcs8 -topk8 -inform PEM -outform DER -in ~/github-api-app.private-key.pem -out ~/github-api-app.private-key.der -nocrypt
72- * </pre>
73- */
74- private static PrivateKey loadPrivateKey (Path keyPath ) throws GeneralSecurityException , IOException {
75- String keyString = new String (Files .readAllBytes (keyPath ), StandardCharsets .UTF_8 );
76- return getPrivateKeyFromString (keyString );
77- }
78-
7971 /**
8072 * Convert a PKCS#8 formatted private key in string format into a java PrivateKey
8173 *
0 commit comments