<commit_before>package com.imcode.imcms.servlet;

import imcode.server.Imcms;
import imcode.server.ImcmsServices;
import imcode.server.user.UserDomainObject;
import imcode.util.Utility;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

import com.imcode.imcms.util.l10n.LocalizedMessage;

public class ImcmsMultipleUserLoginFilter implements Filter {

    public final static String TOO_MANY_SESSIONS = "TooManySessions";

    public final static LocalizedMessage LOGIN_MSG_TOO_MANY_SESSIONS
            = new LocalizedMessage("templates/login/TooManySessions");

    public void init(FilterConfig config)
    throws ServletException {}

    public void destroy() {}
    
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
    throws IOException, ServletException {       
        HttpServletRequest request = (HttpServletRequest)req;
        HttpServletResponse response = (HttpServletResponse)res;
        HttpSession session = request.getSession();
        ImcmsServices service = Imcms.getServices();

        UserDomainObject user = Utility.getLoggedOnUser(request) ;

        // In case system denies multiple login for same user
        // invalidate current session if it does not match to
        // last user's session and redirect user to the login page.
        if (user != null && !user.isDefaultUser()
                && service.getConfig().isDenyMultipleUserLogin()) {<commit_msg>Issue 6825 - secondary LDAP support. First line sets request's encoding into utf-8<commit_after>package com.imcode.imcms.servlet;

import imcode.server.Imcms;
import imcode.server.ImcmsServices;
import imcode.server.user.UserDomainObject;
import imcode.util.Utility;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

import com.imcode.imcms.util.l10n.LocalizedMessage;

public class ImcmsMultipleUserLoginFilter implements Filter {

    public final static String TOO_MANY_SESSIONS = "TooManySessions";

    public final static LocalizedMessage LOGIN_MSG_TOO_MANY_SESSIONS
            = new LocalizedMessage("templates/login/TooManySessions");

    public void init(FilterConfig config)
    throws ServletException {}

    public void destroy() {}
    
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
    throws IOException, ServletException {       
    	req.setCharacterEncoding(Imcms.DEFAULT_ENCODING);
    	
        HttpServletRequest request = (HttpServletRequest)req;
        HttpServletResponse response = (HttpServletResponse)res;
        HttpSession session = request.getSession();
        ImcmsServices service = Imcms.getServices();

        UserDomainObject user = Utility.getLoggedOnUser(request) ;

        // In case system denies multiple login for same user
        // invalidate current session if it does not match to
        // last user's session and redirect user to the login page.
        if (user != null && !user.isDefaultUser()
                && service.getConfig().isDenyMultipleUserLogin()) {
{'fraction_non_alphanumeric': 0.07760736196319018, 'fraction_numerical': 0.0027607361963190185, 'mean_word_length': 3.8526785714285716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7250764', 'n_tokens_mistral': 881, 'n_tokens_neox': 850, 'n_words': 228}