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 int
computeJavaPrivateKeySize(PrivateKey privateKey)
Computes the size of a JCE PrivateKeystatic PrivateKey
createJCEPrivateKey(byte[] encodedPriKey, String keyWrappingFormat)
Create a JCE PrivateKey given a DER encoded set of bytes representing the key.static PrivateKeyHolder
createJCEPrivateKeyHolder(byte[] encodedPriKey, String keyWrappingFormat)
Create a JCE PrivateKey given a DER encoded set of bytes representing the key.static String
getCommonSubjectName(X509Certificate x509Certificate)
Returns value of "CN" attribute from subject name of this certificate.static Certificate
importCertificate(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:
CertificateException
IOException
-
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:
CertificateException
IOException
-
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:
NoSuchAlgorithmException
InvalidKeySpecException
-
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:
NoSuchAlgorithmException
InvalidKeySpecException
-
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:
CertificateEncodingException
CertificateException
-
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:
NoSuchAlgorithmException
InvalidKeySpecException
-
getCommonSubjectName
public static String getCommonSubjectName(X509Certificate x509Certificate)
Returns value of "CN" attribute from subject name of this certificate.- Parameters:
x509Certificate
-- Returns:
- String
-
-