docs: add javadoc
This commit is contained in:
@@ -68,6 +68,19 @@ public interface KeyLoader {
|
|||||||
throw new KeyLoadingException("This key loader does not support loading an RSA public key.");
|
throw new KeyLoadingException("This key loader does not support loading an RSA public key.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads an EC public key using the provided x and y coordinates together with the curve name.
|
||||||
|
* <p>
|
||||||
|
* This default implementation throws a {@link KeyLoadingException} to signify that this key loader does not support
|
||||||
|
* loading an EC public key. Implementing classes are expected to override this method to supply their own
|
||||||
|
* loading logic.
|
||||||
|
*
|
||||||
|
* @param xHex the hexadecimal string representing the x coordinate of the EC point
|
||||||
|
* @param yHex the hexadecimal string representing the y coordinate of the EC point
|
||||||
|
* @param curveName the name of the elliptic curve
|
||||||
|
* @return the loaded {@link ECPublicKey} instance
|
||||||
|
* @throws KeyLoadingException if loading is not supported or fails
|
||||||
|
*/
|
||||||
default ECPublicKey loadPublicKey(String xHex, String yHex, String curveName) {
|
default ECPublicKey loadPublicKey(String xHex, String yHex, String curveName) {
|
||||||
throw new KeyLoadingException("This key loader does not support loading an EC public key.");
|
throw new KeyLoadingException("This key loader does not support loading an EC public key.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,23 @@ public class ECKeyLoader implements KeyLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads an EC public key from the given hexadecimal x and y coordinates alongside the curve name.
|
||||||
|
* <p>
|
||||||
|
* This method converts the hexadecimal string representations of the EC point coordinates into {@link BigInteger}
|
||||||
|
* instances, then constructs an {@link ECPoint} and retrieves the corresponding {@link ECParameterSpec} for the
|
||||||
|
* named curve. Subsequently, it utilises the {@link KeyFactory} to generate an {@link ECPublicKey}.
|
||||||
|
* <p>
|
||||||
|
* Only curves listed in {@link #SUPPORTED_CURVES} are supported. Should the specified curve name be unsupported,
|
||||||
|
* or if key construction fails due to invalid parameters or unsupported algorithms, a {@link KeyLoadingException}
|
||||||
|
* will be thrown.
|
||||||
|
*
|
||||||
|
* @param xHex the hexadecimal string representing the x-coordinate of the EC point
|
||||||
|
* @param yHex the hexadecimal string representing the y-coordinate of the EC point
|
||||||
|
* @param curveName the name of the elliptic curve
|
||||||
|
* @return the {@link ECPublicKey} generated from the specified coordinates and curve
|
||||||
|
* @throws KeyLoadingException if the curve is unsupported or key generation fails
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ECPublicKey loadPublicKey(String xHex, String yHex, String curveName) {
|
public ECPublicKey loadPublicKey(String xHex, String yHex, String curveName) {
|
||||||
if (!SUPPORTED_CURVES.contains(curveName)) {
|
if (!SUPPORTED_CURVES.contains(curveName)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user