コード例 #1
0
ファイル: Validate.java プロジェクト: cFerg/MineJava
  public static void noNullElements(Collection collection, String message) {
    Validate.notNull(collection);

    for (Iterator it = collection.iterator(); it.hasNext(); ) {
      if (it.next() == null) {
        throw new IllegalArgumentException(message);
      }
    }
  }
コード例 #2
0
ファイル: Validate.java プロジェクト: cFerg/MineJava
  public static void allElementsOfType(Collection collection, Class clazz, String message) {
    Validate.notNull(collection);

    Validate.notNull(clazz);

    for (Iterator it = collection.iterator(); it.hasNext(); ) {
      if (clazz.isInstance(it.next()) == false) {
        throw new IllegalArgumentException(message);
      }
    }
  }
コード例 #3
0
ファイル: Validate.java プロジェクト: cFerg/MineJava
  public static void noNullElements(Collection collection) {
    Validate.notNull(collection);

    int i = 0;

    for (Iterator it = collection.iterator(); it.hasNext(); i++) {
      if (it.next() == null) {
        throw new IllegalArgumentException(
            "The validated collection contains null element at index: " + i);
      }
    }
  }
コード例 #4
0
ファイル: Validate.java プロジェクト: cFerg/MineJava
  public static void allElementsOfType(Collection collection, Class clazz) {
    Validate.notNull(collection);

    Validate.notNull(clazz);

    int i = 0;

    for (Iterator it = collection.iterator(); it.hasNext(); i++) {
      if (clazz.isInstance(it.next()) == false) {
        throw new IllegalArgumentException(
            "The validated collection contains an element not of type "
                + clazz.getName()
                + " at index: "
                + i);
      }
    }
  }
コード例 #5
0
ファイル: Validate.java プロジェクト: cFerg/MineJava
 public static void notEmpty(Collection collection, String message) {
   if (collection == null || collection.isEmpty()) {
     throw new IllegalArgumentException(message);
   }
 }
コード例 #6
0
ファイル: X509CRLImpl.java プロジェクト: cFerg/MineJava
  public String toString() {
    StringBuffer sb = new StringBuffer();
    sb.append("X.509 CRL v" + (version + 1) + "\n");
    if (sigAlgId != null) {
      sb.append(
          "Signature Algorithm: "
              + sigAlgId.toString()
              + ", OID="
              + (sigAlgId.getOID()).toString()
              + "\n");
    }
    if (issuer != null) {
      sb.append("Issuer: " + issuer.toString() + "\n");
    }
    if (thisUpdate != null) {
      sb.append("\nThis Update: " + thisUpdate.toString() + "\n");
    }
    if (nextUpdate != null) {
      sb.append("Next Update: " + nextUpdate.toString() + "\n");
    }
    if (revokedList.isEmpty()) {
      sb.append("\nNO certificates have been revoked\n");
    } else {
      sb.append("\nRevoked Certificates: " + revokedList.size());
      int i = 1;
      for (X509CRLEntry entry : revokedList) {
        sb.append("\n[" + i++ + "] " + entry.toString());
      }
    }
    if (extensions != null) {
      Collection<Extension> allExts = extensions.getAllExtensions();
      Object[] objs = allExts.toArray();
      sb.append("\nCRL Extensions: " + objs.length);
      for (int i = 0; i < objs.length; i++) {
        sb.append("\n[" + (i + 1) + "]: ");
        Extension ext = (Extension) objs[i];
        try {
          if (OIDMap.getClass(ext.getExtensionId()) == null) {
            sb.append(ext.toString());
            byte[] extValue = ext.getExtensionValue();
            if (extValue != null) {
              DerOutputStream out = new DerOutputStream();
              out.putOctetString(extValue);
              extValue = out.toByteArray();
              HexDumpEncoder enc = new HexDumpEncoder();
              sb.append(
                  "Extension unknown: "
                      + "DER encoded OCTET string =\n"
                      + enc.encodeBuffer(extValue)
                      + "\n");
            }
          } else {
            sb.append(ext.toString());
          }

        } catch (Exception e) {
          sb.append(", Error parsing this extension");
        }
      }
    }
    if (signature != null) {
      HexDumpEncoder encoder = new HexDumpEncoder();
      sb.append("\nSignature:\n" + encoder.encodeBuffer(signature) + "\n");
    } else {
      sb.append("NOT signed yet\n");
    }
    return sb.toString();
  }