@@ -66,39 +66,42 @@ public Algorithm toAlgorithm() throws JwksException
66
66
{
67
67
return switch (kty )
68
68
{
69
- case "RSA" -> {
69
+ case "RSA" -> toRsaAlgorithm ();
70
+ case "EC" -> toEcdsaAlgorithm ();
70
71
71
- RSAPublicKey key = toRsaPublicKey (n , e );
72
- RSAKeyProvider keyProvider = toRsaKeyProvider (key , kid );
73
-
74
- yield switch (alg )
75
- {
76
- case "RS256" -> Algorithm .RSA256 (keyProvider );
77
- case "RS384" -> Algorithm .RSA384 (keyProvider );
78
- case "RS512" -> Algorithm .RSA512 (keyProvider );
72
+ default -> throw new JwksException ("JWKS kty property value '" + kty + "' not one of 'RSA' or 'EC'" );
73
+ };
74
+ }
79
75
80
- default -> throw new JwksException (
81
- "JWKS alg property value '" + alg + "' not one of 'RSA256', 'RSA384' or 'RSA512'" );
82
- } ;
83
- }
76
+ private Algorithm toRsaAlgorithm ()
77
+ {
78
+ RSAPublicKey key = toRsaPublicKey ( n , e ) ;
79
+ RSAKeyProvider keyProvider = toRsaKeyProvider ( key , kid );
84
80
85
- case "EC" -> {
81
+ return switch (alg )
82
+ {
83
+ case "RS256" -> Algorithm .RSA256 (keyProvider );
84
+ case "RS384" -> Algorithm .RSA384 (keyProvider );
85
+ case "RS512" -> Algorithm .RSA512 (keyProvider );
86
86
87
- ECPublicKey key = toEcPublicKey (x , y , crv );
88
- ECDSAKeyProvider keyProvider = toEcKeyProvider (key , kid );
87
+ default -> throw new JwksException (
88
+ "JWKS alg property value '" + alg + "' not one of 'RSA256', 'RSA384' or 'RSA512'" );
89
+ };
90
+ }
89
91
90
- yield switch (alg )
91
- {
92
- case "ES256" -> Algorithm .ECDSA256 (keyProvider );
93
- case "ES384" -> Algorithm .ECDSA384 (keyProvider );
94
- case "ES512" -> Algorithm .ECDSA512 (keyProvider );
92
+ private Algorithm toEcdsaAlgorithm ()
93
+ {
94
+ ECPublicKey key = toEcPublicKey (x , y , crv );
95
+ ECDSAKeyProvider keyProvider = toEcKeyProvider (key , kid );
95
96
96
- default -> throw new JwksException (
97
- "JWKS crv property value '" + alg + "' not one of 'ES256', 'ES384' or 'ES512'" );
98
- };
99
- }
97
+ return switch (alg )
98
+ {
99
+ case "ES256" -> Algorithm .ECDSA256 (keyProvider );
100
+ case "ES384" -> Algorithm .ECDSA384 (keyProvider );
101
+ case "ES512" -> Algorithm .ECDSA512 (keyProvider );
100
102
101
- default -> throw new JwksException ("JWKS kty property value '" + kty + "' not one of 'RSA' or 'EC'" );
103
+ default -> throw new JwksException (
104
+ "JWKS crv property value '" + alg + "' not one of 'ES256', 'ES384' or 'ES512'" );
102
105
};
103
106
}
104
107
0 commit comments