示例#1
0
 /**
  * Returns all certificates of a member.
  *
  * @param memberId member if
  * @throws Exception if an error occurs
  */
 @Command(description = "Returns all certificates of a member")
 public void getMemberCerts(
     @Param(name = "memberId", description = "Member identifier") ClientId memberId)
     throws Exception {
   GetMemberCertsResponse response = SignerClient.execute(new GetMemberCerts(memberId));
   System.out.println("Certs of member " + memberId + ":");
   for (CertificateInfo cert : response.getCerts()) {
     System.out.println("\tId:\t" + cert.getId());
     System.out.println("\t\tStatus:\t" + cert.getStatus());
     System.out.println("\t\tActive:\t" + cert.isActive());
   }
 }
示例#2
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");
  }