Package io.skodjob.testframe.utils
Class SecurityUtils
java.lang.Object
io.skodjob.testframe.utils.SecurityUtils
Utils for manipulating with certs
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsAllDN(String principal1, String principal2) Check if principal1 contains all dns of principal2 in dnstatic FileconvertPrivateKeyToPKCS8File(PrivateKey privatekey) Converts private key into PKCS8Filestatic FileexportCaDataToFile(String caData, String prefix, String suffix) This method exports Certificate Authority (CA) data to a temporary file for cases in which mentioned data is necessary in form of file - for use in applications like OpenSSL.static CertAndKeyFilesexportToPemFiles(CertAndKey... certs) Export in-memory cert and key into pem files
-
Method Details
-
exportToPemFiles
Export in-memory cert and key into pem files- Parameters:
certs- im memory certs- Returns:
- exported files
-
convertPrivateKeyToPKCS8File
public static File convertPrivateKeyToPKCS8File(PrivateKey privatekey) throws NoSuchAlgorithmException, InvalidKeySpecException, IOException Converts private key into PKCS8File- Parameters:
privatekey- private key- Returns:
- exported file on disk
- Throws:
NoSuchAlgorithmException- bad algorithmInvalidKeySpecException- bad keyIOException- io exception
-
exportCaDataToFile
This method exports Certificate Authority (CA) data to a temporary file for cases in which mentioned data is necessary in form of file - for use in applications like OpenSSL. The primary purpose is to save CA files, such as certificates and private keys (e.g., ca.key and ca.cert), into temporary files. These files are essential when you need to provide CA data to other applications, such as OpenSSL, for signing user Certificate Signing Requests (CSRs).- Parameters:
caData- The Certificate Authority data to be saved to the temporary file.prefix- The prefix for the temporary file's name.suffix- The suffix for the temporary file's name.- Returns:
- A File object representing the temporary file containing the CA data.
- Throws:
RuntimeException- If an IOException occurs while creating a file or writing into the temporary file given the critical role these operations play in ensuring proper functionality.
-
containsAllDN
Check if principal1 contains all dns of principal2 in dn- Parameters:
principal1- principalprincipal2- principal- Returns:
- true of principal 1 contains all dn of principal 2
-