Class NSSDatabase

java.lang.Object
org.dogtagpki.nss.NSSDatabase

public class NSSDatabase extends Object
Author:
Endi S. Dewata
  • Field Details

    • logger

      public static org.slf4j.Logger logger
  • Constructor Details

    • NSSDatabase

      public NSSDatabase()
    • NSSDatabase

      public NSSDatabase(Path path)
    • NSSDatabase

      public NSSDatabase(File directory)
    • NSSDatabase

      public NSSDatabase(String directory)
  • Method Details

    • getPath

      public Path getPath()
    • setPath

      public void setPath(Path path)
    • getDirectory

      public File getDirectory()
    • setDirectory

      public void setDirectory(File directory)
    • getPasswordStore

      public IPasswordStore getPasswordStore()
    • setPasswordStore

      public void setPasswordStore(IPasswordStore passwordStore)
    • exists

      public boolean exists()
    • create

      public void create() throws Exception
      Throws:
      Exception
    • create

      public void create(String password) throws Exception
      Throws:
      Exception
    • create

      public void create(String password, boolean enableTrustPolicy) throws Exception
      Throws:
      Exception
    • moduleExists

      public boolean moduleExists(String name) throws Exception
      Throws:
      Exception
    • addModule

      public void addModule(String name, String library) throws Exception
      Throws:
      Exception
    • addCertificate

      public org.mozilla.jss.crypto.X509Certificate addCertificate(X509Certificate cert, String trustFlags) throws Exception
      Throws:
      Exception
    • addPEMCertificate

      public org.mozilla.jss.crypto.X509Certificate addPEMCertificate(String filename, String trustFlags) throws Exception
      Throws:
      Exception
    • addCertificate

      public void addCertificate(String nickname, X509Certificate cert, String trustFlags) throws Exception
      Throws:
      Exception
    • addCertificate

      public void addCertificate(String tokenName, String nickname, X509Certificate cert, String trustFlags) throws Exception
      Throws:
      Exception
    • addPEMCertificate

      public void addPEMCertificate(String nickname, String filename, String trustFlags) throws Exception
      Throws:
      Exception
    • addPEMCertificate

      public void addPEMCertificate(String tokenName, String nickname, String filename, String trustFlags) throws Exception
      Throws:
      Exception
    • addBasicConstraintsExtension

      public void addBasicConstraintsExtension(List<String> cmd, PrintWriter stdin, org.mozilla.jss.netscape.security.x509.BasicConstraintsExtension extension) throws Exception
      This method provides the arguments and the standard input for certutil to create a cert/CSR with basic constraints extension.
      Parameters:
      cmd - certutil command and arguments
      stdin - certutil's standard input
      extension - The extension to add
      Throws:
      Exception
    • addAKIDExtension

      public void addAKIDExtension(List<String> cmd, PrintWriter stdin, org.mozilla.jss.netscape.security.x509.AuthorityKeyIdentifierExtension extension) throws Exception
      This method provides the arguments and the standard input for certutil to create a cert/CSR with AKID extension.
      Parameters:
      cmd - certutil command and arguments
      stdin - certutil's standard input
      extension - The extension to add
      Throws:
      Exception
    • addSKIDExtension

      public void addSKIDExtension(List<String> cmd, PrintWriter stdin, org.mozilla.jss.netscape.security.x509.SubjectKeyIdentifierExtension extension) throws Exception
      This method provides the arguments and the standard input for certutil to create a cert/CSR with SKID extension.
      Parameters:
      cmd - certutil command and arguments
      stdin - certutil's standard input
      extension - The extension to add
      Throws:
      Exception
    • addAIAExtension

      public void addAIAExtension(List<String> cmd, PrintWriter stdin, org.mozilla.jss.netscape.security.extensions.AuthInfoAccessExtension extension) throws Exception
      This method provides the arguments and the standard input for certutil to create a cert/CSR with AIA extension.
      Parameters:
      cmd - certutil command and arguments
      stdin - certutil's standard input
      extension - The extension to add
      Throws:
      Exception
    • addKeyUsageExtension

      public void addKeyUsageExtension(List<String> cmd, org.mozilla.jss.netscape.security.x509.KeyUsageExtension extension) throws Exception
      This method provides the arguments for certutil to create a cert/CSR with key usage extension.
      Parameters:
      cmd - certutil command and arguments
      extension - The extension to add
      Throws:
      Exception
    • addExtendedKeyUsageExtension

      public void addExtendedKeyUsageExtension(List<String> cmd, org.mozilla.jss.netscape.security.extensions.ExtendedKeyUsageExtension extension) throws Exception
      This method provides the arguments for certutil to create a cert/CSR with extended key usage extension.
      Parameters:
      cmd - certutil command and arguments
      extension - The extension to add
      Throws:
      Exception
    • addCertificatePoliciesExtension

      public void addCertificatePoliciesExtension(List<String> cmd, PrintWriter stdin, org.mozilla.jss.netscape.security.x509.CertificatePoliciesExtension extension) throws Exception
      This method provides the arguments and the standard input for certutil to create a cert/CSR with certificate policies extension.
      Parameters:
      cmd - certutil command and arguments
      stdin - certutil's standard input
      extension - The extension to add
      Throws:
      Exception
    • addOCSPNoCheckExtension

      public void addOCSPNoCheckExtension(List<String> cmd, PrintWriter stdin, org.mozilla.jss.netscape.security.extensions.OCSPNoCheckExtension extension, Path tmpDir) throws Exception
      This method provides the arguments and the standard input for certutil to create a cert/CSR with OCSP No Check extension.
      Parameters:
      cmd - certutil command and arguments
      stdin - certutil's standard input
      extension - The extension to add
      tmpDir - Temporary directory to store extension value
      Throws:
      Exception
    • addExtensions

      public void addExtensions(List<String> cmd, StringWriter sw, org.mozilla.jss.netscape.security.x509.Extensions extensions, Path tmpDir) throws Exception
      Throws:
      Exception
    • loadKeyPair

      public KeyPair loadKeyPair(org.mozilla.jss.crypto.CryptoToken token, byte[] keyID) throws Exception
      Throws:
      Exception
    • createRSAKeyPair

      public KeyPair createRSAKeyPair(org.mozilla.jss.crypto.CryptoToken token, int keySize, org.mozilla.jss.crypto.KeyPairGeneratorSpi.Usage[] usages, org.mozilla.jss.crypto.KeyPairGeneratorSpi.Usage[] usagesMask) throws Exception
      Throws:
      Exception
    • createRSAKeyPair

      public KeyPair createRSAKeyPair(org.mozilla.jss.crypto.CryptoToken token, int keySize) throws Exception
      Throws:
      Exception
    • createECKeyPair

      public KeyPair createECKeyPair(org.mozilla.jss.crypto.CryptoToken token, String curveName, org.mozilla.jss.crypto.KeyPairGeneratorSpi.Usage[] usages, org.mozilla.jss.crypto.KeyPairGeneratorSpi.Usage[] usagesMask) throws Exception
      Throws:
      Exception
    • createECKeyPair

      public KeyPair createECKeyPair(org.mozilla.jss.crypto.CryptoToken token, String curveName) throws Exception
      Throws:
      Exception
    • createPKCS10Request

      public org.mozilla.jss.netscape.security.pkcs.PKCS10 createPKCS10Request(KeyPair keyPair, String subject, String algorithm, org.mozilla.jss.netscape.security.x509.Extensions extensions) throws Exception
      Throws:
      Exception
    • createCertificate

      public X509Certificate createCertificate(org.mozilla.jss.crypto.X509Certificate issuer, org.mozilla.jss.netscape.security.pkcs.PKCS10 pkcs10, Integer monthsValid, String hash, org.mozilla.jss.netscape.security.x509.Extensions extensions) throws Exception
      Throws:
      Exception
    • createCertificate

      public X509Certificate createCertificate(org.mozilla.jss.crypto.X509Certificate issuer, org.mozilla.jss.netscape.security.pkcs.PKCS10 pkcs10, String serialNumber, Integer monthsValid, String hash, org.mozilla.jss.netscape.security.x509.Extensions extensions) throws Exception
      Throws:
      Exception
    • createCertificate

      public X509Certificate createCertificate(String tokenName, org.mozilla.jss.crypto.X509Certificate issuer, org.mozilla.jss.netscape.security.pkcs.PKCS10 pkcs10, String serialNumber, Integer monthsValid, String hash, org.mozilla.jss.netscape.security.x509.Extensions extensions) throws Exception
      Throws:
      Exception
    • delete

      public void delete() throws Exception
      Throws:
      Exception
    • debug

      public void debug(Collection<String> command)
    • readStdout

      public void readStdout(Process process)
    • readStderr

      public void readStderr(Process process)
    • writeStdin

      public void writeStdin(Process process, String input) throws Exception
      Throws:
      Exception