class DBService implements RolesProvider {

    Policy updateTemplatePolicy(Policy policy, String domainName, List<TemplateParam> params) {
        
        // first process our given role name and carry out any
        // requested substitutions
        
        String templatePolicyName = policy.getName().replace(TEMPLATE_DOMAIN_NAME, domainName);
        if (params != null) {
            for (TemplateParam param : params) {
                final String paramKey = "_" + param.getName() + "_";
                templatePolicyName = templatePolicyName.replace(paramKey, param.getValue());
            }
        }
        
        Policy templatePolicy = new Policy().setName(templatePolicyName);
        List<Assertion> assertions = policy.getAssertions();
        List<Assertion> newAssertions = new ArrayList<>();
        if (assertions != null && !assertions.isEmpty()) {
            for (Assertion assertion : assertions) {
                Assertion newAssertion = new Assertion();
                newAssertion.setAction(assertion.getAction());
                newAssertion.setEffect(assertion.getEffect());
                
                // process our assertion resource and role for any requested substitutions
                
                String resource = assertion.getResource().replace(TEMPLATE_DOMAIN_NAME, domainName);
                String role = assertion.getRole().replace(TEMPLATE_DOMAIN_NAME, domainName);
                if (params != null) {
                    for (TemplateParam param : params) {
                        final String paramKey = "_" + param.getName() + "_";
                        resource = resource.replace(paramKey, param.getValue());
                        role = role.replace(paramKey, param.getValue());
                    }
                }
                newAssertion.setResource(resource);
                newAssertion.setRole(role);
                newAssertions.add(newAssertion);
            }
        }
        templatePolicy.setAssertions(newAssertions);
        return templatePolicy;
    }

    public  DBService(ObjectStore store, AuditLogger auditLogger, ZMSConfig zmsConfig, AuditReferenceValidator auditReferenceValidator);

}