class DBService implements RolesProvider {

    Role updateTemplateRole(Role role, String domainName, List<TemplateParam> params) {
        
        // first process our given role name and carry out any
        // requested substitutions
        
        String templateRoleName = role.getName().replace(TEMPLATE_DOMAIN_NAME, domainName);
        if (params != null) {
            for (TemplateParam param : params) {
                final String paramKey = "_" + param.getName() + "_";
                templateRoleName = templateRoleName.replace(paramKey, param.getValue());
            }
        }
        Role templateRole = new Role()
                .setName(templateRoleName)
                .setTrust(role.getTrust())
                //adding additional role meta attributes if present in template->roles
                .setCertExpiryMins(role.getCertExpiryMins())
                .setSelfServe(role.getSelfServe())
                .setMemberExpiryDays(role.getMemberExpiryDays())
                .setTokenExpiryMins(role.getTokenExpiryMins())
                .setSignAlgorithm(role.getSignAlgorithm())
                .setServiceExpiryDays(role.getServiceExpiryDays())
                .setGroupExpiryDays(role.getGroupExpiryDays())
                .setMemberReviewDays(role.getMemberReviewDays())
                .setServiceReviewDays(role.getServiceReviewDays())
                .setReviewEnabled(role.getReviewEnabled())
                .setNotifyRoles(role.getNotifyRoles())
                .setUserAuthorityFilter(role.getUserAuthorityFilter())
                .setUserAuthorityExpiration(role.getUserAuthorityExpiration());
        
        List<RoleMember> roleMembers = role.getRoleMembers();
        List<RoleMember> newMembers = new ArrayList<>();
        if (roleMembers != null && !roleMembers.isEmpty()) {
            for (RoleMember roleMember : roleMembers) {
                RoleMember newRoleMember = new RoleMember();
                
                // process our role members for any requested substitutions
                
                String memberName = roleMember.getMemberName().replace(TEMPLATE_DOMAIN_NAME, domainName);
                if (params != null) {
                    for (TemplateParam param : params) {
                        final String paramKey = "_" + param.getName() + "_";
                        memberName = memberName.replace(paramKey, param.getValue());
                    }
                }
                newRoleMember.setMemberName(memberName);
                newRoleMember.setExpiration(roleMember.getExpiration());
                newMembers.add(newRoleMember);
            }
        }
        templateRole.setRoleMembers(newMembers);
        return templateRole;
    }

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

}