1
0
mirror of synced 2026-05-22 13:23:17 +00:00

Remove redundant classes

Issue gh-17880
This commit is contained in:
Joe Grandja
2025-09-10 16:48:23 -04:00
parent 8399bc161d
commit 098574c50e
8 changed files with 26 additions and 377 deletions
@@ -16,10 +16,13 @@
package org.springframework.security.oauth2.jose;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.interfaces.ECPrivateKey;
import java.security.interfaces.ECPublicKey;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.util.UUID;
import javax.crypto.SecretKey;
@@ -33,6 +36,17 @@ import com.nimbusds.jose.jwk.RSAKey;
*/
public final class TestJwks {
private static final KeyPairGenerator rsaKeyPairGenerator;
static {
try {
rsaKeyPairGenerator = KeyPairGenerator.getInstance("RSA");
rsaKeyPairGenerator.initialize(2048);
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
// @formatter:off
public static final RSAKey DEFAULT_RSA_JWK =
jwk(
@@ -59,6 +73,16 @@ public final class TestJwks {
private TestJwks() {
}
public static RSAKey.Builder generateRsa() {
KeyPair keyPair = rsaKeyPairGenerator.generateKeyPair();
RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
// @formatter:off
return jwk(publicKey, privateKey)
.keyID(UUID.randomUUID().toString());
// @formatter:on
}
public static RSAKey.Builder rsa() {
return jwk(TestKeys.DEFAULT_PUBLIC_KEY, TestKeys.DEFAULT_PRIVATE_KEY);
}