class CookieFilter implements Filter {
    private FilterConfig fc;

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
            throws IOException, ServletException {<FILL_FUNCTION_BODY>}

    private String getSuffix() {
        StringBuilder sb = new StringBuilder();

        for (Enumeration<String> e = fc.getInitParameterNames(); e.hasMoreElements();) {
            String attributeName = e.nextElement();
            if (sb.length() > 0) {
                sb.append("; ");
            }
            sb.append(attributeName);
            String attributeValue = fc.getInitParameter(attributeName);
            if (!attributeValue.isEmpty()) {
                sb.append("=");
                sb.append(attributeValue);
            }
        }
        return sb.toString();
    }

    @Override
    public void init(FilterConfig filterConfig) {
        this.fc = filterConfig;
    }

    @Override
    public void destroy() {
        // pass
    }
}


        HttpServletResponse response = (HttpServletResponse) res;

        chain.doFilter(req, response);

        // Change the existing cookies to use the attributes and values from the configuration.
        String cookieName = HttpHeaders.SET_COOKIE;
        Collection<String> headers = response.getHeaders(cookieName);
        if (headers == null) {
            return;
        }
        boolean firstHeader = true;
        String suffix = getSuffix();
        for (String header : headers) { // there can be multiple Set-Cookie attributes
            if (firstHeader) {
                response.setHeader(cookieName, String.format("%s; %s", header, suffix));
                firstHeader = false;
                continue;
            }
            response.addHeader(cookieName, String.format("%s; %s", header, suffix));
        }
    
<no_super_class>