Class CertUtils
java.lang.Object
se.swedenconnect.sigval.cert.utils.CertUtils
Utility class for X.509 Certificate related functions.
- Author:
- Martin Lindström (martin@idsec.se), Stefan Santesson (stefan@idsec.se)
-
Method Summary
Modifier and TypeMethodDescriptionstatic X509Certificate
getCert
(InputStream inStream) Get a certificate from input streamstatic List
<X509Certificate> getCertificateList
(org.bouncycastle.cert.X509CertificateHolder[] certificateHolders) static org.bouncycastle.asn1.x509.CRLDistPoint
getCrlDistPoint
(X509Certificate certificate) Get CRL Distribution point extension from certificatestatic org.bouncycastle.asn1.ASN1Primitive
getExtensionValue
(X509Certificate certificate, String oid) static String
getOCSPUrl
(X509Certificate certificate) Get OCSP url from certificatestatic List
<X509Certificate> This method returns the resulting path as a list of certificates starting from the target certificate, ending in the trust anchor certificatestatic SubjectInformationAccess
getSIAExtension
(X509Certificate certificate) Get Subject information access extension from certificatestatic boolean
isCurrentlyValid
(X509Certificate certificate) Verifies that a certificate currently is within its validity periodstatic boolean
isCurrentlyValid
(X509Certificate certificate, Date validationTime) Verifies that a certificate at a specified time was within its validity periodstatic boolean
isOCSPNocheckExt
(X509Certificate certificate) Test if certificate has OCSP no-check extension
-
Method Details
-
getOCSPUrl
Get OCSP url from certificate- Parameters:
certificate
- certificate- Returns:
- OCSP responder URL or null if no such URL is present
-
getExtensionValue
public static org.bouncycastle.asn1.ASN1Primitive getExtensionValue(X509Certificate certificate, String oid) throws IOException - Parameters:
certificate
- the certificate from which we need the ExtensionValueoid
- the Object Identifier value for the extension.- Returns:
- the extension value as an ASN1Primitive object
- Throws:
IOException
- on error
-
getCertificateList
public static List<X509Certificate> getCertificateList(org.bouncycastle.cert.X509CertificateHolder[] certificateHolders) throws CertificateException - Throws:
CertificateException
-
getCrlDistPoint
public static org.bouncycastle.asn1.x509.CRLDistPoint getCrlDistPoint(X509Certificate certificate) throws IOException Get CRL Distribution point extension from certificate- Parameters:
certificate
- certificate- Returns:
CRLDistPoint
extension or null if no such extension is present- Throws:
IOException
- on error obtaining extension data
-
getSIAExtension
Get Subject information access extension from certificate- Parameters:
certificate
- certificate- Returns:
SubjectInformationAccess
-
isOCSPNocheckExt
Test if certificate has OCSP no-check extension- Parameters:
certificate
- certificate- Returns:
- true if OCSP no-check extension is present
-
isCurrentlyValid
Verifies that a certificate currently is within its validity period- Parameters:
certificate
- certificate to check- Returns:
- true if the certificate is within its validity period
-
isCurrentlyValid
Verifies that a certificate at a specified time was within its validity period- Parameters:
certificate
- certificate to checkvalidationTime
- the time when the certificate should be valid- Returns:
- true if the certificate was within its validity period at the specified time
-
getCert
public static X509Certificate getCert(InputStream inStream) throws CertificateException, IOException Get a certificate from input stream- Parameters:
inStream
- input stream- Returns:
- certificate
- Throws:
CertificateException
- error parsing certificate dataIOException
- IO errors
-
getResultPath
This method returns the resulting path as a list of certificates starting from the target certificate, ending in the trust anchor certificate- Parameters:
result
- validated certificate path- Returns:
- validated certificate path starting with the target certificate and ending with the self signed TA root certificate
-