Ejemplo n.º 1
0
  public DERObject getDERObject() {
    ASN1EncodableVector vec = new ASN1EncodableVector();
    Enumeration e = ordering.elements();

    while (e.hasMoreElements()) {
      DERObjectIdentifier oid = (DERObjectIdentifier) e.nextElement();
      X509Extension ext = (X509Extension) extensions.get(oid);
      ASN1EncodableVector v = new ASN1EncodableVector();

      v.add(oid);

      if (ext.isCritical()) {
        v.add(new DERBoolean(true));
      }

      v.add(ext.getValue());

      vec.add(new DERSequence(v));
    }

    return new DERSequence(vec);
  }
  public static BasicConstraints getInstance(Object obj) {
    if (obj instanceof BasicConstraints) {
      return (BasicConstraints) obj;
    }
    if (obj instanceof X509Extension) {
      return getInstance(X509Extension.convertValueToObject((X509Extension) obj));
    }
    if (obj != null) {
      return new BasicConstraints(ASN1Sequence.getInstance(obj));
    }

    return null;
  }
  public static SubjectKeyIdentifier getInstance(Object obj) {
    if (obj instanceof SubjectKeyIdentifier) {
      return (SubjectKeyIdentifier) obj;
    }

    if (obj instanceof SubjectPublicKeyInfo) {
      return new SubjectKeyIdentifier((SubjectPublicKeyInfo) obj);
    }

    if (obj instanceof ASN1OctetString) {
      return new SubjectKeyIdentifier((ASN1OctetString) obj);
    }

    if (obj instanceof X509Extension) {
      return getInstance(X509Extension.convertValueToObject((X509Extension) obj));
    }

    throw new IllegalArgumentException("Invalid SubjectKeyIdentifier: " + obj.getClass().getName());
  }