Esempio n. 1
0
 /* 16:   */
 /* 17:   */ public Rule getMatchingRule(Node node) /* 18:   */ {
   /* 19:50 */ Rule[] matches = getRuleArray();
   /* 20:52 */ for (int i = matches.length - 1; i >= 0; i--)
   /* 21:   */ {
     /* 22:53 */ Rule rule = matches[i];
     /* 23:55 */ if (rule.matches(node)) {
       /* 24:56 */ return rule;
       /* 25:   */ }
     /* 26:   */ }
   /* 27:60 */ return null;
   /* 28:   */ }
Esempio n. 2
0
  protected void findMatchesToRules(
      @Observes @Priority(EmailEvent.FIND_MATCHES_TO_RULES) EmailEvent evnt) {
    log.info("ENTER");

    Map<Rule, List<EmailMessage>> matches = new HashMap<>();

    for (Rule rule : evnt.getRules()) {
      matches.put(rule, new LinkedList<>());
      for (EmailMessage message : evnt.getFolder().getMessages()) {
        if (rule.matches(message)) {
          matches.get(rule).add(message);
        }
      }
    }

    evnt.setMatches(matches);
  }
  public boolean checkIntent(
      FirewallIntentResolver resolver,
      ComponentName resolvedComponent,
      int intentType,
      Intent intent,
      int callerUid,
      int callerPid,
      String resolvedType,
      int receivingUid) {
    boolean log = false;
    boolean block = false;

    // For the first pass, find all the rules that have at least one intent-filter or
    // component-filter that matches this intent
    List<Rule> candidateRules;
    candidateRules = resolver.queryIntent(intent, resolvedType, false, 0);
    if (candidateRules == null) {
      candidateRules = new ArrayList<Rule>();
    }
    resolver.queryByComponent(resolvedComponent, candidateRules);

    // For the second pass, try to match the potentially more specific conditions in each
    // rule against the intent
    for (int i = 0; i < candidateRules.size(); i++) {
      Rule rule = candidateRules.get(i);
      if (rule.matches(
          this, resolvedComponent, intent, callerUid, callerPid, resolvedType, receivingUid)) {
        block |= rule.getBlock();
        log |= rule.getLog();

        // if we've already determined that we should both block and log, there's no need
        // to continue trying rules
        if (block && log) {
          break;
        }
      }
    }

    if (log) {
      logIntent(intentType, intent, callerUid, resolvedType);
    }

    return !block;
  }