コード例 #1
0
  private Object[] getNames() {
    GeneralNames name;

    if (form instanceof V2Form) {
      name = ((V2Form) form).getIssuerName();
    } else {
      name = (GeneralNames) form;
    }

    GeneralName[] names = name.getNames();

    List l = new ArrayList(names.length);

    for (int i = 0; i != names.length; i++) {
      if (names[i].getTagNo() == GeneralName.directoryName) {
        try {
          l.add(
              new X500Principal(
                  ((ASN1Encodable) names[i].getName()).toASN1Primitive().getEncoded()));
        } catch (IOException e) {
          throw new RuntimeException("badly formed Name object");
        }
      }
    }

    return l.toArray(new Object[l.size()]);
  }
コード例 #2
0
  public String toString() {
    StringBuffer buf = new StringBuffer();
    String nl = System.getProperty("line.separator");

    buf.append("      userCertificate: ").append(this.getSerialNumber()).append(nl);
    buf.append("       revocationDate: ").append(this.getRevocationDate()).append(nl);
    buf.append("       certificateIssuer: ").append(this.getCertificateIssuer()).append(nl);

    Extensions extensions = c.getExtensions();

    if (extensions != null) {
      Enumeration e = extensions.oids();
      if (e.hasMoreElements()) {
        buf.append("   crlEntryExtensions:").append(nl);

        while (e.hasMoreElements()) {
          ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) e.nextElement();
          Extension ext = extensions.getExtension(oid);
          if (ext.getExtnValue() != null) {
            byte[] octs = ext.getExtnValue().getOctets();
            ASN1InputStream dIn = new ASN1InputStream(octs);
            buf.append("                       critical(").append(ext.isCritical()).append(") ");
            try {
              if (oid.equals(X509Extension.reasonCode)) {
                buf.append(CRLReason.getInstance(ASN1Enumerated.getInstance(dIn.readObject())))
                    .append(nl);
              } else if (oid.equals(X509Extension.certificateIssuer)) {
                buf.append("Certificate issuer: ")
                    .append(GeneralNames.getInstance(dIn.readObject()))
                    .append(nl);
              } else {
                buf.append(oid.getId());
                buf.append(" value = ").append(ASN1Dump.dumpAsString(dIn.readObject())).append(nl);
              }
            } catch (Exception ex) {
              buf.append(oid.getId());
              buf.append(" value = ").append("*****").append(nl);
            }
          } else {
            buf.append(nl);
          }
        }
      }
    }

    return buf.toString();
  }
コード例 #3
0
  private boolean matchesDN(X500Principal subject, GeneralNames targets) {
    GeneralName[] names = targets.getNames();

    for (int i = 0; i != names.length; i++) {
      GeneralName gn = names[i];

      if (gn.getTagNo() == GeneralName.directoryName) {
        try {
          if (new X500Principal(((ASN1Encodable) gn.getName()).toASN1Primitive().getEncoded())
              .equals(subject)) {
            return true;
          }
        } catch (IOException e) {
        }
      }
    }

    return false;
  }
コード例 #4
0
  private X500Name loadCertificateIssuer(boolean isIndirect, X500Name previousCertificateIssuer) {
    if (!isIndirect) {
      return null;
    }

    Extension ext = getExtension(Extension.certificateIssuer);
    if (ext == null) {
      return previousCertificateIssuer;
    }

    try {
      GeneralName[] names = GeneralNames.getInstance(ext.getParsedValue()).getNames();
      for (int i = 0; i < names.length; i++) {
        if (names[i].getTagNo() == GeneralName.directoryName) {
          return X500Name.getInstance(names[i].getName());
        }
      }
      return null;
    } catch (Exception e) {
      return null;
    }
  }
コード例 #5
0
 public AttributeCertificateIssuer(X509Principal principal) {
   form = new V2Form(GeneralNames.getInstance(new DERSequence(new GeneralName(principal))));
 }