Example #1
0
 /**
  * Gets the single instance of SecurityInfos.
  *
  * @param obj
  * @return single instance of SecurityInfos
  */
 public static SecurityInfos getInstance(Object obj) {
   if (obj instanceof SecurityInfo) {
     return (SecurityInfos) obj;
   } else if (obj instanceof ASN1Set) {
     return new SecurityInfos((ASN1Set) obj);
   } else if (obj instanceof byte[]) {
     return getInstance(new ByteArrayInputStream((byte[]) obj));
   } else if (obj instanceof InputStream) {
     try {
       ASN1StreamParser sp = new ASN1StreamParser((InputStream) obj);
       ASN1Encodable enc = sp.readObject();
       return getInstance(enc.toASN1Primitive());
     } catch (IOException e) {
       LOG.error("Cannot parse SecurityInfos", e);
     }
   }
   throw new IllegalArgumentException("Unknown object in factory: " + obj.getClass());
 }