JSON
。我的所有数据都存储在服务器上。如果我正在登录页面,它将在服务器中检查该数据是否存在,如果存在,那么它应该继续。我可以使用spring安全性和身份验证来执行此操作..?对此有任何帮助..?这是我的spring-security.xml
<http use-expressions="true">
<intercept-url pattern="/signin*" access="isAnonymous()" />
<intercept-url pattern="/**" access="isAuthenticated()"/>
<form-login
login-page='/signin'
default-target-url="/home"
authentication-failure-url="/signin?error=true"
login-processing-url="/security/j_spring_security_check"
/>
<logout logout-success-url="/signin" />
</http> and may be i have to add some ref in the authentication manager so that it will check the username and password which are present in the remote server..
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref="user" />
</authentication-manager>
如果有一些链接或某些信息......那么请帮助我
答案 0 :(得分:0)
在您可以配置的服务器中(如果用户名和密码存储在数据库中)
<authentication-manager>
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
SELECT USERNAME, PASSWORD, CASE ENABLED WHEN 1 THEN 'true' ELSE 'false' END 'ENABLED'
FROM TBL_USERS
WHERE USERNAME=?;"
authorities-by-username-query="
SELECT u.USERNAME, r.ROLENAME
FROM TBL_USERS u, TBL_USER_ROLE r
WHERE u.ID = r.USERID
AND u.USERNAME=?;"
/>
</authentication-provider>
</authentication-manager>
或
<authentication-manager>
<authentication-provider>
<user-service>
<user name="user" password="123456" authorities="ROLE_USER" />
<user name="admin" password="123456" authorities="ROLE_ADMIN" />
<user name="dba" password="123456" authorities="ROLE_DBA" />
</user-service>
</authentication-provider>
</authentication-manager>
表格登录
<form name='loginForm' action="<c:url value='/j_spring_security_check' />" method='POST'>
<table>
<tr>
<td>User:</td>
<td><input type='text' name='username'></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password' /></td>
</tr>
<tr>
<td></td>
<td>
<input name="submit" type="submit" value="Login"/>
</td>
</tr>
</table>
</form>
认为它可以提供帮助