Example #1
0
 private static LinkedHashSet getProvidersNotUsingCache(
     String serviceName,
     String algName,
     String attrName,
     String filterValue,
     Provider[] allProviders) {
   LinkedHashSet candidates = new LinkedHashSet(5);
   for (int i = 0; i < allProviders.length; i++) {
     if (isCriterionSatisfied(allProviders[i], serviceName, algName, attrName, filterValue)) {
       candidates.add(allProviders[i]);
     }
   }
   return candidates;
 }
  public static ComponentResultSet_c[] getManyPE_CRSsOnR8008(
      ComponentVisibility_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {
    if (targets == null || targets.length == 0 || targets[0] == null)
      return new ComponentResultSet_c[0];

    LinkedHashSet<ComponentResultSet_c> elementsSet = new LinkedHashSet<ComponentResultSet_c>();
    for (int i = 0; i < targets.length; i++) {
      ComponentResultSet_c associate = targets[i].MakesUpAComponentResultSet;
      if (targets[i] != null && associate != null && (test == null || test.evaluate(associate))) {
        if (elementsSet.add(associate)) {}
      }
    }

    ComponentResultSet_c[] result = new ComponentResultSet_c[elementsSet.size()];
    elementsSet.toArray(result);
    return result;
  }
  public static BridgeInvocation_c[] getManyACT_BRGsOnR628(
      ActualParameter_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {
    if (targets == null || targets.length == 0 || targets[0] == null)
      return new BridgeInvocation_c[0];

    LinkedHashSet<BridgeInvocation_c> elementsSet = new LinkedHashSet<BridgeInvocation_c>();
    for (int i = 0; i < targets.length; i++) {
      BridgeInvocation_c associate = targets[i].BridgeInvocation;
      if (targets[i] != null && associate != null && (test == null || test.evaluate(associate))) {
        if (elementsSet.add(associate)) {}
      }
    }

    BridgeInvocation_c[] result = new BridgeInvocation_c[elementsSet.size()];
    elementsSet.toArray(result);
    return result;
  }
  public static Graphnode_c[] getManyDIM_NDsOnR19(
      FloatingText_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {
    if (targets == null || targets.length == 0 || targets[0] == null) return new Graphnode_c[0];

    LinkedHashSet<Graphnode_c> elementsSet = new LinkedHashSet<Graphnode_c>();
    for (int i = 0; i < targets.length; i++) {
      if (loadComponent && targets[i] != null && targets[i].IsSupertypeGraphnode == null)
        targets[i].loadProxy();
      Graphnode_c associate = targets[i].IsSupertypeGraphnode;
      if (targets[i] != null && associate != null && (test == null || test.evaluate(associate))) {
        if (elementsSet.add(associate)) {}
      }
    }

    Graphnode_c[] result = new Graphnode_c[elementsSet.size()];
    elementsSet.toArray(result);
    return result;
  }
Example #5
0
  /**
   * Returns an array containing all installed providers that satisfy the specified* selection
   * criteria, or null if no such providers have been installed. The returned providers are ordered
   * according to their <a href= "#insertProviderAt(java.security.Provider, int)">preference
   * order</a>.
   *
   * <p>The selection criteria are represented by a map. Each map entry represents a selection
   * criterion. A provider is selected iff it satisfies all selection criteria. The key for any
   * entry in such a map must be in one of the following two formats:
   *
   * <ul>
   *   <li><i>&lt;crypto_service>.&lt;algorithm_or_type></i>
   *       <p>The cryptographic service name must not contain any dots.
   *       <p>The value associated with the key must be an empty string.
   *       <p>A provider satisfies this selection criterion iff the provider implements the
   *       specified algorithm or type for the specified cryptographic service.
   *   <li><i>&lt;crypto_service>.&lt;algorithm_or_type> &lt;attribute_name></i>
   *       <p>The cryptographic service name must not contain any dots. There must be one or more
   *       space charaters between the <i>&lt;algorithm_or_type></i> and the
   *       <i>&lt;attribute_name></i>.
   *       <p>The value associated with the key must be a non-empty string. A provider satisfies
   *       this selection criterion iff the provider implements the specified algorithm or type for
   *       the specified cryptographic service and its implementation meets the constraint expressed
   *       by the specified attribute name/value pair.
   * </ul>
   *
   * <p>See Appendix A in the <a href= "../../../guide/security/CryptoSpec.html#AppA"> Java
   * Cryptogaphy Architecture API Specification &amp; Reference </a> for information about standard
   * cryptographic service names, standard algorithm names and standard attribute names.
   *
   * @param filter the criteria for selecting providers. The filter is case-insensitive.
   * @return all the installed providers that satisfy the selection criteria, or null if no such
   *     providers have been installed.
   * @throws InvalidParameterException if the filter is not in the required format
   * @throws NullPointerException if filter is null
   * @see #getProviders(java.lang.String)
   */
  public static Provider[] getProviders(Map<String, String> filter) {
    // Get all installed providers first.
    // Then only return those providers who satisfy the selection criteria.
    Provider[] allProviders = Security.getProviders();
    Set keySet = filter.keySet();
    LinkedHashSet candidates = new LinkedHashSet(5);

    // Returns all installed providers
    // if the selection criteria is null.
    if ((keySet == null) || (allProviders == null)) {
      return allProviders;
    }

    boolean firstSearch = true;

    // For each selection criterion, remove providers
    // which don't satisfy the criterion from the candidate set.
    for (Iterator ite = keySet.iterator(); ite.hasNext(); ) {
      String key = (String) ite.next();
      String value = (String) filter.get(key);

      LinkedHashSet newCandidates = getAllQualifyingCandidates(key, value, allProviders);
      if (firstSearch) {
        candidates = newCandidates;
        firstSearch = false;
      }

      if ((newCandidates != null) && !newCandidates.isEmpty()) {
        // For each provider in the candidates set, if it
        // isn't in the newCandidate set, we should remove
        // it from the candidate set.
        for (Iterator cansIte = candidates.iterator(); cansIte.hasNext(); ) {
          Provider prov = (Provider) cansIte.next();
          if (!newCandidates.contains(prov)) {
            cansIte.remove();
          }
        }
      } else {
        candidates = null;
        break;
      }
    }

    if ((candidates == null) || (candidates.isEmpty())) return null;

    Object[] candidatesArray = candidates.toArray();
    Provider[] result = new Provider[candidatesArray.length];

    for (int i = 0; i < result.length; i++) {
      result[i] = (Provider) candidatesArray[i];
    }

    return result;
  }
  public static ComponentInComponent_c[] getManyCN_CICsOnR4203(
      Component_c[] targets, ClassQueryInterface_c test, boolean loadComponent) {
    if (targets == null || targets.length == 0 || targets[0] == null)
      return new ComponentInComponent_c[0];

    LinkedHashSet<ComponentInComponent_c> elementsSet = new LinkedHashSet<ComponentInComponent_c>();
    for (int i = 0; i < targets.length; i++) {
      if (loadComponent
          && targets[i] != null
          && targets[i].IsNestedThroughComponentInComponent == null) targets[i].loadProxy();
      ComponentInComponent_c associate = targets[i].IsNestedThroughComponentInComponent;
      if (targets[i] != null && associate != null && (test == null || test.evaluate(associate))) {
        if (elementsSet.add(associate)) {
          if (loadComponent) {
            associate.loadProxy();
          }
        }
      }
    }

    ComponentInComponent_c[] result = new ComponentInComponent_c[elementsSet.size()];
    elementsSet.toArray(result);
    return result;
  }