public Collection getIssuerAlternativeNames() throws CertificateParsingException {
   Extension e = getExtension(IssuerAlternativeNames.ID);
   if (e != null) {
     return ((IssuerAlternativeNames) e.getValue()).getNames();
   }
   return null;
 }
 public byte[] getExtensionValue(String oid) {
   Extension e = getExtension(new OID(oid));
   if (e != null) {
     return e.getValue().getEncoded();
   }
   return null;
 }
 public int getBasicConstraints() {
   Extension e = getExtension(BasicConstraints.ID);
   if (e != null) {
     return ((BasicConstraints) e.getValue()).getPathLengthConstraint();
   }
   return -1;
 }
 public boolean[] getKeyUsage() {
   Extension e = getExtension(KeyUsage.ID);
   if (e != null) {
     KeyUsage ku = (KeyUsage) e.getValue();
     boolean[] result = new boolean[9];
     boolean[] b = ku.getKeyUsage().toBooleanArray();
     System.arraycopy(b, 0, result, 0, b.length);
     return result;
   }
   return null;
 }
 public List getExtendedKeyUsage() throws CertificateParsingException {
   Extension e = getExtension(ExtendedKeyUsage.ID);
   if (e != null) {
     List a = ((ExtendedKeyUsage) e.getValue()).getPurposeIds();
     List b = new ArrayList(a.size());
     for (Iterator it = a.iterator(); it.hasNext(); ) {
       b.add(it.next().toString());
     }
     return Collections.unmodifiableList(b);
   }
   return null;
 }
Пример #6
0
 static {
   for (Extension s : EnumSet.allOf(Extension.class)) lookup.put(s.getValue(), s);
 }
Пример #7
0
  public static LanguageTag parseLocale(BaseLocale baseLocale, LocaleExtensions localeExtensions) {
    LanguageTag tag = new LanguageTag();

    String language = baseLocale.getLanguage();
    String script = baseLocale.getScript();
    String region = baseLocale.getRegion();
    String variant = baseLocale.getVariant();

    boolean hasSubtag = false;

    String privuseVar = null; // store ill-formed variant subtags

    if (isLanguage(language)) {
      // Convert a deprecated language code to its new code
      if (language.equals("iw")) {
        language = "he";
      } else if (language.equals("ji")) {
        language = "yi";
      } else if (language.equals("in")) {
        language = "id";
      }
      tag.language = language;
    }

    if (isScript(script)) {
      tag.script = canonicalizeScript(script);
      hasSubtag = true;
    }

    if (isRegion(region)) {
      tag.region = canonicalizeRegion(region);
      hasSubtag = true;
    }

    // Special handling for no_NO_NY - use nn_NO for language tag
    if (tag.language.equals("no") && tag.region.equals("NO") && variant.equals("NY")) {
      tag.language = "nn";
      variant = "";
    }

    if (variant.length() > 0) {
      List<String> variants = null;
      StringTokenIterator varitr = new StringTokenIterator(variant, BaseLocale.SEP);
      while (!varitr.isDone()) {
        String var = varitr.current();
        if (!isVariant(var)) {
          break;
        }
        if (variants == null) {
          variants = new ArrayList<>();
        }
        variants.add(var); // Do not canonicalize!
        varitr.next();
      }
      if (variants != null) {
        tag.variants = variants;
        hasSubtag = true;
      }
      if (!varitr.isDone()) {
        // ill-formed variant subtags
        StringJoiner sj = new StringJoiner(SEP);
        while (!varitr.isDone()) {
          String prvv = varitr.current();
          if (!isPrivateuseSubtag(prvv)) {
            // cannot use private use subtag - truncated
            break;
          }
          sj.add(prvv);
          varitr.next();
        }
        if (sj.length() > 0) {
          privuseVar = sj.toString();
        }
      }
    }

    List<String> extensions = null;
    String privateuse = null;

    if (localeExtensions != null) {
      Set<Character> locextKeys = localeExtensions.getKeys();
      for (Character locextKey : locextKeys) {
        Extension ext = localeExtensions.getExtension(locextKey);
        if (isPrivateusePrefixChar(locextKey)) {
          privateuse = ext.getValue();
        } else {
          if (extensions == null) {
            extensions = new ArrayList<>();
          }
          extensions.add(locextKey.toString() + SEP + ext.getValue());
        }
      }
    }

    if (extensions != null) {
      tag.extensions = extensions;
      hasSubtag = true;
    }

    // append ill-formed variant subtags to private use
    if (privuseVar != null) {
      if (privateuse == null) {
        privateuse = PRIVUSE_VARIANT_PREFIX + SEP + privuseVar;
      } else {
        privateuse =
            privateuse
                + SEP
                + PRIVUSE_VARIANT_PREFIX
                + SEP
                + privuseVar.replace(BaseLocale.SEP, SEP);
      }
    }

    if (privateuse != null) {
      tag.privateuse = privateuse;
    }

    if (tag.language.length() == 0 && (hasSubtag || privateuse == null)) {
      // use lang "und" when 1) no language is available AND
      // 2) any of other subtags other than private use are available or
      // no private use tag is available
      tag.language = UNDETERMINED;
    }

    return tag;
  }