SecurityRuleComparator

public class SecurityRuleComparator implements Comparator<MotechURLSecurityRule>

Class that helps to compare org.motechproject.security.domain.MotechURLSecurityRule

Methods

compare

public int compare(MotechURLSecurityRule o1, MotechURLSecurityRule o2)

Compares two MotechURLSecurityRules to select more important one (one with higher priority or one that comes from the system or one with longer pattern). First checks if both priorities are the same, if yes then checks for origin of both rules. If both of origins equals org.motechproject.security.constants.SecurityConfigConstants.SYSTEM_ORIGIN or if none of them then compares length of patterns from both rules. If origin of only one of the rules is equal then returns number that represents given rule. If priorities of both rules are not the same then just compares them.

Parameters:
  • o1 – first rule
  • o2 – second rule
Returns:

number that represents one of the rules - will return 1 if first rule is more important or -1 if the second one