Package software.amazon.awssdk.crt.utils
Class PemUtils
- java.lang.Object
-
- software.amazon.awssdk.crt.utils.PemUtils
-
public class PemUtils extends java.lang.Object
Utility Class used for Cleaning Up and Sanity Checking PEM formatted Strings for Validity.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
cleanUpPem(java.lang.String pem)
Cleanup Function that removes most formatting and copy/paste mistakes from PEM formatted Strings.static java.lang.String
removeInvalidPemChars(java.lang.String pem)
Removes characters that are not valid in PEM format (non-base64 chars).static boolean
safeSanityCheck(java.lang.String pem, int maxChainLength, java.lang.String expectedPemTypeSubString)
Returns false if there is a problem with a PEM instead of throwing an Exception.static void
sanityCheck(java.lang.String pem, int maxChainLength, java.lang.String expectedPemTypeSubString)
Performs various sanity checks on a PEM Formatted String, and should be tolerant of common minor mistakes in formatting.
-
-
-
Method Detail
-
removeInvalidPemChars
public static java.lang.String removeInvalidPemChars(java.lang.String pem)
Removes characters that are not valid in PEM format (non-base64 chars). No other cleanup is done.- Parameters:
pem
- The input "dirty" PEM- Returns:
- The output "clean" PEM
-
cleanUpPem
public static java.lang.String cleanUpPem(java.lang.String pem)
Cleanup Function that removes most formatting and copy/paste mistakes from PEM formatted Strings.- Parameters:
pem
- The input "dirty" PEM- Returns:
- The output "clean" PEM
-
sanityCheck
public static void sanityCheck(java.lang.String pem, int maxChainLength, java.lang.String expectedPemTypeSubString)
Performs various sanity checks on a PEM Formatted String, and should be tolerant of common minor mistakes in formatting.- Parameters:
pem
- The PEM or PEM Chain to validate.maxChainLength
- The max number of PEM encoded objects in the String.expectedPemTypeSubString
- A Substring that is expected to be present in the PEM Type.- Throws:
java.lang.IllegalArgumentException
- if there is a problem with the PEM formatted String.
-
safeSanityCheck
public static boolean safeSanityCheck(java.lang.String pem, int maxChainLength, java.lang.String expectedPemTypeSubString)
Returns false if there is a problem with a PEM instead of throwing an Exception.- Parameters:
pem
- The PEM to sanity check.maxChainLength
- The Max number of PEM Objects in the PEM StringexpectedPemTypeSubString
- A Substring that is expected to be present in the PEM Type.- Returns:
- True if the PEM passes all sanity Checks, false otherwise.
-
-