Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.4 KiB

  1. #include "cookiepolicy.h"
  2. /*
  3. Logical conjunction eval-rule
  4. This evaluation rule is capable of expressing statements such as
  5. "if all of the tokens {X, Y, Z} appear in the policy and none of
  6. the tokens {A, B, C} appear, then prompt"
  7. */
  8. class IncludeExcludeRule : public CPEvalRule {
  9. public:
  10. virtual int evaluate(const CompactPolicy &sitePolicy) {
  11. static const CompactPolicy empty;
  12. // This rule is triggered IFF:
  13. // 1. Site policy contains all tokens from the include set, AND
  14. // 2. Site policy contains no tokens from exclude set
  15. bool fApplies = (cpInclude & sitePolicy) == cpInclude &&
  16. (cpExclude & sitePolicy) == empty;
  17. // By convention, if the rule does not apply evaluate()
  18. // function returns the UNKNOWN state
  19. return fApplies ? decision : COOKIE_STATE_UNKNOWN;
  20. }
  21. // These two functions are used to build up the set of tokens
  22. // that MUST be included/excluded for the rule to apply
  23. inline void include(int symindex) { cpInclude.addToken(symindex); }
  24. inline void exclude(int symindex) { cpExclude.addToken(symindex); }
  25. inline void setDecision(int decision) { this->decision = decision; }
  26. inline int getDecision(void) { return decision; }
  27. protected:
  28. CompactPolicy cpInclude;
  29. CompactPolicy cpExclude;
  30. unsigned long decision;
  31. };