Internalisation using Spring Security In-Memory Authentication -


i have read references manuals, looked @ forum posts (such as, how hold japanese characters in spring mvc pojo's field), , far know have done things necessary internationalisation spring support, having problems spring security 3 in-memory username matching using unicode/special characters. note, application uses utf-8 , appears , works including entering unicode password (however, unicode password may misleading under covers may convert character , character encoded instead?). have feeling non-matching of unicode usernames may bug spring security in-memory internalisation, need confirmed.

for benefit of reader, have done necessary basic configurations, , please note if not use unicode character username, works expected otherwise authentication fails though correct credentials entered. also, no exceptions thrown.

my snippets follows...

web.xml

      <filter>         <filter-name>encodingfilter</filter-name>         <filter-class>org.springframework.web.filter.characterencodingfilter</filter-class>         <init-param>           <param-name>encoding</param-name>           <param-value>utf-8</param-value>         </init-param>         <init-param>           <param-name>forceencoding</param-name>           <param-value>true</param-value>         </init-param>       </filter>       <filter-mapping>         <filter-name>encodingfilter</filter-name>         <url-pattern>/*</url-pattern>       </filter-mapping> 

spring-servlet-context.xml

        <default-servlet-handler />          <interceptors>                   <beans:bean class="org.springframework.web.servlet.i18n.localechangeinterceptor">                 <beans:property name="paramname" value="lang" />             </beans:bean>              <beans:bean class="org.springframework.web.servlet.theme.themechangeinterceptor">                 <beans:property name="paramname" value="theme" />             </beans:bean>             </interceptors>              <resources mapping="/resources/**" location="/resources/" />           <beans:bean id="messagesource" class="org.springframework.context.support.reloadableresourcebundlemessagesource">             <beans:property name="basename" value="classpath:messages" />             <beans:property name="defaultencoding" value="utf-8"/>         </beans:bean>          <beans:bean id="localeresolver" class="org.springframework.web.servlet.i18n.cookielocaleresolver">             <beans:property name="defaultlocale" value="en"/>         </beans:bean>          <!-- theme setup -->          <beans:bean id="themesource" class="org.springframework.ui.context.support.resourcebundlethemesource">                 <beans:property name="basenameprefix" value="theme-" />         </beans:bean>          <beans:bean id="themeresolver" class="org.springframework.web.servlet.theme.cookiethemeresolver">             <beans:property name="defaultthemename" value="default" />         </beans:bean>           <beans:import resource="spring-security.xml"/>           <context:component-scan base-package="com.myproject.platform" />      </beans:beans> 

spring-security.xml

      <beans:bean id="encoder" class="org.springframework.security.crypto.bcrypt.bcryptpasswordencoder" />                       <authentication-manager alias="authenticationmanager">         <authentication-provider user-service-ref="userservice">                             <password-encoder ref="encoder" />                               </authentication-provider>        </authentication-manager>        <beans:import resource="user-security-bean-config.xml"/>  

user-security-bean-config.xml

        <user-service id="userservice">           <user name="ışığı" password="encodedpasswordstring"                           authorities="r_u,r_a"/>          </user-service> 

note, if have user name as, example, isigi (without special unicode characters), works well.

in jsp files, have @ top line:

<%@ page language="java" session="false" contenttype="text/html; charset=utf-8" pageencoding="utf-8"%> 

... , in head section, have...

<meta http-equiv="content-type" content="text/html; charset=utf-8"> 

and xml files, utf-8 declared @ top line, e.g.,

<?xml version="1.0" encoding="utf-8"?> 

for benefit of others may experience similar problems, order of encodingfilter in web.xml file important , must @ top of filter list otherwise not work. though have read link posted, somehow missed twice, until read third time late last night. forgot mention in post had correctly configured tomcat settings utf-8 in server.xml file adding uriencoding="utf-8" in appropriate places follows:

<connector port="8080" protocol="http/1.1"        connectiontimeout="20000"        redirectport="8443"         uriencoding="utf-8"/>   <connector port="8009" protocol="ajp/1.3" redirectport="8443" uriencoding="utf-8" /> 

i hope answer (together setup stated in question) save hours or nights of frustration of getting special unicode characters work spring mvc / security.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -