docs: added docs

This commit is contained in:
zihluwang
2025-01-18 14:06:13 +08:00
parent 566a960c14
commit a85c562b66
22 changed files with 357 additions and 147 deletions
@@ -30,7 +30,29 @@ import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
/**
* KeyLoader can load key pairs from PEM formated content.
* The {@code KeyLoader} class provides utility methods for loading ECDSA keys from PEM-formatted
* key text. This class supports loading both private and public keys.
* <p>
* The utility methods in this class are useful for scenarios where ECDSA keys need to be loaded
* from PEM-formatted strings for cryptographic operations.
* </p>
*
* <p><b>Example usage:</b></p>
* <pre>
* {@code
* String pemPrivateKey = """
* -----BEGIN PRIVATE KEY-----
* ...
* -----END PRIVATE KEY-----""";
* ECPrivateKey privateKey = KeyLoader.loadEcdsaPrivateKey(pemPrivateKey);
*
* String pemPublicKey = """
* -----BEGIN PUBLIC KEY-----
* ...
* -----END PUBLIC KEY-----""";
* ECPublicKey publicKey = KeyLoader.loadEcdsaPublicKey(pemPublicKey);
* }
* </pre>
*
* @author zihluwang
* @version 1.6.0
@@ -18,7 +18,25 @@
package com.onixbyte.security.exception;
/**
* {@code KeyLoadingException} is an exception indicating an error occurred while loading a key.
* The {@code KeyLoadingException} class represents an exception that is thrown when there is an error
* loading cryptographic keys. This exception can be used to indicate various issues such as invalid key
* specifications, unsupported key algorithms, or other key loading errors.
* <p>
* This class extends {@link RuntimeException}, allowing it to be thrown without being declared in a method's
* {@code throws} clause.
* </p>
*
* <p><b>Example usage:</b></p>
* <pre>
* {@code
* try {
* ECPrivateKey privateKey = KeyLoader.loadEcdsaPrivateKey(pemPrivateKey);
* } catch (KeyLoadingException e) {
* // Handle the exception
* e.printStackTrace();
* }
* }
* </pre>
*
* @author zihluwang
* @version 1.6.0