Class CaUtil


  • public class CaUtil
    extends Object
    Util class of CA.
    Since:
    2.0.0
    Author:
    Lijun Liao (xipki)
    • Method Detail

      • addExtensions

        public static void addExtensions​(org.xipki.ca.api.profile.ExtensionValues extensionValues,
                                         org.bouncycastle.cert.X509v3CertificateBuilder certBuilder)
                                  throws org.bouncycastle.cert.CertIOException
        Throws:
        org.bouncycastle.cert.CertIOException
      • asModifiableList

        @SafeVarargs
        public static <T> List<T> asModifiableList​(T... a)
      • createBasicConstraints

        public static org.bouncycastle.asn1.x509.BasicConstraints createBasicConstraints​(org.xipki.ca.api.profile.Certprofile.CertLevel level,
                                                                                         Integer pathLen)
      • createAuthorityInformationAccess

        public static org.bouncycastle.asn1.x509.AuthorityInformationAccess createAuthorityInformationAccess​(List<String> caIssuerUris,
                                                                                                             List<String> ocspUris)
      • createCrlDistributionPoints

        public static org.bouncycastle.asn1.x509.CRLDistPoint createCrlDistributionPoints​(List<String> crlUris,
                                                                                          org.bouncycastle.asn1.x500.X500Name caSubject,
                                                                                          org.bouncycastle.asn1.x500.X500Name crlSignerSubject)
      • sortX509Name

        public static org.bouncycastle.asn1.x500.X500Name sortX509Name​(org.bouncycastle.asn1.x500.X500Name name)
      • canonicalizeSignerConf

        public static String canonicalizeSignerConf​(String signerConf)
                                             throws org.xipki.ca.api.mgmt.CaMgmtException
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • createFileOrValue

        public static org.xipki.util.FileOrValue createFileOrValue​(ZipOutputStream zipStream,
                                                                   String content,
                                                                   String fileName)
                                                            throws IOException
        If the content has less than 256 chars, then returns a FileOrValue with text content, otherwise, the content is written to the zipStream and a FileOrValue, with file name pointing to the location in the ZIP file, is returned. The specified stream remains open after this method returns.
        Parameters:
        content - the content
        zipStream - the ZIP output stream
        fileName - the file name in the ZIP stream when writing to the ZIp stream.
        Returns:
        a FileOrBinary with the content or fileName as value.
        Throws:
        IOException - if IO error occurs when writing to the ZIP output stream.
      • createFileOrBase64Value

        public static org.xipki.util.FileOrBinary createFileOrBase64Value​(ZipOutputStream zipStream,
                                                                          String b64Content,
                                                                          String fileName)
                                                                   throws IOException
        If the content of the decoded b64Content is less than 256 bytes, then returns a FileOrBinary with binary content, otherwise, the content is written to the zipStream and a FileOrBinary, with file name pointing to the location in the ZIP file, is returned. The specified stream remains open after this method returns.
        Parameters:
        b64Content - the BASE64-encoded content
        zipStream - the ZIP output stream
        fileName - the file name in the ZIP stream when writing to the ZIp stream.
        Returns:
        a FileOrBinary with the content or fileName as value.
        Throws:
        IOException - if IO error occurs when writing to the ZIP output stream.
      • createFileOrBinary

        public static org.xipki.util.FileOrBinary createFileOrBinary​(ZipOutputStream zipStream,
                                                                     byte[] content,
                                                                     String fileName)
                                                              throws IOException
        If the content is less than 256 bytes, then returns a FileOrBinary with binary content, otherwise, the content is written to the zipStream and a FileOrBinary, with file name pointing to the location in the ZIP file, is returned. The specified stream remains open after this method returns.
        Parameters:
        content - the content
        zipStream - the ZIP output stream
        fileName - the file name in the ZIP stream when writing to the ZIp stream.
        Returns:
        a FileOrBinary with the content or fileName as value.
        Throws:
        IOException - if IO error occurs when writing to the ZIP output stream.
      • getPermissions

        public static List<String> getPermissions​(int permission)
      • encodeCertchain

        public static String encodeCertchain​(List<org.xipki.security.X509Cert> certs)
      • buildCertChain

        public static List<org.xipki.security.X509Cert> buildCertChain​(org.xipki.security.X509Cert targetCert,
                                                                       List<org.xipki.security.X509Cert> certs)
                                                                throws org.xipki.ca.api.mgmt.CaMgmtException
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • parseCert

        public static org.xipki.security.X509Cert parseCert​(byte[] encodedCert)
                                                     throws org.xipki.ca.api.mgmt.CaMgmtException
        Throws:
        org.xipki.ca.api.mgmt.CaMgmtException
      • removeEmptyRdns

        public static org.bouncycastle.asn1.x500.X500Name removeEmptyRdns​(org.bouncycastle.asn1.x500.X500Name name)