私はSpring Security 3.2とHibernate 4を使用しています。現在、次のように機能するカスタムログインがあります。URL "/"
(ルート) は、同じパラメーターに従って別のログインを表示するためのパラメーターを要求するウェルカム jsp 要求です。たとえば、ユーザーが URL を入力すると"/parameter1"
(手動操作)、この変数は、そこから RequestMapping (値 = "/{パラメーター}") を取得するドライバーによって生成されたパーソナライズされたログインを表示します。すべての URL にそのパラメーターが含まれます。問題は、私が持っているのは、ユーザーが退出したい場合、またはセッションの有効期限が切れた場合、春は私にURLを送信しますが、パラメーターをキャプチャするために"/"
私に送信する必要があるということです/parameter1
"parameter1"
カスタムログインに私を残すように。そうすれば、パラメータを手動で再入力する必要がなくなります。私のセキュリティ設定は次のとおりです。
<custom-filter position="FORM_LOGIN_FILTER" ref="myFilter" />
<!-- <form-login login-page="/loginUser" login-processing-url="/testUser/j_spring_security_check"
authentication-failure-url="/loginError" default-target-url="/testUser"
username-parameter="j_username" password-parameter="j_password" /> -->
<logout invalidate-session="true" delete-cookies="JSESSIONID" logout-success-url="/loginUser" logout-url="/testUser/j_spring_security_logout"/>
<session-management invalid-session-url="/" session-fixation-protection="migrateSession" >
<concurrency-control max-sessions="2" expired-url="/" error-if-maximum-exceeded="false"/>
</session-management>
<beans:bean id="loginUrlAuthenticationEntryPoint"
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<beans:property name="loginFormUrl" value="/loginUser" />
</beans:bean>
<beans:bean id="myFilter" class="net.universia.test.autenticacionService.LoginAuthenticationFilter">
<beans:property name="authenticationManager" ref='UserauthenticationManager'/>
<beans:property name="authenticationFailureHandler" ref="failureHandler"/>
<beans:property name="authenticationSuccessHandler" ref="successHandler"/>
<beans:property name="filterProcessesUrl" value="/testUser/j_spring_security_check"/>
</beans:bean>
<beans:bean id = "exceptionTranslationFilter" class = "org.springframework.security.web.access.ExceptionTranslationFilter" >
<beans:property name = "authenticationEntryPoint" ref = "loginUrlAuthenticationEntryPoint" />
<beans:property name = "accessDeniedHandler" ref = "accessDeniedHandler" />
</beans:bean>
<beans:bean id="successHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
<beans:property name="defaultTargetUrl" value="/testUser"/>
</beans:bean>
<beans:bean id = "accessDeniedHandler" class = "org.springframework.security.web.access.AccessDeniedHandlerImpl" >
<beans:property name = "errorPage" value = "/403" />
</beans:bean>
また、ログインフォームを表示するドライバーは次のとおりです。
@RequestMapping(value ="/{testRef}", method = {RequestMethod.POST,RequestMethod.GET})
public @ResponseBody ModelAndView loginTestRef(@PathVariable("testRef") String testRef,HttpSession session, HttpServletRequest request) {
session.setAttribute("ssidreffh", testRef);
TestDatos test = testService.showTestUserByRef(testRef);
request.getSession().setAttribute("test", test);
ModelAndView mav = new ModelAndView("/loginUser");
mav.addObject("test", test);
return mav;
}
ユーザーが URL /dominio/parametro1/paginaPerfil にいる場合、またはセッションが終了すると、Spring は私を URL「/myApp/parameter1」にリダイレクトするため、ルート「/」ではなくログインになります。