use of org.motechproject.security.domain.SecurityRuleComparator in project motech by motech.
the class MotechURLSecurityServiceImpl method findAllSecurityRules.
@Override
@Transactional
public List<SecurityRuleDto> findAllSecurityRules() {
List<MotechURLSecurityRule> rules = allSecurityRules.getRules();
Collections.sort(rules, new SecurityRuleComparator());
return toSecurityRuleDtoList(rules);
}
use of org.motechproject.security.domain.SecurityRuleComparator in project motech by motech.
the class MotechProxyManager method updateSecurityChain.
/**
* Updates security chain with given {@link org.motechproject.security.domain.MotechURLSecurityRule}
*
* @param securityRules list that contains new security rules
*/
private void updateSecurityChain(List<MotechURLSecurityRule> securityRules) {
LOGGER.debug("Updating security chain");
// sort rules by priority descending
TreeSet<MotechURLSecurityRule> sortedRules = new TreeSet<>(new SecurityRuleComparator());
sortedRules.addAll(securityRules);
List<SecurityFilterChain> newFilterChains = new ArrayList<>();
for (MotechURLSecurityRule securityRule : sortedRules) {
if (securityRule.isActive() && !securityRule.isDeleted()) {
LOGGER.debug("Creating SecurityFilterChain for: {}", securityRule.getPattern());
for (HTTPMethod method : securityRule.getMethodsRequired()) {
newFilterChains.add(securityRuleBuilder.buildSecurityChain(securityRule, method));
}
LOGGER.debug("Created SecurityFilterChain for: {}", securityRule.getPattern());
}
}
proxy = new FilterChainProxy(newFilterChains);
LOGGER.debug("Updated security chain.");
}
Aggregations