docs: add docs for loading RSA public key with modulus and exponent
This commit is contained in:
@@ -19,9 +19,11 @@ package com.onixbyte.security;
|
|||||||
|
|
||||||
import com.onixbyte.security.exception.KeyLoadingException;
|
import com.onixbyte.security.exception.KeyLoadingException;
|
||||||
|
|
||||||
|
import java.security.KeyFactory;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
import java.security.PublicKey;
|
import java.security.PublicKey;
|
||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
|
import java.security.spec.KeySpec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code KeyLoader} class provides utility methods for loading keys pairs from PEM-formatted
|
* The {@code KeyLoader} class provides utility methods for loading keys pairs from PEM-formatted
|
||||||
@@ -52,6 +54,15 @@ public interface KeyLoader {
|
|||||||
*/
|
*/
|
||||||
PublicKey loadPublicKey(String pemKeyText);
|
PublicKey loadPublicKey(String pemKeyText);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the public key with given modulus and public exponent.
|
||||||
|
*
|
||||||
|
* @param modulus the modulus
|
||||||
|
* @param exponent the public exponent
|
||||||
|
* @return generated public key object from the provided key specification
|
||||||
|
* @see KeyFactory#getInstance(String)
|
||||||
|
* @see KeyFactory#generatePublic(KeySpec)
|
||||||
|
*/
|
||||||
default RSAPublicKey loadPublicKey(String modulus, String exponent) {
|
default RSAPublicKey loadPublicKey(String modulus, String exponent) {
|
||||||
throw new KeyLoadingException("This key loader does not support RSA Public key loading.");
|
throw new KeyLoadingException("This key loader does not support RSA Public key loading.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,10 +25,7 @@ import java.security.KeyFactory;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.interfaces.RSAPrivateKey;
|
import java.security.interfaces.RSAPrivateKey;
|
||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
import java.security.spec.InvalidKeySpecException;
|
import java.security.spec.*;
|
||||||
import java.security.spec.PKCS8EncodedKeySpec;
|
|
||||||
import java.security.spec.RSAPublicKeySpec;
|
|
||||||
import java.security.spec.X509EncodedKeySpec;
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,6 +137,15 @@ public class RSAKeyLoader implements KeyLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the public key with given modulus and public exponent.
|
||||||
|
*
|
||||||
|
* @param modulus the modulus
|
||||||
|
* @param exponent the public exponent
|
||||||
|
* @return generated public key object from the provided key specification
|
||||||
|
* @see KeyFactory#getInstance(String)
|
||||||
|
* @see KeyFactory#generatePublic(KeySpec)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public RSAPublicKey loadPublicKey(String modulus, String exponent) {
|
public RSAPublicKey loadPublicKey(String modulus, String exponent) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user