public ExpirationConfiguration loadExpirationConfiguration(File file) {
    log.debug("loadExpirationConfiguration(File)");
    ExpirationConfiguration result = null;
    int defaultConfiguration = -1;

    try {
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      Document doc = db.parse(file);
      doc.getDocumentElement().normalize();

      log.debug("Root element " + doc.getDocumentElement().getNodeName());

      String defaultUnits = "";
      Node defaultDurationNode =
          doc.getElementsByTagName("expirations")
              .item(0)
              .getAttributes()
              .getNamedItem("defaultDuration");
      Node defaultUnitNode =
          doc.getElementsByTagName("expirations")
              .item(0)
              .getAttributes()
              .getNamedItem("defaultUnits");

      if (defaultDurationNode != null) {
        defaultConfiguration = Integer.parseInt(defaultDurationNode.getTextContent());
      }
      if (defaultUnitNode != null) {
        defaultUnits = defaultUnitNode.getTextContent();
      }

      result = new ExpirationConfiguration(defaultConfiguration, defaultUnits);

      NodeList nodeLst = doc.getElementsByTagName("expiration");

      for (int x = 0; x < nodeLst.getLength(); x++) {
        Node item = nodeLst.item(x);
        String aa = item.getAttributes().getNamedItem("assigningAuthority").getTextContent();
        String units = item.getAttributes().getNamedItem("unit").getTextContent();
        String duration = item.getTextContent();

        Expiration expItem = new Expiration(aa, units, Integer.parseInt(duration));

        result.getExpirations().add(expItem);
      }
    } catch (Exception e) {
      log.error("unable to load PCConfiguration file", e);
      e.printStackTrace();
    }

    return result;
  }
  public Expiration loadConfiguration(ExpirationConfiguration config, String assigningAuthority) {
    Expiration result = null;

    if (config != null) {
      for (Expiration item : config.getExpirations()) {
        if (item.getAssigningAuthority().equalsIgnoreCase(assigningAuthority)) {
          result = item;
        }
      }

      if (result == null) {
        if (config.getDefaultDuration() >= 0 && config.getDefaultUnits().length() > 0) {
          result = new Expiration("", config.getDefaultUnits(), config.getDefaultDuration());
        }
      }
    }

    return result;
  }