@@ -28,6 +28,18 @@ public static Algorithm RSA256(RSAKeyProvider keyProvider) throws IllegalArgumen
2828 return new RSAAlgorithm ("RS256" , "SHA256withRSA" , keyProvider );
2929 }
3030
31+ /**
32+ * Creates a new Algorithm instance using SHA256withRSA. Tokens specify this as "RS256".
33+ *
34+ * @param publicKey the key to use in the verify instance.
35+ * @param privateKey the key to use in the signing instance.
36+ * @return a valid RSA256 Algorithm.
37+ * @throws IllegalArgumentException if both provided Keys are null.
38+ */
39+ public static Algorithm RSA256 (RSAPublicKey publicKey , RSAPrivateKey privateKey ) throws IllegalArgumentException {
40+ return new RSAAlgorithm ("RS256" , "SHA256withRSA" , publicKey , privateKey );
41+ }
42+
3143 /**
3244 * Creates a new Algorithm instance using SHA256withRSA. Tokens specify this as "RS256".
3345 *
@@ -46,66 +58,50 @@ public static Algorithm RSA256(RSAKey key) throws IllegalArgumentException {
4658 /**
4759 * Creates a new Algorithm instance using SHA384withRSA. Tokens specify this as "RS384".
4860 *
49- * @param key the key to use in the verify or signing instance.
61+ * @param keyProvider the provider of the Public Key and Private Key for the verify and signing instance.
5062 * @return a valid RSA384 Algorithm.
51- * @throws IllegalArgumentException if the provided Key is null.
52- * @deprecated use {@link #RSA384(RSAPublicKey, RSAPrivateKey)}
63+ * @throws IllegalArgumentException if the Key Provider is null.
5364 */
54- @ Deprecated
55- public static Algorithm RSA384 (RSAKey key ) throws IllegalArgumentException {
56- RSAPublicKey publicKey = key instanceof RSAPublicKey ? (RSAPublicKey ) key : null ;
57- RSAPrivateKey privateKey = key instanceof RSAPrivateKey ? (RSAPrivateKey ) key : null ;
58- return RSA384 (publicKey , privateKey );
65+ public static Algorithm RSA384 (RSAKeyProvider keyProvider ) throws IllegalArgumentException {
66+ return new RSAAlgorithm ("RS384" , "SHA384withRSA" , keyProvider );
5967 }
6068
6169 /**
6270 * Creates a new Algorithm instance using SHA384withRSA. Tokens specify this as "RS384".
6371 *
64- * @param keyProvider the provider of the Public Key and Private Key for the verify and signing instance.
72+ * @param publicKey the key to use in the verify instance.
73+ * @param privateKey the key to use in the signing instance.
6574 * @return a valid RSA384 Algorithm.
66- * @throws IllegalArgumentException if the Key Provider is null.
75+ * @throws IllegalArgumentException if both provided Keys are null.
6776 */
68- public static Algorithm RSA384 (RSAKeyProvider keyProvider ) throws IllegalArgumentException {
69- return new RSAAlgorithm ("RS384" , "SHA384withRSA" , keyProvider );
77+ public static Algorithm RSA384 (RSAPublicKey publicKey , RSAPrivateKey privateKey ) throws IllegalArgumentException {
78+ return new RSAAlgorithm ("RS384" , "SHA384withRSA" , publicKey , privateKey );
7079 }
7180
7281 /**
73- * Creates a new Algorithm instance using SHA512withRSA . Tokens specify this as "RS512 ".
82+ * Creates a new Algorithm instance using SHA384withRSA . Tokens specify this as "RS384 ".
7483 *
7584 * @param key the key to use in the verify or signing instance.
76- * @return a valid RSA512 Algorithm.
85+ * @return a valid RSA384 Algorithm.
7786 * @throws IllegalArgumentException if the provided Key is null.
78- * @deprecated use {@link #RSA512 (RSAPublicKey, RSAPrivateKey)}
87+ * @deprecated use {@link #RSA384 (RSAPublicKey, RSAPrivateKey)}
7988 */
8089 @ Deprecated
81- public static Algorithm RSA512 (RSAKey key ) throws IllegalArgumentException {
90+ public static Algorithm RSA384 (RSAKey key ) throws IllegalArgumentException {
8291 RSAPublicKey publicKey = key instanceof RSAPublicKey ? (RSAPublicKey ) key : null ;
8392 RSAPrivateKey privateKey = key instanceof RSAPrivateKey ? (RSAPrivateKey ) key : null ;
84- return RSA512 (publicKey , privateKey );
85- }
86-
87- /**
88- * Creates a new Algorithm instance using SHA256withRSA. Tokens specify this as "RS256".
89- *
90- * @param publicKey the key to use in the verify instance.
91- * @param privateKey the key to use in the signing instance.
92- * @return a valid RSA256 Algorithm.
93- * @throws IllegalArgumentException if both provided Keys are null.
94- */
95- public static Algorithm RSA256 (RSAPublicKey publicKey , RSAPrivateKey privateKey ) throws IllegalArgumentException {
96- return new RSAAlgorithm ("RS256" , "SHA256withRSA" , publicKey , privateKey );
93+ return RSA384 (publicKey , privateKey );
9794 }
9895
9996 /**
100- * Creates a new Algorithm instance using SHA384withRSA . Tokens specify this as "RS384 ".
97+ * Creates a new Algorithm instance using SHA512withRSA . Tokens specify this as "RS512 ".
10198 *
102- * @param publicKey the key to use in the verify instance.
103- * @param privateKey the key to use in the signing instance.
104- * @return a valid RSA384 Algorithm.
105- * @throws IllegalArgumentException if both provided Keys are null.
99+ * @param keyProvider the provider of the Public Key and Private Key for the verify and signing instance.
100+ * @return a valid RSA512 Algorithm.
101+ * @throws IllegalArgumentException if the Key Provider is null.
106102 */
107- public static Algorithm RSA384 ( RSAPublicKey publicKey , RSAPrivateKey privateKey ) throws IllegalArgumentException {
108- return new RSAAlgorithm ("RS384 " , "SHA384withRSA " , publicKey , privateKey );
103+ public static Algorithm RSA512 ( RSAKeyProvider keyProvider ) throws IllegalArgumentException {
104+ return new RSAAlgorithm ("RS512 " , "SHA512withRSA " , keyProvider );
109105 }
110106
111107 /**
@@ -123,12 +119,16 @@ public static Algorithm RSA512(RSAPublicKey publicKey, RSAPrivateKey privateKey)
123119 /**
124120 * Creates a new Algorithm instance using SHA512withRSA. Tokens specify this as "RS512".
125121 *
126- * @param keyProvider the provider of the Public Key and Private Key for the verify and signing instance.
122+ * @param key the key to use in the verify or signing instance.
127123 * @return a valid RSA512 Algorithm.
128- * @throws IllegalArgumentException if the Key Provider is null.
124+ * @throws IllegalArgumentException if the provided Key is null.
125+ * @deprecated use {@link #RSA512(RSAPublicKey, RSAPrivateKey)}
129126 */
130- public static Algorithm RSA512 (RSAKeyProvider keyProvider ) throws IllegalArgumentException {
131- return new RSAAlgorithm ("RS512" , "SHA512withRSA" , keyProvider );
127+ @ Deprecated
128+ public static Algorithm RSA512 (RSAKey key ) throws IllegalArgumentException {
129+ RSAPublicKey publicKey = key instanceof RSAPublicKey ? (RSAPublicKey ) key : null ;
130+ RSAPrivateKey privateKey = key instanceof RSAPrivateKey ? (RSAPrivateKey ) key : null ;
131+ return RSA512 (publicKey , privateKey );
132132 }
133133
134134 /**
@@ -203,42 +203,39 @@ public static Algorithm HMAC512(byte[] secret) throws IllegalArgumentException {
203203 /**
204204 * Creates a new Algorithm instance using SHA256withECDSA. Tokens specify this as "ES256".
205205 *
206- * @param key the key to use in the verify or signing instance.
206+ * @param keyProvider the provider of the Public Key and Private Key for the verify and signing instance.
207207 * @return a valid ECDSA256 Algorithm.
208- * @throws IllegalArgumentException if the provided Key is null.
209- * @deprecated use {@link #ECDSA256(ECPublicKey, ECPrivateKey)}
208+ * @throws IllegalArgumentException if the Key Provider is null.
210209 */
211- @ Deprecated
212- public static Algorithm ECDSA256 (ECKey key ) throws IllegalArgumentException {
213- ECPublicKey publicKey = key instanceof ECPublicKey ? (ECPublicKey ) key : null ;
214- ECPrivateKey privateKey = key instanceof ECPrivateKey ? (ECPrivateKey ) key : null ;
215- return ECDSA256 (publicKey , privateKey );
210+ public static Algorithm ECDSA256 (ECKeyProvider keyProvider ) throws IllegalArgumentException {
211+ return new ECDSAAlgorithm ("ES256" , "SHA256withECDSA" , 32 , keyProvider );
216212 }
217213
218214 /**
219215 * Creates a new Algorithm instance using SHA256withECDSA. Tokens specify this as "ES256".
220216 *
221- * @param keyProvider the provider of the Public Key and Private Key for the verify and signing instance.
217+ * @param publicKey the key to use in the verify instance.
218+ * @param privateKey the key to use in the signing instance.
222219 * @return a valid ECDSA256 Algorithm.
223- * @throws IllegalArgumentException if the Key Provider is null.
220+ * @throws IllegalArgumentException if the provided Key is null.
224221 */
225- public static Algorithm ECDSA256 (ECKeyProvider keyProvider ) throws IllegalArgumentException {
226- return new ECDSAAlgorithm ("ES256" , "SHA256withECDSA" , 32 , keyProvider );
222+ public static Algorithm ECDSA256 (ECPublicKey publicKey , ECPrivateKey privateKey ) throws IllegalArgumentException {
223+ return new ECDSAAlgorithm ("ES256" , "SHA256withECDSA" , 32 , publicKey , privateKey );
227224 }
228225
229226 /**
230- * Creates a new Algorithm instance using SHA384withECDSA . Tokens specify this as "ES384 ".
227+ * Creates a new Algorithm instance using SHA256withECDSA . Tokens specify this as "ES256 ".
231228 *
232229 * @param key the key to use in the verify or signing instance.
233- * @return a valid ECDSA384 Algorithm.
230+ * @return a valid ECDSA256 Algorithm.
234231 * @throws IllegalArgumentException if the provided Key is null.
235- * @deprecated use {@link #ECDSA384 (ECPublicKey, ECPrivateKey)}
232+ * @deprecated use {@link #ECDSA256 (ECPublicKey, ECPrivateKey)}
236233 */
237234 @ Deprecated
238- public static Algorithm ECDSA384 (ECKey key ) throws IllegalArgumentException {
235+ public static Algorithm ECDSA256 (ECKey key ) throws IllegalArgumentException {
239236 ECPublicKey publicKey = key instanceof ECPublicKey ? (ECPublicKey ) key : null ;
240237 ECPrivateKey privateKey = key instanceof ECPrivateKey ? (ECPrivateKey ) key : null ;
241- return ECDSA384 (publicKey , privateKey );
238+ return ECDSA256 (publicKey , privateKey );
242239 }
243240
244241 /**
@@ -253,42 +250,41 @@ public static Algorithm ECDSA384(ECKeyProvider keyProvider) throws IllegalArgume
253250 }
254251
255252 /**
256- * Creates a new Algorithm instance using SHA512withECDSA . Tokens specify this as "ES512 ".
253+ * Creates a new Algorithm instance using SHA384withECDSA . Tokens specify this as "ES384 ".
257254 *
258- * @param key the key to use in the verify or signing instance.
259- * @return a valid ECDSA512 Algorithm.
255+ * @param publicKey the key to use in the verify instance.
256+ * @param privateKey the key to use in the signing instance.
257+ * @return a valid ECDSA384 Algorithm.
260258 * @throws IllegalArgumentException if the provided Key is null.
261- * @deprecated use {@link #ECDSA512(ECPublicKey, ECPrivateKey)}
262259 */
263- @ Deprecated
264- public static Algorithm ECDSA512 (ECKey key ) throws IllegalArgumentException {
265- ECPublicKey publicKey = key instanceof ECPublicKey ? (ECPublicKey ) key : null ;
266- ECPrivateKey privateKey = key instanceof ECPrivateKey ? (ECPrivateKey ) key : null ;
267- return ECDSA512 (publicKey , privateKey );
260+ public static Algorithm ECDSA384 (ECPublicKey publicKey , ECPrivateKey privateKey ) throws IllegalArgumentException {
261+ return new ECDSAAlgorithm ("ES384" , "SHA384withECDSA" , 48 , publicKey , privateKey );
268262 }
269263
270264 /**
271- * Creates a new Algorithm instance using SHA256withECDSA . Tokens specify this as "ES256 ".
265+ * Creates a new Algorithm instance using SHA384withECDSA . Tokens specify this as "ES384 ".
272266 *
273- * @param publicKey the key to use in the verify instance.
274- * @param privateKey the key to use in the signing instance.
275- * @return a valid ECDSA256 Algorithm.
267+ * @param key the key to use in the verify or signing instance.
268+ * @return a valid ECDSA384 Algorithm.
276269 * @throws IllegalArgumentException if the provided Key is null.
270+ * @deprecated use {@link #ECDSA384(ECPublicKey, ECPrivateKey)}
277271 */
278- public static Algorithm ECDSA256 (ECPublicKey publicKey , ECPrivateKey privateKey ) throws IllegalArgumentException {
279- return new ECDSAAlgorithm ("ES256" , "SHA256withECDSA" , 32 , publicKey , privateKey );
272+ @ Deprecated
273+ public static Algorithm ECDSA384 (ECKey key ) throws IllegalArgumentException {
274+ ECPublicKey publicKey = key instanceof ECPublicKey ? (ECPublicKey ) key : null ;
275+ ECPrivateKey privateKey = key instanceof ECPrivateKey ? (ECPrivateKey ) key : null ;
276+ return ECDSA384 (publicKey , privateKey );
280277 }
281278
282279 /**
283- * Creates a new Algorithm instance using SHA384withECDSA . Tokens specify this as "ES384 ".
280+ * Creates a new Algorithm instance using SHA512withECDSA . Tokens specify this as "ES512 ".
284281 *
285- * @param publicKey the key to use in the verify instance.
286- * @param privateKey the key to use in the signing instance.
287- * @return a valid ECDSA384 Algorithm.
288- * @throws IllegalArgumentException if the provided Key is null.
282+ * @param keyProvider the provider of the Public Key and Private Key for the verify and signing instance.
283+ * @return a valid ECDSA512 Algorithm.
284+ * @throws IllegalArgumentException if the Key Provider is null.
289285 */
290- public static Algorithm ECDSA384 ( ECPublicKey publicKey , ECPrivateKey privateKey ) throws IllegalArgumentException {
291- return new ECDSAAlgorithm ("ES384 " , "SHA384withECDSA " , 48 , publicKey , privateKey );
286+ public static Algorithm ECDSA512 ( ECKeyProvider keyProvider ) throws IllegalArgumentException {
287+ return new ECDSAAlgorithm ("ES512 " , "SHA512withECDSA " , 66 , keyProvider );
292288 }
293289
294290 /**
@@ -306,14 +302,19 @@ public static Algorithm ECDSA512(ECPublicKey publicKey, ECPrivateKey privateKey)
306302 /**
307303 * Creates a new Algorithm instance using SHA512withECDSA. Tokens specify this as "ES512".
308304 *
309- * @param keyProvider the provider of the Public Key and Private Key for the verify and signing instance.
305+ * @param key the key to use in the verify or signing instance.
310306 * @return a valid ECDSA512 Algorithm.
311- * @throws IllegalArgumentException if the Key Provider is null.
307+ * @throws IllegalArgumentException if the provided Key is null.
308+ * @deprecated use {@link #ECDSA512(ECPublicKey, ECPrivateKey)}
312309 */
313- public static Algorithm ECDSA512 (ECKeyProvider keyProvider ) throws IllegalArgumentException {
314- return new ECDSAAlgorithm ("ES512" , "SHA512withECDSA" , 66 , keyProvider );
310+ @ Deprecated
311+ public static Algorithm ECDSA512 (ECKey key ) throws IllegalArgumentException {
312+ ECPublicKey publicKey = key instanceof ECPublicKey ? (ECPublicKey ) key : null ;
313+ ECPrivateKey privateKey = key instanceof ECPrivateKey ? (ECPrivateKey ) key : null ;
314+ return ECDSA512 (publicKey , privateKey );
315315 }
316316
317+
317318 public static Algorithm none () {
318319 return new NoneAlgorithm ();
319320 }
0 commit comments