SEC-1527: Internationalization of contacts sample (Adding message resource bundle and RequestContextFilter). Re-working of L12n section of manual to mention existing localized message files and use of RequestContextFilter.
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
|
||||
|
||||
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
|
||||
<property name="basename" value="classpath:org/springframework/security/messages"/>
|
||||
</bean>
|
||||
|
||||
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
|
||||
<property name="url" value="jdbc:hsqldb:mem:test"/>
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
|
||||
<%@ page pageEncoding="UTF-8" %>
|
||||
|
||||
@@ -31,11 +31,21 @@
|
||||
<param-value>contacts.root</param-value>
|
||||
</context-param>
|
||||
|
||||
<filter>
|
||||
<filter-name>localizationFilter</filter-name>
|
||||
<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter>
|
||||
<filter-name>springSecurityFilterChain</filter-name>
|
||||
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>localizationFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>springSecurityFilterChain</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
<title>Access Denied</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body>
|
||||
<h1>Sorry, access is denied</h1>
|
||||
|
||||
<p>
|
||||
<%= request.getAttribute("SPRING_SECURITY_403_EXCEPTION")%>
|
||||
</p>
|
||||
<p>
|
||||
<% Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (auth != null) { %>
|
||||
Authentication object as a String: <%= auth.toString() %><BR><BR>
|
||||
<% Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (auth != null) { %>
|
||||
Authentication object as a String: <%= auth.toString() %><br /><br />
|
||||
<% } %>
|
||||
</p>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<%@ taglib prefix='c' uri='http://java.sun.com/jstl/core' %>
|
||||
|
||||
<%@ page import="org.springframework.security.core.context.SecurityContextHolder" %>
|
||||
<%@ page import="org.springframework.security.core.Authentication" %>
|
||||
<%@ page import="org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter" %>
|
||||
<%@ page import="org.springframework.security.core.AuthenticationException" %>
|
||||
<%@ page import="org.springframework.security.core.context.SecurityContextHolder" %>
|
||||
<%@ page pageEncoding="UTF-8" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
@@ -16,7 +15,7 @@
|
||||
<c:if test="${not empty param.login_error}">
|
||||
<font color="red">
|
||||
Your 'Exit User' attempt was not successful, try again.<br/><br/>
|
||||
Reason: <%= ((AuthenticationException) session.getAttribute(AbstractAuthenticationProcessingFilter.SPRING_SECURITY_LAST_EXCEPTION_KEY)).getMessage() %>
|
||||
Reason: <c:out value="${SPRING_SECURITY_LAST_EXCEPTION.message}"/>
|
||||
</font>
|
||||
</c:if>
|
||||
|
||||
@@ -24,16 +23,13 @@
|
||||
<table>
|
||||
<tr><td>Current User:</td><td>
|
||||
|
||||
<%
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (auth != null) { %>
|
||||
|
||||
<%= auth.getPrincipal().toString() %>
|
||||
|
||||
<% } %>
|
||||
|
||||
<%
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (auth != null) { %>
|
||||
|
||||
<%= auth.getPrincipal().toString() %>
|
||||
|
||||
<% } %>
|
||||
</td></tr>
|
||||
<tr><td colspan='2'><input name="exit" type="submit" value="Exit"></td></tr>
|
||||
</table>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<%@ taglib prefix='c' uri='http://java.sun.com/jstl/core_rt' %>
|
||||
<%@ page pageEncoding="UTF-8" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
@@ -19,6 +20,7 @@
|
||||
<p>username <b>jane</b>, password <b>wombat</b>
|
||||
<p>
|
||||
|
||||
<p>Locale is: <%= request.getLocale() %></p>
|
||||
<%-- this form-login-page form is also used as the
|
||||
form-error-page to ask for a login again.
|
||||
--%>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<%@ taglib prefix='c' uri='http://java.sun.com/jstl/core' %>
|
||||
<%@ page import="org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter" %>
|
||||
<%@ page import="org.springframework.security.core.AuthenticationException" %>
|
||||
<%@ page pageEncoding="UTF-8" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
|
||||
Reference in New Issue
Block a user