title: Internalisation using Spring Security In-Memory Authentication
body: <p>I have read the references manuals, looked at forum posts (such as, <a href="https://stackoverflow.com/questions/9062545/how-to-hold-japanese-characters-in-spring-mvc-pojos-field">How to hold japanese characters in SPRING MVC POJO&#39;s field</a>), and I as far as I know I have done all the things necessary for internationalisation Spring support, but I am having problems the Spring Security 3 In-Memory username matching using Unicode/special characters.  Note, that my application uses UTF-8 and all appears well and all works well including entering Unicode password (however, this Unicode password may well be misleading as under the covers it may convert it to another character and this character is encoded instead?).  I have a feeling that this non-matching of Unicode Usernames may be a bug with Spring Security In-Memory internalisation, but need this confirmed. </p>
  
  <p>For the benefit of the reader, I have done all the necessary basic configurations, and please note that if I do not use Unicode character for username, everything works as expected otherwise Authentication fails even though the correct credentials are entered.  Also, no exceptions are thrown.</p>
  
  <p>My snippets are as follows... </p>
  
  <p>web.xml </p>
  
  <pre><code>      &lt;filter&gt;
          &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt;
          &lt;filter-class&gt;org.springframework.web.filter.CharacterEncodingFilter&lt;/filter-class&gt;
          &lt;init-param&gt;
            &lt;param-name&gt;encoding&lt;/param-name&gt;
            &lt;param-value&gt;UTF-8&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;init-param&gt;
            &lt;param-name&gt;forceEncoding&lt;/param-name&gt;
            &lt;param-value&gt;true&lt;/param-value&gt;
          &lt;/init-param&gt;
        &lt;/filter&gt;
        &lt;filter-mapping&gt;
          &lt;filter-name&gt;encodingFilter&lt;/filter-name&gt;
          &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
        &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>spring-servlet-context.xml</p>
  
  <p></p>
  
  <pre><code>        &lt;default-servlet-handler /&gt;
  
          &lt;interceptors&gt;      
              &lt;beans:bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
                  &lt;beans:property name="paramName" value="lang" /&gt;
              &lt;/beans:bean&gt;
  
              &lt;beans:bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor"&gt;
                  &lt;beans:property name="paramName" value="theme" /&gt;
              &lt;/beans:bean&gt;   
  
          &lt;/interceptors&gt; 
  
  
            &lt;resources mapping="/resources/**" location="/resources/" /&gt;
  
  
          &lt;beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
              &lt;beans:property name="basename" value="classpath:messages" /&gt;
              &lt;beans:property name="defaultEncoding" value="UTF-8"/&gt;
          &lt;/beans:bean&gt;
  
          &lt;beans:bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"&gt;
              &lt;beans:property name="defaultLocale" value="en"/&gt;
          &lt;/beans:bean&gt;
  
          &lt;!-- Theme setup --&gt; 
          &lt;beans:bean id="themeSource" class="org.springframework.ui.context.support.ResourceBundleThemeSource"&gt;
                  &lt;beans:property name="basenamePrefix" value="theme-" /&gt;
          &lt;/beans:bean&gt;
  
          &lt;beans:bean id="themeResolver" class="org.springframework.web.servlet.theme.CookieThemeResolver"&gt;
              &lt;beans:property name="defaultThemeName" value="default" /&gt;
          &lt;/beans:bean&gt;
  
  
          &lt;beans:import resource="spring-security.xml"/&gt;
  
           &lt;context:component-scan base-package="com.myproject.platform" /&gt;
  
      &lt;/beans:beans&gt;
  </code></pre>
  
  <p>spring-security.xml</p>
  
  <pre><code>      &lt;beans:bean id="encoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" /&gt;              
  
  
        &lt;authentication-manager alias="authenticationManager"&gt;
          &lt;authentication-provider user-service-ref="userService"&gt;                
              &lt;password-encoder ref="encoder" /&gt;                      
          &lt;/authentication-provider&gt; 
        &lt;/authentication-manager&gt;
  
        &lt;beans:import resource="user-security-bean-config.xml"/&gt; 
  </code></pre>
  
  <p>user-security-bean-config.xml </p>
  
  <pre><code>        &lt;user-service id="userService"&gt;
            &lt;user name="ışığı" password="encodedpasswordstring" 
                           authorities="R_U,R_A"/&gt;
  
          &lt;/user-service&gt;
  </code></pre>
  
  <p>Note, if I have user name as, for example, isigi (without special unicode characters), then all works well.</p>
  
  <p>In my jsp files, I have at the top line: </p>
  
  <pre><code>&lt;%@ page language="java" session="false" contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%&gt;
  </code></pre>
  
  <p>... and in the <em>head</em> section, I have...</p>
  
  <pre><code>&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  </code></pre>
  
  <p>And my xml files, UTF-8 declared at the top line, e.g., </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>