Class PKIUtil


  • public final class PKIUtil
    extends java.lang.Object
    This class implements some handy methods in context of PKI
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.security.cert.X509Certificate[] combineCertificates​(java.security.cert.X509Certificate[] certs, java.security.cert.X509Certificate[] caCerts)
      Combine two certificate arrays
      static javax.security.cert.X509Certificate convert​(java.security.cert.X509Certificate cert)
      Converts to javax.security
      static java.security.cert.X509Certificate convert​(javax.security.cert.X509Certificate cert)
      Converts to java.security
      protected com.github.toolarium.common.ByteArray formatBuffer​(com.github.toolarium.common.ByteArray rawCertificate, int rowWith, java.lang.String startTag, java.lang.String endTag)
      Formats a raw base64 encoded data to a well formed data.
      com.github.toolarium.common.ByteArray formatDSAPKCS8​(com.github.toolarium.common.ByteArray rawData)
      Formats a raw base64 encoded PKCS8 to a well formed private key, which is bounded at the beginning by -----BEGIN DSA PRIVATE KEY-----, and bounded at the end by -----END DSA PRIVATE KEY-----.
      java.lang.String formatDSAPublicKey​(java.security.PublicKey publicKey)
      Formats a public dsa key into a well formated X509 certificate (PEM format), which are each bounded at the beginning by -----BEGIN DSA PUBLIC KEY-----, and bounded at the end by -----END DSA PUBLIC KEY-----.
      com.github.toolarium.common.ByteArray formatPKCS7​(com.github.toolarium.common.ByteArray rawCertificate)
      Formats a raw base64 encoded X509 certificates to a well formated X509 certificate (PEM format), which are each bounded at the beginning by -----BEGIN CERTIFICATE-----, and bounded at the end by -----END CERTIFICATE-----.
      com.github.toolarium.common.ByteArray formatPKCS7​(java.security.cert.Certificate certificate)
      Formats a certificate to a well formated X509 certificate (PEM format), which are each bounded at the beginning by -----BEGIN CERTIFICATE-----, and bounded at the end by -----END CERTIFICATE-----.
      java.lang.String formatPKCS7​(java.security.cert.X509Certificate[] certificateChain)
      Create certificate chain into a well formed string representation
      java.lang.String formatPrivateKey​(java.security.PrivateKey privateKey)
      Formats a private key into a well formed private key, which is bounded at the beginning and ending with the corresponding messages (see PKCS8).
      java.lang.String formatPublicKey​(java.security.PublicKey publicKey)
      Formats a public key into a well formed private key, which is bounded at the beginning and ending with the corresponding messages (see PKCS8).
      com.github.toolarium.common.ByteArray formatRSAPKCS8​(com.github.toolarium.common.ByteArray rawData)
      Formats a raw base64 encoded PKCS8 to a well formed private key, which is bounded at the beginning by -----BEGIN RSA PRIVATE KEY-----, and bounded at the end by -----END RSA PRIVATE KEY-----.
      java.lang.String formatRSAPublicKey​(java.security.PublicKey publicKey)
      Formats a public rsa key into a well formated X509 certificate (PEM format), which are each bounded at the beginning by -----BEGIN RSA PUBLIC KEY-----, and bounded at the end by -----END RSA PUBLIC KEY-----.
      java.security.KeyPair generateKeyPair​(java.lang.String algorithm, int keySize)
      Generates a KeyPair containing a Private- and PublicKey
      java.security.KeyPair generateKeyPair​(java.lang.String provider, java.lang.String algorithm, int k)
      Generates a KeyPair containing a Private- and PublicKey
      java.security.PrivateKey getDSAPrivateKey​(byte[] buffer)
      Reads PKCS#8 formated DSA private key from a buffer, which are each bounded at the beginning by -----BEGIN DSA PRIVATE KEY-----, and bounded at the end by -----END DSA PRIVATE KEY-----.
      java.security.PrivateKey getDSAPrivateKey​(java.lang.String fileName)
      Reads PKCS#8 formated DSA private key from a file, which are each bounded at the beginning by -----BEGIN DSA PRIVATE KEY-----, and bounded at the end by -----END DSA PRIVATE KEY-----.
      java.security.PublicKey getDSAPublicKey​(byte[] buffer)
      Reads PKCS#8 formated public key from a buffer which are each bounded at the beginning by -----BEGIN PUBLIC KEY-----, and bounded at the end by -----END PUBLIC KEY-----.
      static PKIUtil getInstance()
      Get the instance
      java.security.PrivateKey getRSAPrivateKey​(com.github.toolarium.common.ByteArray buffer)
      Reads PKCS#8 formated RSA private key from a buffer, which are each bounded at the beginning by -----BEGIN RSA PRIVATE KEY-----, and bounded at the end by -----END RSA PRIVATE KEY-----.
      java.security.PrivateKey getRSAPrivateKey​(java.lang.String fileName)
      Reads PKCS#8 formated private key from a file, which are each bounded at the beginning by -----BEGIN RSA PRIVATE KEY-----, and bounded at the end by -----END RSA PRIVATE KEY-----.
      java.security.PublicKey getRSAPublicKey​(byte[] buffer)
      Reads PKCS#8 formated public key from a buffer, which are each bounded at the beginning by -----BEGIN RSA PRIVATE KEY-----, and bounded at the end by -----END RSA PRIVATE KEY-----.
      java.security.cert.X509Certificate[] getX509Certificates​(com.github.toolarium.common.ByteArray inputData)
      Reas a PKCS#7 (with base64 encoded) X509 certificates from the given buffer, which are each bounded at the beginning by -----BEGIN CERTIFICATE-----, and bounded at the end by -----END CERTIFICATE-----.
      java.security.cert.X509Certificate[] getX509Certificates​(java.lang.String fileName)
      Reas a PKCS#7 (with base64 encoded) X509 certificates from a file, which are each bounded at the beginning by -----BEGIN CERTIFICATE-----, and bounded at the end by -----END CERTIFICATE-----.
      void logCertificate​(java.lang.String msg, java.security.cert.X509Certificate... cert)
      Logs a given certificate
      void logPrivateKeyInfo​(java.lang.String msg, java.security.PrivateKey privateKey)
      Logs information of a given private key
      void logPublicKeyInfo​(java.lang.String msg, java.security.PublicKey publicKey)
      Logs information of a given public key
      protected com.github.toolarium.common.ByteArray normalizeBuffer​(com.github.toolarium.common.ByteArray rawCertificate, java.lang.String startTag, java.lang.String endTag)
      Normalize a raw base64 encoded data to a well formed data.
      com.github.toolarium.common.ByteArray normalizeDSAPKCS8​(com.github.toolarium.common.ByteArray rawData)
      Normalize a raw base64 encoded PKCS8 to a well formed private key.
      com.github.toolarium.common.ByteArray normalizeRSAPKCS8​(com.github.toolarium.common.ByteArray rawData)
      Normalize a raw base64 encoded PKCS8 to a well formed private key.
      CertificateStore readPKCS12KeyPair​(java.lang.String fileName, java.lang.String provider, java.lang.String alias, java.lang.String password)
      Read a PKCS12 file as keystore
      java.security.KeyStore readPKCS12KeyStore​(java.lang.String fileName, java.lang.String provider, java.lang.String password)
      Read a PKCS12 file as keystore
      void verifyCertificate​(java.security.cert.X509Certificate userCertificate)
      Verifies the digital signature of a certificate.
      void verifyCertificate​(java.security.cert.X509Certificate userCert, java.security.cert.X509Certificate caCert)
      Verifies the digital signature of a certificate.
      void verifyCertificateChain​(java.security.cert.X509Certificate[] certs)
      Verifies a chain of certificates where the user certificate is stored at index 0.
      void writePKCS12KeyStore​(java.lang.String fileName, java.lang.String provider, java.lang.String alias, java.security.PrivateKey privateKey, java.security.cert.Certificate[] certificates, java.lang.String password)
      Writes a PKCS12 file as keystore
      void writePKCS12KeyStore​(java.lang.String fileName, java.lang.String alias, java.security.PrivateKey privateKey, java.security.cert.Certificate[] certificates, java.lang.String password)
      Writes a PKCS12 file as keystore
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PUBLIC_CERTIFICATE_START

        public static final java.lang.String PUBLIC_CERTIFICATE_START
        the public key certifcate start
        See Also:
        Constant Field Values
      • PUBLIC_CERTIFICATE_END

        public static final java.lang.String PUBLIC_CERTIFICATE_END
        the public key certifcate end
        See Also:
        Constant Field Values
      • PUBLIC_RSA_KEY_START

        public static final java.lang.String PUBLIC_RSA_KEY_START
        the public rsa key start
        See Also:
        Constant Field Values
      • PUBLIC_RSA_KEY_END

        public static final java.lang.String PUBLIC_RSA_KEY_END
        the public rsa key end
        See Also:
        Constant Field Values
      • PUBLIC_DSA_KEY_START

        public static final java.lang.String PUBLIC_DSA_KEY_START
        the public dsa key start
        See Also:
        Constant Field Values
      • PUBLIC_DSA_KEY_END

        public static final java.lang.String PUBLIC_DSA_KEY_END
        the public dsa key end
        See Also:
        Constant Field Values
      • PRIVATE_RSA_KEY_START

        public static final java.lang.String PRIVATE_RSA_KEY_START
        the private RSA key certifcate start
        See Also:
        Constant Field Values
      • PRIVATE_RSA_KEY_END

        public static final java.lang.String PRIVATE_RSA_KEY_END
        the private RSA key certifcate end
        See Also:
        Constant Field Values
      • PRIVATE_DSA_KEY_START

        public static final java.lang.String PRIVATE_DSA_KEY_START
        the private DSA key certifcate start
        See Also:
        Constant Field Values
      • PRIVATE_DSA_KEY_END

        public static final java.lang.String PRIVATE_DSA_KEY_END
        the private DSA key certifcate end
        See Also:
        Constant Field Values
    • Method Detail

      • getInstance

        public static PKIUtil getInstance()
        Get the instance
        Returns:
        the instance
      • generateKeyPair

        public java.security.KeyPair generateKeyPair​(java.lang.String algorithm,
                                                     int keySize)
                                              throws java.security.GeneralSecurityException
        Generates a KeyPair containing a Private- and PublicKey
        Parameters:
        algorithm - the algorithm like: SHA1withRSA, SHA1withDSA, RSA...
        keySize - the size of the key
        Returns:
        the created KeyPair
        Throws:
        java.security.GeneralSecurityException - in case of error
      • generateKeyPair

        public java.security.KeyPair generateKeyPair​(java.lang.String provider,
                                                     java.lang.String algorithm,
                                                     int k)
                                              throws java.security.GeneralSecurityException
        Generates a KeyPair containing a Private- and PublicKey
        Parameters:
        provider - the provider
        algorithm - the algorithm like: SHA1withRSA, SHA1withDSA, RSA...
        k - the size of the key
        Returns:
        the created KeyPair
        Throws:
        java.security.GeneralSecurityException - in case of error
      • getX509Certificates

        public java.security.cert.X509Certificate[] getX509Certificates​(java.lang.String fileName)
                                                                 throws java.security.GeneralSecurityException,
                                                                        java.io.IOException
        Reas a PKCS#7 (with base64 encoded) X509 certificates from a file, which are each bounded at the beginning by -----BEGIN CERTIFICATE-----, and bounded at the end by -----END CERTIFICATE-----.
        Parameters:
        fileName - the file to read
        Returns:
        the read certificates
        Throws:
        java.security.GeneralSecurityException - in case of error
        java.io.IOException - in case of error
      • getX509Certificates

        public java.security.cert.X509Certificate[] getX509Certificates​(com.github.toolarium.common.ByteArray inputData)
                                                                 throws java.security.GeneralSecurityException
        Reas a PKCS#7 (with base64 encoded) X509 certificates from the given buffer, which are each bounded at the beginning by -----BEGIN CERTIFICATE-----, and bounded at the end by -----END CERTIFICATE-----.
        Parameters:
        inputData - the data
        Returns:
        the read certificates
        Throws:
        java.security.GeneralSecurityException - in case of error
      • getDSAPublicKey

        public java.security.PublicKey getDSAPublicKey​(byte[] buffer)
                                                throws java.io.IOException,
                                                       java.security.GeneralSecurityException
        Reads PKCS#8 formated public key from a buffer which are each bounded at the beginning by -----BEGIN PUBLIC KEY-----, and bounded at the end by -----END PUBLIC KEY-----.
        Parameters:
        buffer - the data
        Returns:
        the public key
        Throws:
        java.io.IOException - in case of error
        java.security.GeneralSecurityException - in case of error
      • getRSAPublicKey

        public java.security.PublicKey getRSAPublicKey​(byte[] buffer)
                                                throws java.io.IOException,
                                                       java.security.GeneralSecurityException
        Reads PKCS#8 formated public key from a buffer, which are each bounded at the beginning by -----BEGIN RSA PRIVATE KEY-----, and bounded at the end by -----END RSA PRIVATE KEY-----.
        Parameters:
        buffer - the data
        Returns:
        the public key
        Throws:
        java.io.IOException - in case of error
        java.security.GeneralSecurityException - in case of error
      • combineCertificates

        public java.security.cert.X509Certificate[] combineCertificates​(java.security.cert.X509Certificate[] certs,
                                                                        java.security.cert.X509Certificate[] caCerts)
        Combine two certificate arrays
        Parameters:
        certs - the certificate
        caCerts - the ca certificate(s)
        Returns:
        the combined certificates
      • getDSAPrivateKey

        public java.security.PrivateKey getDSAPrivateKey​(java.lang.String fileName)
                                                  throws java.io.IOException,
                                                         java.security.GeneralSecurityException
        Reads PKCS#8 formated DSA private key from a file, which are each bounded at the beginning by -----BEGIN DSA PRIVATE KEY-----, and bounded at the end by -----END DSA PRIVATE KEY-----.
        Parameters:
        fileName - the file to read
        Returns:
        the private key
        Throws:
        java.io.IOException - in case of error
        java.security.GeneralSecurityException - in case of error
      • getDSAPrivateKey

        public java.security.PrivateKey getDSAPrivateKey​(byte[] buffer)
                                                  throws java.security.GeneralSecurityException
        Reads PKCS#8 formated DSA private key from a buffer, which are each bounded at the beginning by -----BEGIN DSA PRIVATE KEY-----, and bounded at the end by -----END DSA PRIVATE KEY-----.
        Parameters:
        buffer - the private key to encode
        Returns:
        the private key
        Throws:
        java.security.GeneralSecurityException - in case of error
      • getRSAPrivateKey

        public java.security.PrivateKey getRSAPrivateKey​(java.lang.String fileName)
                                                  throws java.io.IOException,
                                                         java.security.GeneralSecurityException
        Reads PKCS#8 formated private key from a file, which are each bounded at the beginning by -----BEGIN RSA PRIVATE KEY-----, and bounded at the end by -----END RSA PRIVATE KEY-----.
        Parameters:
        fileName - the file to read
        Returns:
        the private key
        Throws:
        java.io.IOException - in case of error
        java.security.GeneralSecurityException - in case of error
      • getRSAPrivateKey

        public java.security.PrivateKey getRSAPrivateKey​(com.github.toolarium.common.ByteArray buffer)
                                                  throws java.security.GeneralSecurityException
        Reads PKCS#8 formated RSA private key from a buffer, which are each bounded at the beginning by -----BEGIN RSA PRIVATE KEY-----, and bounded at the end by -----END RSA PRIVATE KEY-----.
        Parameters:
        buffer - the private key to encode
        Returns:
        the private key
        Throws:
        java.security.GeneralSecurityException - in case of error
      • formatPublicKey

        public java.lang.String formatPublicKey​(java.security.PublicKey publicKey)
        Formats a public key into a well formed private key, which is bounded at the beginning and ending with the corresponding messages (see PKCS8).
        Parameters:
        publicKey - the public key
        Returns:
        the well formed certificate
      • formatDSAPublicKey

        public java.lang.String formatDSAPublicKey​(java.security.PublicKey publicKey)
        Formats a public dsa key into a well formated X509 certificate (PEM format), which are each bounded at the beginning by -----BEGIN DSA PUBLIC KEY-----, and bounded at the end by -----END DSA PUBLIC KEY-----.
        Parameters:
        publicKey - the public key to format
        Returns:
        the well formed certificate
      • formatRSAPublicKey

        public java.lang.String formatRSAPublicKey​(java.security.PublicKey publicKey)
        Formats a public rsa key into a well formated X509 certificate (PEM format), which are each bounded at the beginning by -----BEGIN RSA PUBLIC KEY-----, and bounded at the end by -----END RSA PUBLIC KEY-----.
        Parameters:
        publicKey - the public key to format
        Returns:
        the well formed certificate
      • formatPKCS7

        public com.github.toolarium.common.ByteArray formatPKCS7​(com.github.toolarium.common.ByteArray rawCertificate)
        Formats a raw base64 encoded X509 certificates to a well formated X509 certificate (PEM format), which are each bounded at the beginning by -----BEGIN CERTIFICATE-----, and bounded at the end by -----END CERTIFICATE-----.
        Parameters:
        rawCertificate - the raw certificate to format
        Returns:
        the well formed certificate
      • formatPKCS7

        public java.lang.String formatPKCS7​(java.security.cert.X509Certificate[] certificateChain)
                                     throws java.security.cert.CertificateEncodingException
        Create certificate chain into a well formed string representation
        Parameters:
        certificateChain - the certificate chain
        Returns:
        the string representation
        Throws:
        java.security.cert.CertificateEncodingException - In case of a certificate error
      • formatPKCS7

        public com.github.toolarium.common.ByteArray formatPKCS7​(java.security.cert.Certificate certificate)
                                                          throws java.security.cert.CertificateEncodingException
        Formats a certificate to a well formated X509 certificate (PEM format), which are each bounded at the beginning by -----BEGIN CERTIFICATE-----, and bounded at the end by -----END CERTIFICATE-----.
        Parameters:
        certificate - the certificate to format in PEM format
        Returns:
        the well formed certificate
        Throws:
        java.security.cert.CertificateEncodingException - In case of a certificate error
      • formatPrivateKey

        public java.lang.String formatPrivateKey​(java.security.PrivateKey privateKey)
        Formats a private key into a well formed private key, which is bounded at the beginning and ending with the corresponding messages (see PKCS8).
        Parameters:
        privateKey - the private key
        Returns:
        the well formed certificate
      • formatDSAPKCS8

        public com.github.toolarium.common.ByteArray formatDSAPKCS8​(com.github.toolarium.common.ByteArray rawData)
        Formats a raw base64 encoded PKCS8 to a well formed private key, which is bounded at the beginning by -----BEGIN DSA PRIVATE KEY-----, and bounded at the end by -----END DSA PRIVATE KEY-----.
        Parameters:
        rawData - the raw data to format
        Returns:
        the well formed certificate
      • formatRSAPKCS8

        public com.github.toolarium.common.ByteArray formatRSAPKCS8​(com.github.toolarium.common.ByteArray rawData)
        Formats a raw base64 encoded PKCS8 to a well formed private key, which is bounded at the beginning by -----BEGIN RSA PRIVATE KEY-----, and bounded at the end by -----END RSA PRIVATE KEY-----.
        Parameters:
        rawData - the raw data to format
        Returns:
        the well formed certificate
      • normalizeDSAPKCS8

        public com.github.toolarium.common.ByteArray normalizeDSAPKCS8​(com.github.toolarium.common.ByteArray rawData)
        Normalize a raw base64 encoded PKCS8 to a well formed private key.
        Parameters:
        rawData - the raw data to normalize
        Returns:
        the normalized private key
      • normalizeRSAPKCS8

        public com.github.toolarium.common.ByteArray normalizeRSAPKCS8​(com.github.toolarium.common.ByteArray rawData)
        Normalize a raw base64 encoded PKCS8 to a well formed private key.
        Parameters:
        rawData - the raw data to normalize
        Returns:
        the normalized private key
      • logCertificate

        public void logCertificate​(java.lang.String msg,
                                   java.security.cert.X509Certificate... cert)
        Logs a given certificate
        Parameters:
        msg - the message to add
        cert - the cerificate to log
      • logPrivateKeyInfo

        public void logPrivateKeyInfo​(java.lang.String msg,
                                      java.security.PrivateKey privateKey)
        Logs information of a given private key
        Parameters:
        msg - the message to add
        privateKey - the public key
      • logPublicKeyInfo

        public void logPublicKeyInfo​(java.lang.String msg,
                                     java.security.PublicKey publicKey)
        Logs information of a given public key
        Parameters:
        msg - the message to add
        publicKey - the public key
      • verifyCertificateChain

        public void verifyCertificateChain​(java.security.cert.X509Certificate[] certs)
                                    throws java.security.GeneralSecurityException
        Verifies a chain of certificates where the user certificate is stored at index 0. The self-signed top level certificate is verified using its inherent public key. Any other certificate of the chain is verified by means of the public key derived from the issuing certificate which is located one index higher in the chain. certs[0] = user certificate. certs[x] = self signed CA certificate
        Parameters:
        certs - the certificate chain to verify
        Throws:
        java.security.GeneralSecurityException - in case of error
      • verifyCertificate

        public void verifyCertificate​(java.security.cert.X509Certificate userCert,
                                      java.security.cert.X509Certificate caCert)
                               throws java.security.GeneralSecurityException
        Verifies the digital signature of a certificate.
        Parameters:
        userCert - the certificate to verify
        caCert - the certificate of the CA which has issued the userCert or null if the userCert is a self signed certificate
        Throws:
        java.security.GeneralSecurityException - in case of error
      • verifyCertificate

        public void verifyCertificate​(java.security.cert.X509Certificate userCertificate)
                               throws java.security.GeneralSecurityException
        Verifies the digital signature of a certificate.
        Parameters:
        userCertificate - the certificate to verify
        Throws:
        java.security.GeneralSecurityException - in case of error
      • readPKCS12KeyStore

        public java.security.KeyStore readPKCS12KeyStore​(java.lang.String fileName,
                                                         java.lang.String provider,
                                                         java.lang.String password)
                                                  throws java.security.GeneralSecurityException,
                                                         java.io.IOException
        Read a PKCS12 file as keystore
        Parameters:
        fileName - the file to read
        provider - the provider
        password - the password
        Returns:
        the key pairs
        Throws:
        java.io.IOException - in case of a file read error
        java.security.GeneralSecurityException - in case of error
      • readPKCS12KeyPair

        public CertificateStore readPKCS12KeyPair​(java.lang.String fileName,
                                                  java.lang.String provider,
                                                  java.lang.String alias,
                                                  java.lang.String password)
                                           throws java.security.GeneralSecurityException,
                                                  java.io.IOException
        Read a PKCS12 file as keystore
        Parameters:
        fileName - the file to read
        provider - the provider
        alias - the alias in the PKCS12 file
        password - the password
        Returns:
        the certficiate store
        Throws:
        java.security.GeneralSecurityException - in case of error
        java.io.IOException - in case of error
      • writePKCS12KeyStore

        public void writePKCS12KeyStore​(java.lang.String fileName,
                                        java.lang.String alias,
                                        java.security.PrivateKey privateKey,
                                        java.security.cert.Certificate[] certificates,
                                        java.lang.String password)
                                 throws java.security.GeneralSecurityException,
                                        java.io.IOException
        Writes a PKCS12 file as keystore
        Parameters:
        fileName - the file to read
        alias - the alias in the PKCS12 file
        privateKey - the private key
        certificates - the certificate chain
        password - the password
        Throws:
        java.security.GeneralSecurityException - in case of error
        java.io.IOException - in case of error
      • writePKCS12KeyStore

        public void writePKCS12KeyStore​(java.lang.String fileName,
                                        java.lang.String provider,
                                        java.lang.String alias,
                                        java.security.PrivateKey privateKey,
                                        java.security.cert.Certificate[] certificates,
                                        java.lang.String password)
                                 throws java.security.GeneralSecurityException,
                                        java.io.IOException
        Writes a PKCS12 file as keystore
        Parameters:
        fileName - the file to read
        provider - the provider
        alias - the alias in the PKCS12 file
        privateKey - the private key
        certificates - the certificate chain
        password - the password
        Throws:
        java.security.GeneralSecurityException - in case of error
        java.io.IOException - in case of error
      • convert

        public static java.security.cert.X509Certificate convert​(javax.security.cert.X509Certificate cert)
        Converts to java.security
        Parameters:
        cert - the certificate
        Returns:
        the converted certificate
      • convert

        public static javax.security.cert.X509Certificate convert​(java.security.cert.X509Certificate cert)
        Converts to javax.security
        Parameters:
        cert - the certificate
        Returns:
        the converted certificate
      • formatBuffer

        protected com.github.toolarium.common.ByteArray formatBuffer​(com.github.toolarium.common.ByteArray rawCertificate,
                                                                     int rowWith,
                                                                     java.lang.String startTag,
                                                                     java.lang.String endTag)
        Formats a raw base64 encoded data to a well formed data.
        Parameters:
        rawCertificate - the raw certificate to format
        rowWith - the with of the format
        startTag - the start tag
        endTag - the end tag
        Returns:
        the well formed certificate
      • normalizeBuffer

        protected com.github.toolarium.common.ByteArray normalizeBuffer​(com.github.toolarium.common.ByteArray rawCertificate,
                                                                        java.lang.String startTag,
                                                                        java.lang.String endTag)
        Normalize a raw base64 encoded data to a well formed data.
        Parameters:
        rawCertificate - the raw certificate to format
        startTag - the start tag
        endTag - the end tag
        Returns:
        the normalized data