Package com.suse.common.security
Class CertificateHelper
java.lang.Object
com.suse.common.security.CertificateHelper
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic X509CertificatedownloadCertificate(String certificateUrl) static X509CertificatedownloadCertificate(String certificateUrl, long timeoutSeconds) static X509CRLstatic X509CRLdownloadCertificateRevocationList(String crlUrl, long timeoutSeconds) private static StringdownloadStringContent(String urlIn, long timeoutSeconds) static Stringstatic X509Certificatestatic X509CRLparseCertificateRevocationList(String pemCrlCertificate) static X509CRLParse the given certificate revocation list
-
Field Details
-
PEM_BEGIN_CERT_TAG
- See Also:
-
PEM_END_CERT_TAG
- See Also:
-
DEFAULT_DOWNLOAD_TIMEOUT_SECONDS
private static final long DEFAULT_DOWNLOAD_TIMEOUT_SECONDS- See Also:
-
-
Constructor Details
-
CertificateHelper
private CertificateHelper()
-
-
Method Details
-
downloadCertificate
- Parameters:
certificateUrl- url of the certificate to download- Returns:
- the certificate
- Throws:
IOException- if something goes wrong
-
downloadCertificate
public static X509Certificate downloadCertificate(String certificateUrl, long timeoutSeconds) throws IOException - Parameters:
certificateUrl- url of the certificate to downloadtimeoutSeconds- download timeout in seconds- Returns:
- the certificate
- Throws:
IOException- if something goes wrong
-
parse
- Parameters:
pemCertificate- certificate in pem format- Returns:
- the parsed certificate
- Throws:
CertificateException- when an error occurs while parsing the data
-
downloadCertificateRevocationList
- Parameters:
crlUrl- url of the certificate revocation list to download- Returns:
- the certificate revocation list
- Throws:
IOException- if something goes wrong
-
downloadCertificateRevocationList
public static X509CRL downloadCertificateRevocationList(String crlUrl, long timeoutSeconds) throws IOException - Parameters:
crlUrl- url of the certificate revocation list to downloadtimeoutSeconds- download timeout in seconds- Returns:
- the certificate revocation list
- Throws:
IOException- if something goes wrong
-
parseCertificateRevocationList
public static X509CRL parseCertificateRevocationList(String pemCrlCertificate) throws CertificateException - Parameters:
pemCrlCertificate- certificate revocation list in pem format- Returns:
- the parsed certificate revocation list
- Throws:
CertificateException- when an error occurs while parsing the data
-
downloadStringContent
- Parameters:
urlIn- url of the file to downloadtimeoutSeconds- download timeout in seconds- Returns:
- downloaded file as string content
- Throws:
IOException- if something goes wrong
-
getPemCertificate
- Parameters:
cert- certificate- Returns:
- string representation of the certificate
- Throws:
CertificateEncodingException- when an error occurs while parsing the data
-
parseCrl
Parse the given certificate revocation list- Parameters:
pemCrlCertificate- a string representing the PEM certificate. Might be empty or null- Returns:
- the certificate revocation list
- Throws:
CertificateException- when an error occurs while parsing the data
-