feat: extracted ECDSA key pair loader

This commit is contained in:
zihluwang
2025-01-26 18:47:46 +08:00
parent e28559a5f9
commit 5f9ea34af0
3 changed files with 137 additions and 77 deletions
@@ -20,6 +20,7 @@ package com.onixbyte.simplejwt.authzero;
import com.onixbyte.devkit.utils.Base64Util;
import com.onixbyte.guid.GuidCreator;
import com.onixbyte.security.KeyLoader;
import com.onixbyte.security.impl.EcKeyLoader;
import com.onixbyte.simplejwt.TokenPayload;
import com.onixbyte.simplejwt.TokenResolver;
import com.onixbyte.simplejwt.annotations.ExcludeFromPayload;
@@ -178,8 +179,9 @@ public class AuthzeroTokenResolver implements TokenResolver<DecodedJWT> {
* @return the builder instance
*/
public Builder keyPair(String publicKey, String privateKey) {
this.publicKey = KeyLoader.loadEcdsaPublicKey(publicKey);
this.privateKey = KeyLoader.loadEcdsaPrivateKey(privateKey);
var keyLoader = new EcKeyLoader();
this.publicKey = keyLoader.loadPublicKey(publicKey);
this.privateKey = keyLoader.loadPrivateKey(privateKey);
return this;
}