Class CertificateHelper

java.lang.Object
com.suse.common.security.CertificateHelper

public class CertificateHelper extends Object
  • Field Details

  • Constructor Details

    • CertificateHelper

      private CertificateHelper()
  • Method Details

    • downloadCertificate

      public static X509Certificate downloadCertificate(String certificateUrl) throws IOException
      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 download
      timeoutSeconds - download timeout in seconds
      Returns:
      the certificate
      Throws:
      IOException - if something goes wrong
    • parse

      public static X509Certificate parse(String pemCertificate) throws CertificateException
      Parameters:
      pemCertificate - certificate in pem format
      Returns:
      the parsed certificate
      Throws:
      CertificateException - when an error occurs while parsing the data
    • downloadCertificateRevocationList

      public static X509CRL downloadCertificateRevocationList(String crlUrl) throws IOException
      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 download
      timeoutSeconds - 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

      private static String downloadStringContent(String urlIn, long timeoutSeconds) throws IOException
      Parameters:
      urlIn - url of the file to download
      timeoutSeconds - download timeout in seconds
      Returns:
      downloaded file as string content
      Throws:
      IOException - if something goes wrong
    • getPemCertificate

      public static String getPemCertificate(X509Certificate cert) throws CertificateEncodingException
      Parameters:
      cert - certificate
      Returns:
      string representation of the certificate
      Throws:
      CertificateEncodingException - when an error occurs while parsing the data
    • parseCrl

      public static X509CRL parseCrl(String pemCrlCertificate) throws CertificateException
      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