@@ -42,11 +42,15 @@ public class JWTTokenProvider implements AuthorizationProvider {
42
42
private final String applicationId ;
43
43
44
44
public JWTTokenProvider (String applicationId , File keyFile ) throws GeneralSecurityException , IOException {
45
- this (applicationId , loadPrivateKey ( keyFile .toPath () ));
45
+ this (applicationId , keyFile .toPath ());
46
46
}
47
47
48
48
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 ));
50
54
}
51
55
52
56
public JWTTokenProvider (String applicationId , PrivateKey privateKey ) {
@@ -64,18 +68,6 @@ public String getEncodedAuthorization() throws IOException {
64
68
}
65
69
}
66
70
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
-
79
71
/**
80
72
* Convert a PKCS#8 formatted private key in string format into a java PrivateKey
81
73
*
0 commit comments