Java 春季安全。自定义身份验证管理器
我有SpringMVC应用程序。我还通过CustomAuthenticationManager添加了Spring安全性。这是appContex.xml中包含的application-security.xml。在login.jsp中,我使用带有两个输入的standart登录页面:name='j_username'&name='j_password',并在CustomAuthenticationManager中的方法中使用than。Authentication(身份验证)我只接收密码,而不接收带有其名称的主体。我做错了什么Java 春季安全。自定义身份验证管理器,java,spring,authentication,spring-security,Java,Spring,Authentication,Spring Security,我有SpringMVC应用程序。我还通过CustomAuthenticationManager添加了Spring安全性。这是appContex.xml中包含的application-security.xml。在login.jsp中,我使用带有两个输入的standart登录页面:name='j_username'&name='j_password',并在CustomAuthenticationManager中的方法中使用than。Authentication(身份验证)我只接收密码,而不接收带有其
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p" xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<bean id="loginPassAuthenticationFilter"
class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter">
<property name="authenticationManager" ref="customAuthenticationManager" />
<property name="allowSessionCreation" value="true" />
<property name="filterProcessesUrl" value="/j_spring_security_check" />
<property name="authenticationFailureHandler" ref="customAuthenticationFailureHandler" />
<property name="authenticationSuccessHandler" ref="customAuthenticationSuccessHandler" />
</bean>
<bean id="customAuthenticationManager"
class="com.whatever.security.CustomAuthenticationManager" />
<bean id="authenticationFilter"
class="org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"
p:authenticationManager-ref="customAuthenticationManager"
p:authenticationFailureHandler-ref="customAuthenticationFailureHandler"
p:authenticationSuccessHandler-ref="customAuthenticationSuccessHandler" />
<bean id="customAuthenticationFailureHandler"
class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"
p:defaultFailureUrl="/?error=true" />
<bean id="customAuthenticationSuccessHandler"
class="org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler"
p:defaultTargetUrl="/" />
<bean id="authenticationEntryPoint"
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint"
p:loginFormUrl="/" />
<security:authentication-manager />
<bean id="passwordEncoder"
class="org.springframework.security.authentication.encoding.ShaPasswordEncoder">
<constructor-arg value="512" />
</bean>
用户:
密码:
我建议使用安全命名空间(链接到最小配置示例):下面是如何定义自己的身份验证提供程序的链接: 创建自己的身份验证提供程序可以解决大多数用例。 如果您需要任何额外的澄清,请告诉我 致以最良好的祝愿
Michael我建议使用安全名称空间(链接到最小配置示例):
下面是如何定义自己的身份验证提供程序的链接: 创建自己的身份验证提供程序可以解决大多数用例。 如果您需要任何额外的澄清,请告诉我 致以最良好的祝愿
Michael您的
j_用户名
输入指定自己的值=''
。这可能会抢占用户输入值。不,这不是帮助shm,我将logger放入Authentication manager,当我使用eclipse部署应用程序时,它会在调试中显示找到了任何登录名,但是如果它是使用控制台部署在真正的服务器上-logger show me login…您的j_用户名
输入指定它自己的值=''
。这可能会抢占用户输入值。不,这不是帮助shm,我将logger放在Authentication manager中,当我使用eclipse部署应用程序时,它会在调试中向我显示找到了任何登录名,但如果它是使用真实服务器上的控制台部署的-logger show me login。。。
<form name='f' action="<c:url value='j_spring_security_check' />"
method='POST'>
<table>
<tr>
<td>User:</td>
<td><input type='text' name='j_username' value=''></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='j_password' /></td>
</tr>
<tr>
<td colspan='2'><input name="submit" type="submit"
value="submit" /></td>
</tr>
<tr>
<td colspan='2'><input name="reset" type="reset" /></td>
</tr>
</table>
</form>