<commit_before>package com.knowledgex.web.controller;

import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;

import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.webflow.core.collection.ParameterMap;
import org.springframework.webflow.execution.RequestContext;

import com.knowledgex.web.view.*;

@Controller
@Component("signinController")
public class SigninController {
	
    private static final String REQUEST_PARAM_AUTH_FAILED = "failed";
//    private static final String USER_IS_AUTHENTICATED = "yes";
//    private static final String USER_IS_NOT_AUTHENTICATED = "no";
    
	@SuppressWarnings("unused")
    private static final Logger logger = LoggerFactory.getLogger(SigninController.class);
    
    public AuthenticationBean newAuthenticationBean() {
        return new AuthenticationBean();
    }
    
    public boolean isAuthenticated() {
    	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    	Object principal = auth.getPrincipal();
    	return principal instanceof UserDetails;
    }
    
    public void onEntry(RequestContext rc) {
        final ParameterMap pm = rc.getExternalContext().getRequestParameterMap();
        if (pm.get(REQUEST_PARAM_AUTH_FAILED) != null) {
        	final LocaleBean localeBean = ViewUtil.findBean("localeBean");
        	final Locale locale = localeBean.getLocale();
        	final ResourceBundle bundle = ResourceBundle.getBundle("i18n.MessageResources", locale);
        	final String msg = bundle.getString("credential_incorrect");<commit_msg>[update][refactoring] code of a21b561 has been refactored to use ViewUtil.getResourceBundleString() method<commit_after>package com.knowledgex.web.controller;

import java.io.IOException;

import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.webflow.core.collection.ParameterMap;
import org.springframework.webflow.execution.RequestContext;

import com.knowledgex.web.view.*;

@Controller
@Component("signinController")
public class SigninController {
	
    private static final String REQUEST_PARAM_AUTH_FAILED = "failed";
//    private static final String USER_IS_AUTHENTICATED = "yes";
//    private static final String USER_IS_NOT_AUTHENTICATED = "no";
    
	@SuppressWarnings("unused")
    private static final Logger logger = LoggerFactory.getLogger(SigninController.class);
    
    public AuthenticationBean newAuthenticationBean() {
        return new AuthenticationBean();
    }
    
    public boolean isAuthenticated() {
    	Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    	Object principal = auth.getPrincipal();
    	return principal instanceof UserDetails;
    }
    
    public void onEntry(RequestContext rc) {
        final ParameterMap pm = rc.getExternalContext().getRequestParameterMap();
        if (pm.get(REQUEST_PARAM_AUTH_FAILED) != null) {
        	final String msg = ViewUtil.getResourceBundleString("credential_incorrect");
{'fraction_non_alphanumeric': 0.08829174664107485, 'fraction_numerical': 0.00263915547024952, 'mean_word_length': 5.23168908819133, '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': '6614572', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1092, 'n_words': 230}