Class CertUtils
- java.lang.Object
-
- com.adobe.internal.pdftoolkit.core.credentials.impl.utils.CertUtils
-
public class CertUtils extends Object
A collection of utility methods related to cert creation and conversion
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[][]buildDERCertChain(Certificate[] certChain)Converts a java Certificate Chain to a der encoded byte array.static intcomputeJavaPrivateKeySize(PrivateKey privateKey)Computes the size of a JCE PrivateKeystatic PrivateKeycreateJCEPrivateKey(byte[] encodedPriKey, String keyWrappingFormat)Create a JCE PrivateKey given a DER encoded set of bytes representing the key.static PrivateKeyHoldercreateJCEPrivateKeyHolder(byte[] encodedPriKey, String keyWrappingFormat)Create a JCE PrivateKey given a DER encoded set of bytes representing the key.static StringgetCommonSubjectName(X509Certificate x509Certificate)Returns value of "CN" attribute from subject name of this certificate.static CertificateimportCertificate(byte[] certData)Creates a JCE X509 certificate from a DER encoded byte array representing the certificate.static Certificate[]importCertificateChain(byte[][] certData)Creates a JCE X509 certificate chain from a DER encoded byte array representing the cert chain
-
-
-
Method Detail
-
importCertificate
public static Certificate importCertificate(byte[] certData) throws CertificateException, IOException
Creates a JCE X509 certificate from a DER encoded byte array representing the certificate.- Parameters:
certData-- Returns:
- java.security.cert.Certificate
- Throws:
CertificateExceptionIOException
-
importCertificateChain
public static Certificate[] importCertificateChain(byte[][] certData) throws CertificateException, IOException
Creates a JCE X509 certificate chain from a DER encoded byte array representing the cert chain- Parameters:
certData-- Returns:
- certificate chain
- Throws:
CertificateExceptionIOException
-
createJCEPrivateKey
public static PrivateKey createJCEPrivateKey(byte[] encodedPriKey, String keyWrappingFormat) throws NoSuchAlgorithmException, InvalidKeySpecException
Create a JCE PrivateKey given a DER encoded set of bytes representing the key.- Parameters:
encodedPriKey-keyWrappingFormat-- Returns:
- PrivateKey
- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecException
-
createJCEPrivateKeyHolder
public static PrivateKeyHolder createJCEPrivateKeyHolder(byte[] encodedPriKey, String keyWrappingFormat) throws NoSuchAlgorithmException, InvalidKeySpecException
Create a JCE PrivateKey given a DER encoded set of bytes representing the key.- Parameters:
encodedPriKey-keyWrappingFormat-- Returns:
- JCEPrivateKeyHolder
- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecException
-
buildDERCertChain
public static byte[][] buildDERCertChain(Certificate[] certChain) throws CertificateEncodingException, CertificateException
Converts a java Certificate Chain to a der encoded byte array.- Parameters:
certChain-- Returns:
- byte[][] representing the der cert chain
- Throws:
CertificateEncodingExceptionCertificateException
-
computeJavaPrivateKeySize
public static int computeJavaPrivateKeySize(PrivateKey privateKey) throws NoSuchAlgorithmException, InvalidKeySpecException
Computes the size of a JCE PrivateKey- Parameters:
privateKey-- Returns:
- size of the JCE PrivateKey
- Throws:
NoSuchAlgorithmExceptionInvalidKeySpecException
-
getCommonSubjectName
public static String getCommonSubjectName(X509Certificate x509Certificate)
Returns value of "CN" attribute from subject name of this certificate.- Parameters:
x509Certificate-- Returns:
- String
-
-