package com.action;
import java.util.List;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import com.pojo.User;
import com.service.UserDetaisServiceImpl;
public class LoginAction extends BaseAction {
/**
*
*/
private static final long serialVersionUID = 1L;
private String username;
private String password;
private AuthenticationManager authenticationManager;
public AuthenticationManager getAuthenticationManager() {
return authenticationManager;
}
public void setAuthenticationManager(
AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public void login() {
try {
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
username, password);
// 认证验证,内部会调用 UserDetailsServiceImpl.loadUserByUsername()验证
Authentication authentication = authenticationManager
.authenticate(token);
SecurityContextHolder.getContext()
.setAuthentication(authentication);
this.getSession().setAttribute("SPRING_SECURITY_CONTEXT",
SecurityContextHolder.getContext());
this.getOut().print("success");
} catch (Exception e) {
e.printStackTrace();
this.getOut().print("error");
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
spring Security整合SSH
共77个文件
jar:41个
xml:12个
class:6个
需积分: 12 29 下载量 132 浏览量
2017-01-16
21:04:52
上传
评论
收藏 16.42MB ZIP 举报
温馨提示
Spring Security与SSH整合,Spring Security通过数据库给用户认证授权,且jar完整,除了简单配置数据库,即可运行!
资源推荐
资源详情
资源评论
收起资源包目录
spring Security.zip (77个子文件)
spring Security
.project 1KB
src
struts.xml 307B
spring-security.xml 2KB
applicationContext.xml 2KB
com
service
UserDetaisServiceImpl.java 2KB
pojo
User.java 718B
Role.java 504B
User.hbm.xml 719B
Role.hbm.xml 710B
action
LoginAction.java 2KB
BaseAction.java 914B
dao
UserDetailsDaoImpl.java 470B
WebRoot
WEB-INF
classes
struts.xml 307B
spring-security.xml 2KB
applicationContext.xml 2KB
com
service
UserDetaisServiceImpl.class 2KB
pojo
User.class 1KB
Role.class 1KB
User.hbm.xml 719B
Role.hbm.xml 710B
action
BaseAction.class 1KB
LoginAction.class 3KB
dao
UserDetailsDaoImpl.class 1KB
lib
struts2-convention-plugin-2.3.20.jar 66KB
commons-fileupload-1.3.1.jar 67KB
spring-security-web-3.2.0.RELEASE.jar 334KB
asm-5.0.2.jar 52KB
dom4j-1.6.1.jar 307KB
spring-expression-3.2.0.RELEASE.jar 189KB
spring-beans-3.2.0.RELEASE.jar 591KB
spring-core-3.2.0.RELEASE.jar 843KB
jstl-1.2.jar 405KB
struts2-spring-plugin-2.3.20.jar 21KB
commons-io-2.2.jar 170KB
spring-context-3.2.0.RELEASE.jar 834KB
spring-orm-3.2.0.RELEASE.jar 383KB
commons-logging-1.1.1.jar 59KB
asm-tree-5.0.2.jar 28KB
spring-web-3.2.0.RELEASE.jar 610KB
commons-lang3-3.2.jar 376KB
javax.servlet-api-3.1.0.jar 94KB
antlr-2.7.6.jar 433KB
commons-collections-3.1.jar 546KB
freemarker-2.3.19.jar 909KB
spring-security-config-3.2.0.RELEASE.jar 390KB
hibernate-jpa-2.0-api-1.0.1.Final.jar 100KB
hibernate-ehcache-3.6.6.Final.jar 11KB
slf4j-api-1.6.1.jar 25KB
javassist-3.22.0-CR1.jar 718KB
spring-aop-3.2.0.RELEASE.jar 327KB
spring-security-core-3.2.0.RELEASE.jar 351KB
aspectjweaver-1.8.4.jar 1.78MB
asm-commons-5.0.2.jar 41KB
aopalliance-1.0.jar 4KB
hibernate-core-3.6.6.Final.jar 2.97MB
mysql-connector-java-5.1.34.jar 938KB
struts2-core-2.3.20.jar 807KB
xwork-core-2.3.20.jar 656KB
jta-1.1.jar 15KB
spring-jdbc-3.2.0.RELEASE.jar 392KB
ehcache-core-2.4.3.jar 983KB
ognl-3.0.6.jar 223KB
spring-tx-3.2.0.RELEASE.jar 235KB
hibernate-commons-annotations-3.2.0.Final.jar 70KB
web.xml 2KB
index.jsp 272B
js
jquery-1.4.2.min.js 70KB
jquery-2.1.0.js 305KB
META-INF
MANIFEST.MF 39B
login.jsp 972B
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 414B
org.eclipse.jdt.core.prefs 364B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.component 504B
.jsdtscope 522B
.classpath 1KB
共 77 条
- 1
资源评论
不努力拿什么说明天
- 粉丝: 19
- 资源: 23
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功