Ejemplo n.º 1
0
  /**
   * Show certificate.
   *
   * @param certId certificate id
   * @throws Exception if an error occurs
   */
  @Command(description = "Show certificate")
  public void showCertificate(@Param(name = "certId", description = "Certificate ID") String certId)
      throws Exception {
    List<TokenInfo> tokens = SignerClient.execute(new ListTokens());
    for (TokenInfo token : tokens) {
      for (KeyInfo key : token.getKeyInfo()) {
        for (CertificateInfo cert : key.getCerts()) {
          if (certId.equals(cert.getId())) {
            X509Certificate x509 = readCertificate(cert.getCertificateBytes());
            System.out.println(x509);
            return;
          }
        }
      }
    }

    System.out.println("Certificate " + certId + " not found");
  }