Exemple #1
0
  public static OtherStatusInfo getInstance(Object obj) {
    if (obj instanceof OtherStatusInfo) {
      return (OtherStatusInfo) obj;
    }

    if (obj instanceof ASN1Encodable) {
      ASN1Encodable asn1Value = ((ASN1Encodable) obj).toASN1Primitive();

      if (asn1Value instanceof ASN1Integer) // CMCFail info is an asn1 integer.
      {
        return new OtherStatusInfo(CMCFailInfo.getInstance(asn1Value));
      } else if (asn1Value instanceof ASN1Sequence) // PendInfo is a sequence.
      {
        if (((ASN1Sequence) asn1Value).getObjectAt(0) instanceof ASN1ObjectIdentifier) {
          return new OtherStatusInfo(ExtendedFailInfo.getInstance(asn1Value));
        }
        return new OtherStatusInfo(PendInfo.getInstance(asn1Value));
      }
    } else if (obj instanceof byte[]) {
      ASN1InputStream ain = new ASN1InputStream(new ByteArrayInputStream((byte[]) obj));
      try {
        return getInstance(ain.readObject());
      } catch (Exception e) {
        throw new IllegalArgumentException(e.getMessage(), e);
      } finally {
        try {
          ain.close();
        } catch (IOException e) {
          throw new IllegalArgumentException(e.getMessage(), e);
        }
      }
    }
    throw new IllegalArgumentException(
        "unknown object in getInstance(): " + obj.getClass().getName());
  }
Exemple #2
0
 public ASN1Primitive toASN1Primitive() {
   if (pendInfo != null) {
     return pendInfo.toASN1Primitive();
   } else if (failInfo != null) {
     return failInfo.toASN1Primitive();
   }
   return extendedFailInfo.toASN1Primitive();
 }