Exemplo n.º 1
0
  public String getValue(String name, Locale locale, X509CertInfo info) throws EPropertyException {
    if (name == null) {
      throw new EPropertyException(CMS.getUserMessage(locale, "CMS_INVALID_PROPERTY", name));
    }

    ExtendedKeyUsageExtension ext =
        (ExtendedKeyUsageExtension) getExtension(ExtendedKeyUsageExtension.OID, info);

    if (ext == null) {
      try {
        populate(null, info);

      } catch (EProfileException e) {
        throw new EPropertyException(CMS.getUserMessage(locale, "CMS_INVALID_PROPERTY", name));
      }
    }

    if (name.equals(VAL_CRITICAL)) {
      ext = (ExtendedKeyUsageExtension) getExtension(ExtendedKeyUsageExtension.OID, info);

      if (ext == null) {
        return null;
      }
      if (ext.isCritical()) {
        return "true";
      } else {
        return "false";
      }
    } else if (name.equals(VAL_OIDS)) {
      ext = (ExtendedKeyUsageExtension) getExtension(ExtendedKeyUsageExtension.OID, info);
      StringBuffer sb = new StringBuffer();
      if (ext == null) {
        return "";
      }
      Enumeration<ObjectIdentifier> e = ext.getOIDs();

      while (e.hasMoreElements()) {
        ObjectIdentifier oid = e.nextElement();

        if (!sb.toString().equals("")) {
          sb.append(",");
        }
        sb.append(oid.toString());
      }
      return sb.toString();
    } else {
      throw new EPropertyException(CMS.getUserMessage(locale, "CMS_INVALID_PROPERTY", name));
    }
  }
Exemplo n.º 2
0
  public void setValue(String name, Locale locale, X509CertInfo info, String value)
      throws EPropertyException {
    ExtendedKeyUsageExtension ext = null;

    ext = (ExtendedKeyUsageExtension) getExtension(ExtendedKeyUsageExtension.OID, info);

    if (ext == null) {
      try {
        populate(null, info);

      } catch (EProfileException e) {
        throw new EPropertyException(CMS.getUserMessage(locale, "CMS_INVALID_PROPERTY", name));
      }
    }
    if (name == null) {
      throw new EPropertyException(CMS.getUserMessage(locale, "CMS_INVALID_PROPERTY", name));
    }
    if (name.equals(VAL_CRITICAL)) {
      ext = (ExtendedKeyUsageExtension) getExtension(ExtendedKeyUsageExtension.OID, info);
      boolean val = Boolean.valueOf(value).booleanValue();

      if (ext == null) {
        return;
      }
      ext.setCritical(val);
    } else if (name.equals(VAL_OIDS)) {
      ext = (ExtendedKeyUsageExtension) getExtension(ExtendedKeyUsageExtension.OID, info);
      //		ext.deleteAllOIDs();
      StringTokenizer st = new StringTokenizer(value, ",");

      if (ext == null) {
        return;
      }
      while (st.hasMoreTokens()) {
        String oid = st.nextToken();

        ext.addOID(new ObjectIdentifier(oid));
      }
    } else {
      throw new EPropertyException(CMS.getUserMessage(locale, "CMS_INVALID_PROPERTY", name));
    }
    try {
      replaceExtension(ExtendedKeyUsageExtension.OID, ext, info);
    } catch (EProfileException e) {
      CMS.debug("ExtendedKeyUsageExtDefault: setValue " + e.toString());
      throw new EPropertyException(CMS.getUserMessage(locale, "CMS_INVALID_PROPERTY", name));
    }
  }
Exemplo n.º 3
0
  public ExtendedKeyUsageExtension createExtension() {
    ExtendedKeyUsageExtension ext = null;

    try {
      ext = new ExtendedKeyUsageExtension();
    } catch (Exception e) {
      CMS.debug("ExtendedKeyUsageExtDefault: createExtension " + e.toString());
    }
    if (ext == null) return null;
    boolean critical = getBoolean(getConfig(CONFIG_CRITICAL));

    ext.setCritical(critical);
    StringTokenizer st = new StringTokenizer(getConfig(CONFIG_OIDS), ",");

    while (st.hasMoreTokens()) {
      String oid = st.nextToken();

      ext.addOID(new ObjectIdentifier(oid));
    }
    return ext;
  }