public class Utility extends Object
| Constructor and Description |
|---|
Utility() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkAuthenticationValidation(String authenticationType)
Checks whether the authentication type is rightly entered with no typo error.
|
static String |
extractSerialNumber(X509Certificate x509Certificate) |
static X509Certificate |
getCertificateByAliasFromPKCS(String filePath,
char[] password,
String alias)
Retrieves a certificate by alias from a PKCS12 keystore.
|
static String |
getFileExtension(String fileName) |
static boolean |
isP12GeneratedByCyberSource(String filePath,
char[] password) |
static boolean |
isValidBooleanString(String value)
Helper method to validate if a string represents a valid boolean value.
|
static Collection<X509Certificate> |
loadCertificatesFromPemFile(String certFilePath)
Loads X509 certificates from a PEM file.
|
static PrivateKey |
loadPrivateKeyFromPemFile(String keyFilePath,
char[] password) |
static PrivateKey |
readPrivateKeyFromP12(String p12FilePath,
char[] password) |
static String |
retrieveGetIDFromRequestTarget(String requestTarget) |
static X509Certificate |
searchCertificateByAlias(Collection<X509Certificate> certs,
String keyAlias)
Searches for a certificate that matches the given key alias from a collection of certificates.
|
static void |
validateCertificateExpiry(X509Certificate certificate,
String keyAlias,
String mleCacheKeyIdentifier)
Validate the certificate expiry and log a warning if expired or expiring soon.
|
static void |
validatePathAndFile(String filePath,
String pathType)
Validates that the given file path exists and is not empty.
|
public static boolean checkAuthenticationValidation(String authenticationType)
authenticationType - HTTP or JWTpublic static String retrieveGetIDFromRequestTarget(String requestTarget)
requestTarget - : request target from where we will retrieve Idpublic static boolean isValidBooleanString(String value)
value - the string to validatepublic static String extractSerialNumber(X509Certificate x509Certificate)
public static void validatePathAndFile(String filePath, String pathType) throws IOException
filePath - The file path to validate.pathType - A description of the path type (e.g., "Input file").IOException - If the file does not exist.IllegalArgumentException - If the path is null or empty.public static Collection<X509Certificate> loadCertificatesFromPemFile(String certFilePath) throws CertificateException, IOException
certFilePath - The file path to the PEM certificate file.CertificateException - If the certificate cannot be parsed or is invalid.IOException - If the file cannot be read or does not exist.public static X509Certificate searchCertificateByAlias(Collection<X509Certificate> certs, String keyAlias)
certs - Collection of X509 certificates to search throughkeyAlias - The key alias to search forpublic static void validateCertificateExpiry(X509Certificate certificate, String keyAlias, String mleCacheKeyIdentifier) throws MLEException
certificate - The X509Certificate to check.keyAlias - The alias of the key in the keystore.mleCacheKeyIdentifier - Identifier for the MLE cache key.MLEException - if certificate validation fails.public static PrivateKey readPrivateKeyFromP12(String p12FilePath, char[] password) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException
public static PrivateKey loadPrivateKeyFromPemFile(String keyFilePath, char[] password) throws Exception
Exceptionpublic static X509Certificate getCertificateByAliasFromPKCS(String filePath, char[] password, String alias) throws CertificateException, IOException, KeyStoreException
filePath - The path to the PKCS12 (.p12) filepassword - The password to unlock the keystorealias - The certificate alias to search forCertificateException - If there's an error parsing certificatesIOException - If the file cannot be readKeyStoreException - If there's an error accessing the keystoreIllegalArgumentException - If required parameters are invalidpublic static boolean isP12GeneratedByCyberSource(String filePath, char[] password)
Copyright © 2026. All rights reserved.