diff --git a/README.md b/README.md
index 3d0db56..5afc7f2 100644
--- a/README.md
+++ b/README.md
@@ -1,255 +1,184 @@
[](https://travis-ci.org/crossoverJie/jeeplatform) [](https://gitter.im/jeeplatform/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-## 项目简介 ##
-一款企业信息化开发基础平台,拟集成OA(办公自动化)、SCM(供应链系统)、ERP(企业资源管理系统)、CMS(内容管理系统)、CRM(客户关系管理系统)等企业系统的通用业务功能
+## 一、项目简介
+JeePlatform项目是一款以SpringBoot为核心框架,集ORM框架Mybatis,Web层框架SpringMVC和多种开源组件框架而成的一款通用基础平台,代码已经捐赠给开源中国社区:https://www.oschina.net/p/jeeplatform
-JeePlatform项目是一款以Spring Framework为核心框架,集ORM框架Mybatis,Web层框架SpringMVC和多种开源组件框架而成的一款通用基础平台,代码已经捐赠给开源中国社区:https://www.oschina.net/p/jeeplatform
+代码结构图:
+```
+├─jeeplatform----------------------------父项目,公共依赖
+│ │
+│ ├─jeeplatform-admin--------------------------基础管理系统
+│ │
+│ ├─jeeplatform-cms-----------------------内容管理系统
+│ │
+│ ├─jeeplatform-common--------------------------通用工程
+│ │
+│ ├─jeeplatform-oa--------------------------协调办公系统
+| |
+| |─jeeplatform-provider-----------------------平台服务中心
+│ │
+│ ├─jeeplatform-provider-api-----------------------平台服务API
+| |
+│ ├─jeeplatform-sso-cas-----------------------CAS单点登录服务端
+│ │
+│ ├─jeeplatform--sso-oauth2---------------OAuth2.0单点登录服务端
+│ │
+
+```
-## 系统设计 ##
-### 系统管理(模块名称jeeplatform-admin) ###
-管理系统登录页面,采用Shiro登录验证
+## 二、系统设计
+### 系统管理(模块名称jeeplatform-admin)
+管理系统登录页面
ps:登录链接一般为:http://127.0.0.1:8080/jeeplatform/login
-
+
管理系统主页前端,可以适配移动端页面
-
+
管理系统主页采用开源前端模板,具有换肤功能
-
+
-
+
管理系统主页,获取用户具有的权限,显示菜单
-
+
角色进行授权,只有超级管理员才具有权限
-
+
角色进行配置,可以学习一下RBAC(基于角色的权限控制)
-
+
使用JavaEmail插件实现邮件发送,记得需要开启SSl验证
-
+
### OA管理系统(待开发)
-
+接入CAS Server实现单点登录
### CMS管理系统(待开发)
+暂时接入Oauth2.0实现的单点登录系统
-## 系统升级
-### 单点登录基础(模块名称jeeplatform-sso)(开发中)
-> 项目采用CAS登录登录实现,单点登录集群搭建可以参考博客:
+## 三、关键技术
+### CAS单点登录基础(模块名称jeeplatform-sso-cas)(功能修整中)
+> 项目采用CAS实现单点登录,单点登录集群搭建可以参考博客:
> http://blog.csdn.net/u014427391/article/details/78653482
-> 项目单点登录:使用nginx作为负载均衡,使用redis存储tomcat session,来实现集群中tomcat session的共享,使用redis作为cas ticket的仓库,来实现集群中cas ticket的一致性。
+> 项目单点登录:使用nginx作为负载均衡,使用redis存储tomcat session,来实现集群中tomcat session的共享,使用redis作为cas ticket的仓库,来实现集群中cas ticket的一致性。OA已经对接CAS,admin工程暂时不对接CAS
-单点登录集群如图
-
-### SpringBoot集成Redis缓存处理(Spring AOP实现)
-先从Redis里获取缓存,查询不到,就查询MySQL数据库,然后再保存到Redis缓存里,下次查询时直接调用Redis缓存
+图来自官网,这里简单介绍一下,从图可以看出,CAS支持多种方式的认证,一种是LDAP的、比较常见的数据库Database的JDBC,还有Active Directory等等;支持的协议有Custom Protocol 、 CAS 、 OAuth 、 OpenID 、 RESTful API 、 SAML1.1 、 SAML2.0 等
-```
-package org.muses.jeeplatform.cache;
-
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
-
-/**
- * AOP实现Redis缓存处理
- */
-@Component
-@Aspect
-public class RedisAspect {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(RedisAspect.class);
-
- @Autowired
- @Qualifier("redisCache")
- private RedisCache redisCache;
-
- /**
- * 拦截所有元注解RedisCache注解的方法
- */
- @Pointcut("@annotation(org.muses.jeeplatform.annotation.RedisCache)")
- public void pointcutMethod(){
-
- }
-
- /**
- * 环绕处理,先从Redis里获取缓存,查询不到,就查询MySQL数据库,
- * 然后再保存到Redis缓存里
- * @param joinPoint
- * @return
- */
- @Around("pointcutMethod()")
- public Object around(ProceedingJoinPoint joinPoint){
- //前置:从Redis里获取缓存
- //先获取目标方法参数
- long startTime = System.currentTimeMillis();
- String applId = null;
- Object[] args = joinPoint.getArgs();
- if (args != null && args.length > 0) {
- applId = String.valueOf(args[0]);
- }
-
- //获取目标方法所在类
- String target = joinPoint.getTarget().toString();
- String className = target.split("@")[0];
-
- //获取目标方法的方法名称
- String methodName = joinPoint.getSignature().getName();
-
- //redis中key格式: applId:方法名称
- String redisKey = applId + ":" + className + "." + methodName;
-
- Object obj = redisCache.getDataFromRedis(redisKey);
-
- if(obj!=null){
- LOGGER.info("**********从Redis中查到了数据**********");
- LOGGER.info("Redis的KEY值:"+redisKey);
- LOGGER.info("REDIS的VALUE值:"+obj.toString());
- return obj;
- }
- long endTime = System.currentTimeMillis();
- LOGGER.info("Redis缓存AOP处理所用时间:"+(endTime-startTime));
- LOGGER.info("**********没有从Redis查到数据**********");
- try{
- obj = joinPoint.proceed();
- }catch(Throwable e){
- e.printStackTrace();
- }
- LOGGER.info("**********开始从MySQL查询数据**********");
- //后置:将数据库查到的数据保存到Redis
- String code = redisCache.saveDataToRedis(redisKey,obj);
- if(code.equals("OK")){
- LOGGER.info("**********数据成功保存到Redis缓存!!!**********");
- LOGGER.info("Redis的KEY值:"+redisKey);
- LOGGER.info("REDIS的VALUE值:"+obj.toString());
- }
- return obj;
- }
-
-
-}
+
+
+
+
+单点登录集群方案如图
+
+
+### OAuth2.0单点登录基础(模块名称jeeplatform-sso-oauth2)(功能修整中)
+
+
+
+### SpringBoot集成Redis缓存处理(Spring AOP实现)
+先从Redis里获取缓存,查询不到,就查询MySQL数据库,然后再保存到Redis缓存里,下次查询时直接调用Redis缓存,详情参考博客:[链接](https://blog.csdn.net/u014427391/article/details/78799623)
-```

可以看到Redis里保存到了缓存

-## 业务方案 ##
-### 系统管理通用功能 ####
+## 四、业务方案
+### 系统管理通用功能
+- [ ] 单点登录: OAuth2.0+JWT单点登录/CAS单点登录
- [x] 用户管理: 系统用户
-- [x] 角色管理: 按照企业系统职能进行角色分配,每个角色具有不同的系统操作权限 OK
-- [x] 权限管理: 权限管理细分到系统按钮权限,菜单权限,管理员可以对权限进行细分控制
+- [x] 角色管理: 按照企业系统职能进行角色分配,每个角色具有不同的系统操作权限
+- [x] 权限管理: 权限管理细分到系统菜单权限
- [ ] 在线管理:管理在线用户,可以强制下线
-- [x] 菜单管理:系统可以配置系统菜单,并分配不同的权限 OK
+- [x] 菜单管理:系统可以配置系统菜单,并分配不同的权限
- [ ] 报表统计:数据报表、用户分析
-- [ ] 系统监控:数据监控、系统日志(用户登录记录)
-- [ ] 通用接口:SMS(短信)、系统邮件、Excel表导出导入操作...
-### OA系统通用功能(待开发) ###
+- [x] 系统监控:数据库等方面监控(采用Druid提供的)
+- [x] 在线文档:SwaggerUI API在线文档管理
+- [x] 通用接口:系统邮件发送功能、Excel报表功能
+### OA系统通用功能(待开发)
+- [x] 单点登录: CAS单点登录
- [ ] 考勤管理:请假流程
- [ ] 人事管理:机构管理、部门管理、员工管理
-### CMS系统通用功能(待开发) ###
+### CMS系统通用功能(待开发)
+- [x] 单点登录: OAuth2.0+JWT单点登录
- [ ] 信息管理:文章管理、文章审核
...
-## 技术方案 ##
-### 后台技术 ###
-* 工作流引擎:Activiti5
-* ORM框架:Mybatis/Hibernate JPA
+## 五、技术方案
+### 后台技术
+* 工作流引擎:Activiti5(待定)
+* ORM框架:Mybatis
* Web框架:SpringMVC
-* 核心框架:Spring Framework4.0
-* 任务调度:Spring Task
-* 权限安全:Apache Shiro/Spring Security
-* 全文搜索引擎:Lucene/Solr
-* 页面静态化处理:Freemark/Velocity
-* 服务器页面包含技术:SSI
-* 网页即时通讯:long polling/websocket
+* 核心框架:SpringBoot
+* 任务调度:Spring Task(待定)
+* 权限安全:Apache Shiro、Spring Security
+* 全文搜索引擎:Lucene(待定)
+* 模板引擎:JSP(还没使用Thymeleaf,前端需要重构)
+* 服务器页面包含技术:SSI(待定)
+* 网页即时通讯:websocket
* 连接池:Druid(阿里开源)
-* 日志处理:SLF4J
-* 缓存处理:Redis、EhCache
+* 日志处理:SLF4J(日志门面框架)、logback
+* 缓存处理:Redis
* Excel表处理:POI
-### 前端技术 ###
+### 前端技术
* 文件上传:JQuery uploadify
* 树形结构:EasyUI Tree
* 日期插件:JQuery Date
* 弹窗框架:zDialog
* Cookie保存:JQuery Cookie
* 富文本编辑器:Baidu UEDitor
-* 前端框架:Twitter Bootstrap、ExtJS
-
-### 服务器 ####
-* 负载均衡:Nginx
-* 分布式:alibaba Dubbo
-* 中间件:RocketMQ
-
-### 项目测试 ###
-* DeBug:Junit、FindBugs、EclEmma
-* 程序质量:Jdepend4eclipse
-* 压力测试:JMeter
-
-### 工具软件 ###
-* 服务器:SecureCRT
-* Java:IntelliJ IDEA/Eclipse
-* 远程控制:TeamViewer
-* 版本控制:Git
-* Jar管理:Maven
-* UML建模:ArgoUML
-* Eclipse测试插件:EclEmma
-* 程序质量检查插件:Jdepend4eclipse(Eclipse平台)
-## 常见问题 ##
+* 前端框架:Twitter Bootstrap
+
+## 六、常见问题
运行jeeplatform打开页面404,如果是用idea的,就可以edit configurations->configuration->edit working directory设置为:$MODULE_DIR$
-## 项目技术博客介绍 ##
+
+## 七、版本说明
+* master版本
+主干版本,实现简单的权限管理,单点登录方案有CAS和OAuth2.0+JWT两种方案,admin暂时没接单点,oa工程对接cas,cms对接OAuth2.0实现单点登录,微服务只是做了个demo,还没进行项目服务处理,所以并没有merge代码
+* dev版本
+dev版本代码和master分支基本一致
+* 1.0.0版本
+基础版,基本实现简单的权限管理,功能还需改善,权限控制还需要进行细粒度控制
+
+* 1.1.0版本
+进行单点登录对接实验的版本,拟采用两种方案,CAS实现的单点登录和OAuth2.0+JWT单点登录,admin工程暂时还没对接,oa工程对接CAS,cms工程对接OAuth2.0
+
+## 八、项目技术博客介绍
为了帮助学习者更好地理解代码,下面给出自己写的一些博客链接
### Java框架
-* [基于RBAC模型的权限系统设计(Github开源项目)](http://blog.csdn.net/u014427391/article/details/78889378)
-* [Spring Data Jpa+SpringMVC+Jquery.pagination.js实现分页](http://blog.csdn.net/u014427391/article/details/77434664)
+* [基于RBAC模型的权限系统设计](http://blog.csdn.net/u014427391/article/details/78889378)
+* [Spring Data Jpa实现分页](http://blog.csdn.net/u014427391/article/details/77434664)
* [SpringMVC+ZTree实现树形菜单权限配置](https://blog.csdn.net/u014427391/article/details/78889378)
-* [Github开源项目(企业信息化基础平台)](https://blog.csdn.net/u014427391/article/details/78867439)
-* [基于权限安全框架Shiro的登录验证功能实现](http://blog.csdn.net/u014427391/article/details/78307766)
+* [企业信息化基础平台项目介绍](https://blog.csdn.net/u014427391/article/details/78867439)
+* [基于Shiro的登录验证功能实现](http://blog.csdn.net/u014427391/article/details/78307766)
-SpringBoot
+### SpringBoot
+我的Springboot系列博客可以参考我的专栏:[SpringBoot系列博客](https://blog.csdn.net/u014427391/category_9195353.html)
* [SpringBoot热部署配置](https://smilenicky.blog.csdn.net/article/details/89765909)
* [SpringBoot集成Redis实现缓存处理](http://blog.csdn.net/u014427391/article/details/78799623)
* [SpringBoot profles配置多环境](https://smilenicky.blog.csdn.net/article/details/89792248)
* [SpringBoot集成Swagger2](https://smilenicky.blog.csdn.net/article/details/90706219)
-### Redis知识
-* [Redis学习笔记之基本数据结构](https://blog.csdn.net/u014427391/article/details/82860694)
-* [Redis学习笔记之位图](https://blog.csdn.net/u014427391/article/details/87923407)
-* [Redis学习笔记之延时队列](https://blog.csdn.net/u014427391/article/details/87905450)
-* [Redis学习笔记之分布式锁](https://blog.csdn.net/u014427391/article/details/84934045)
-
-### Oracle知识
-* [Oracle知识整理笔录](https://blog.csdn.net/u014427391/article/details/82317376)
-* [Oracle笔记之锁表和解锁](https://blog.csdn.net/u014427391/article/details/83046148)
-* [select in超过1000条报错解决方法](https://blog.csdn.net/u014427391/article/details/87922878)
-* [Oracle笔记之修改表字段类型](https://blog.csdn.net/u014427391/article/details/83046006)
-* [Oracle merge合并更新函数](https://blog.csdn.net/u014427391/article/details/87898729)
-
+### RPC框架
+* [Dubbo服务注册与发现](https://smilenicky.blog.csdn.net/article/details/96754952)
### 单点登录
* [ 单点登录集群安装教程](http://blog.csdn.net/u014427391/article/details/78653482)
+* [CAS单点登录系列之原理简单介绍](https://blog.csdn.net/u014427391/article/details/82083995)
+* [CAS系列之使用cas overlay搭建服务端(一)](https://blog.csdn.net/u014427391/article/details/105818468)
+* [CAS 5.3.1系列之支持JDBC认证登录(二)](https://blog.csdn.net/u014427391/article/details/105603895)
+* [CAS 5.3.1系列之自定义JDBC认证策略(三)](https://blog.csdn.net/u014427391/article/details/105820486)
+* [CAS 5.3.1系列之自定义Shiro认证策略(四)](https://blog.csdn.net/u014427391/article/details/105820586)
+### Docker笔记
+* [Docker简介和安装教程](https://smilenicky.blog.csdn.net/article/details/97613891)
-### SQL调优知识
-* [Oracle优化器基础知识](https://blog.csdn.net/u014427391/article/details/88650696)
-* [Oracle性能调优之虚拟索引用法简介](https://smilenicky.blog.csdn.net/article/details/89761234)
-* [Oracle性能调优之物化视图用法简介](https://smilenicky.blog.csdn.net/article/details/89762680)
-* [Orace执行计划学习笔记](https://smilenicky.blog.csdn.net/article/details/89604262)
-* [Oracle共享池分析SQL资源使用情况](https://blog.csdn.net/u014427391/article/details/86562755)
diff --git a/code/.gitignore b/code/.gitignore
index 266bfaa..4ace0e4 100644
--- a/code/.gitignore
+++ b/code/.gitignore
@@ -19,6 +19,7 @@ mvnw.*
*.ipr
*.iml
*.iws
+.mvn
# temp ignore
*.log
diff --git a/code/HELP.md b/code/HELP.md
new file mode 100644
index 0000000..73e3250
--- /dev/null
+++ b/code/HELP.md
@@ -0,0 +1,8 @@
+# Getting Started
+
+### Reference Documentation
+For further reference, please consider the following sections:
+
+* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html)
+* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.0.RELEASE/maven-plugin/)
+
diff --git a/code/jeeplatform-admin/pom.xml b/code/jeeplatform-admin/pom.xml
index dbf353c..c5fa26a 100644
--- a/code/jeeplatform-admin/pom.xml
+++ b/code/jeeplatform-admin/pom.xml
@@ -14,8 +14,12 @@
1.2.3
+ 1.2.4
+ 1.2.4
4.7.2
3.7
+ 3.2.0
+ 1.2.4
@@ -26,8 +30,39 @@
org.muses.jeeplatform
- jeeplatform-core
- ${jeeplatform-core.version}
+ jeeplatform-provider-api
+ ${jeeplatform-provider-api.version}
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+ ${spring-boot.version}
+
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+ provided
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ ${spring-boot.version}
+
+
+
+
+ com.alibaba
+ druid
+ ${druid.version}
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ ${druid.version}
@@ -52,13 +87,23 @@
javax.servlet
jstl
-
+
org.apache.shiro
- shiro-all
- ${shiro.version}
+ shiro-spring
+ ${shiro.spring.version}
+
+
+ org.apache.shiro
+ shiro-ehcache
+ ${shiro.encache.version}
+
@@ -74,12 +119,25 @@
1.5.6
-
+
+
+
+
- commons-lang
- commons-lang
- 2.5
+ net.unicon.cas
+ cas-client-autoconfig-support
+ 1.5.0-GA
+
+
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/Application.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/AdminApplication.java
similarity index 58%
rename from code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/Application.java
rename to code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/AdminApplication.java
index 09bbe50..2dab8fb 100644
--- a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/Application.java
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/AdminApplication.java
@@ -1,7 +1,9 @@
package org.muses.jeeplatform;
-import org.muses.jeeplatform.cache.RedisClient;
+import net.unicon.cas.client.configuration.EnableCasClient;
+import org.jasig.cas.client.validation.Assertion;
+import org.muses.jeeplatform.cache.redis.RedisClient;
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
@@ -14,8 +16,14 @@
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+import java.io.IOException;
+
/**
* @author caiyuyu
*/
@@ -27,13 +35,13 @@
//@EnableCaching
@EnableAsync
@Controller
-public class Application {
+public class AdminApplication {
@Autowired
RedisClient redisClient;
public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
+ SpringApplication.run(AdminApplication.class, args);
}
@RequestMapping("/set")
@@ -53,4 +61,27 @@ public String get(String key) throws Exception {
// return c;
// }
+ @GetMapping("/auth")
+ public void auth(HttpServletRequest request, HttpServletResponse response, HttpSession session) {
+ Assertion assertion = (Assertion) session.getAttribute("_const_cas_assertion_");
+ response.setHeader("Content-type", "application/json;charset=UTF-8");
+ response.setCharacterEncoding("utf-8");
+ response.setStatus(200);
+ if (assertion != null) {
+ String redirectUrl= request.getParameter("redirectUrl");
+ try {
+ response.setHeader("Content-type", "text/html;charset=UTF-8");
+ response.sendRedirect(redirectUrl);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+ try {
+ response.getWriter().print("401");
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
}
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/RedisAspect.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/aop/RedisAspect.java
similarity index 96%
rename from code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/RedisAspect.java
rename to code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/aop/RedisAspect.java
index 8f9c726..d886b57 100644
--- a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/RedisAspect.java
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/aop/RedisAspect.java
@@ -1,9 +1,10 @@
-package org.muses.jeeplatform.cache;
+package org.muses.jeeplatform.aop;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
+import org.muses.jeeplatform.cache.redis.RedisCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/authentication/cas/CustomAuthticationRedirectStrategy.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/authentication/cas/CustomAuthticationRedirectStrategy.java
new file mode 100644
index 0000000..01845de
--- /dev/null
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/authentication/cas/CustomAuthticationRedirectStrategy.java
@@ -0,0 +1,36 @@
+package org.muses.jeeplatform.authentication.cas;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.shiro.authc.pam.AbstractAuthenticationStrategy;
+import org.jasig.cas.client.authentication.AuthenticationRedirectStrategy;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ *
+ *
+ *
+ *
+ * @author mazq
+ * 修改记录
+ * 修改后版本: 修改人: 修改日期: 2020/04/27 13:37 修改内容:
+ *
+ */
+public class CustomAuthticationRedirectStrategy implements AuthenticationRedirectStrategy {
+
+ @Override
+ public void redirect(HttpServletRequest request, HttpServletResponse response, String potentialRedirectUrl) throws IOException {
+// response.setCharacterEncoding("utf-8");
+// response.setContentType("application/json; charset=utf-8");
+// PrintWriter out = response.getWriter();
+// out.write("401");
+ //response重定向
+ response.sendRedirect(potentialRedirectUrl);
+ }
+}
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/RedisCache.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/redis/RedisCache.java
similarity index 92%
rename from code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/RedisCache.java
rename to code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/redis/RedisCache.java
index af3cd3b..01ebfdf 100644
--- a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/RedisCache.java
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/redis/RedisCache.java
@@ -1,5 +1,6 @@
-package org.muses.jeeplatform.cache;
+package org.muses.jeeplatform.cache.redis;
+import org.muses.jeeplatform.cache.SerializeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/RedisClient.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/redis/RedisClient.java
similarity index 94%
rename from code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/RedisClient.java
rename to code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/redis/RedisClient.java
index 101991a..ce7c0f4 100644
--- a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/RedisClient.java
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/cache/redis/RedisClient.java
@@ -1,4 +1,4 @@
-package org.muses.jeeplatform.cache;
+package org.muses.jeeplatform.cache.redis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/component/CustomErrorAttributes.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/component/CustomErrorAttributes.java
new file mode 100644
index 0000000..f15e6ae
--- /dev/null
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/component/CustomErrorAttributes.java
@@ -0,0 +1,35 @@
+package org.muses.jeeplatform.component;
+
+import org.springframework.boot.autoconfigure.web.DefaultErrorAttributes;
+import org.springframework.stereotype.Component;
+import org.springframework.web.context.request.RequestAttributes;
+
+import java.util.Map;
+
+/**
+ *
+ * 自定义异常Attributes类
+ *
+ *
+ * @author nicky
+ *
+ * 修改记录
+ * 修改后版本: 修改人: 修改日期: 2019年12月01日 修改内容:
+ *
+ */
+@Component
+public class CustomErrorAttributes extends DefaultErrorAttributes {
+
+ //返回值的map就是页面和json能获取的所有字段
+ @Override
+ public Map getErrorAttributes(RequestAttributes requestAttributes, boolean includeStackTrace) {
+ //先将默认的Attributes封装到map
+ Map map = super.getErrorAttributes(requestAttributes, includeStackTrace);
+ map.put("company","company.com");
+ //获取ExceptionHandler设置的Attributes,0表示从Request中拿
+ Map ext = (Map) requestAttributes.getAttribute("extend",0);
+ map.put("extend",ext);
+ return map;
+ }
+
+}
\ No newline at end of file
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/component/CustomExceptionHandler.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/component/CustomExceptionHandler.java
new file mode 100644
index 0000000..8643de6
--- /dev/null
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/component/CustomExceptionHandler.java
@@ -0,0 +1,48 @@
+package org.muses.jeeplatform.component;
+
+import org.muses.jeeplatform.exception.CustomException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * 自定义异常处理类
+ *
+ *
+ * @author nicky
+ *
+ * 修改记录
+ * 修改后版本: 修改人: 修改日期: 2019年12月01日 修改内容:
+ *
+ */
+//@RestControllerAdvice
+@ControllerAdvice
+public class CustomExceptionHandler {
+
+// @ExceptionHandler(NotFoundException.class)
+// @ResponseBody
+// //@ResponseStatus(value=HttpStatus.INTERNAL_SERVER_ERROR)
+// @Deprecated
+// public Map handleException(Exception e){
+// Map map = new HashMap<>(16);
+// map.put("code", "404");
+// map.put("message", e.getMessage());
+// return map;
+// }
+
+ @ExceptionHandler({CustomException.class})
+ public String handleException(Exception e, HttpServletRequest request){
+ Map map = new HashMap<>(16);
+ map.put("code", "404");
+ map.put("message", e.getMessage());
+ request.setAttribute("javax.servlet.error.status_code",404);
+ request.setAttribute("extend",map);
+ return "forward:/error";//BasicErrorController的接口
+ }
+
+
+}
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/config/CASConfig.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/config/CASConfig.java
new file mode 100644
index 0000000..d777822
--- /dev/null
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/config/CASConfig.java
@@ -0,0 +1,88 @@
+package org.muses.jeeplatform.config;
+
+import net.unicon.cas.client.configuration.CasClientConfigurerAdapter;
+import net.unicon.cas.client.configuration.EnableCasClient;
+import org.jasig.cas.client.authentication.AuthenticationFilter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * TODO 接入CAS 单点登录
+ *
+ *
+ * @author nicky
+ *
+ * 修改记录
+ * 修改后版本: 修改人: 修改日期: 2020年04月11日 修改内容:
+ *
+ */
+//@Configuration
+//@EnableCasClient
+//@EnableConfigurationProperties(CasConfigurationProperties.class)
+public class CASConfig extends CasClientConfigurerAdapter {
+
+// @Autowired
+// private CasConfigurationProperties casProperties;
+
+ private static final String CAS_SERVER_URL_LOGIN = "http://127.0.0.1:8080/cas/login";
+ private static final String SERVER_NAME = "http://127.0.0.1:8081/";
+
+ private static final String AUTHENTICATION_REDIRECT_STRATEGY_CLASS = "org.muses.jeeplatform.authentication.cas.CustomAuthticationRedirectStrategy";
+
+
+ @Override
+ public void configureAuthenticationFilter(FilterRegistrationBean authenticationFilter) {
+ super.configureAuthenticationFilter(authenticationFilter);
+ authenticationFilter.getInitParameters().put("authenticationRedirectStrategyClass",AUTHENTICATION_REDIRECT_STRATEGY_CLASS);
+ }
+
+ @Override
+ public void configureValidationFilter(FilterRegistrationBean validationFilter) {
+ Map initParameters = validationFilter.getInitParameters();
+ initParameters.put("encodeServiceUrl", "false");
+ }
+
+ @Bean
+ public FilterRegistrationBean filterRegistrationBean(){
+ FilterRegistrationBean registrationBean = new FilterRegistrationBean();
+ registrationBean.setFilter(new AuthenticationFilter());
+ registrationBean.addUrlPatterns("/*");
+ Map initParameters = new HashMap(4);
+ initParameters.put("casServerLoginUrl",CAS_SERVER_URL_LOGIN);
+ initParameters.put("serverName",SERVER_NAME);
+ initParameters.put("ignorePattern","/logoutSuccess/*");
+ // 自定义重定向策略
+ initParameters.put("authenticationRedirectStrategyClass", AUTHENTICATION_REDIRECT_STRATEGY_CLASS);
+ registrationBean.setInitParameters(initParameters);
+ registrationBean.setOrder(1);
+ return registrationBean;
+ }
+
+ /*@Bean
+ public FilterRegistrationBean corsFilter() {
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ CorsConfiguration config = new CorsConfiguration();
+ config.setAllowCredentials(true);
+ config.addAllowedOrigin("*");
+ config.addAllowedHeader("*");
+ config.addAllowedMethod("*");
+ source.registerCorsConfiguration("/**", config);
+ FilterRegistrationBean registrationBean = new FilterRegistrationBean();
+ registrationBean.setFilter(new CorsFilter(source));
+ registrationBean.setOrder(1);
+ return registrationBean;
+ }*/
+
+
+
+}
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/config/CorsConfig.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/config/CorsConfig.java
new file mode 100644
index 0000000..e0d2d59
--- /dev/null
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/config/CorsConfig.java
@@ -0,0 +1,28 @@
+package org.muses.jeeplatform.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+
+/**
+ * TODO SSO跨域支持
+ * @Author mazq
+ * @Date 2020/04/28 14:55
+ * @Param
+ * @return
+ */
+//@Configuration
+public class CorsConfig extends WebMvcConfigurationSupport {
+
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry.addMapping("/**")
+ .allowedOrigins("*")
+ .allowedHeaders("*")
+ .allowedMethods("*")
+ .maxAge(3600)
+ .allowCredentials(true);
+ }
+
+
+}
\ No newline at end of file
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/config/DefaultView.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/config/DefaultView.java
new file mode 100644
index 0000000..0ff2b1f
--- /dev/null
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/config/DefaultView.java
@@ -0,0 +1,27 @@
+package org.muses.jeeplatform.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.Ordered;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+/**
+ *
+ *
+ *
+ *
+ *
+ * @author mazq
+ * 修改记录
+ * 修改后版本: 修改人: 修改日期: 2020/04/28 13:29 修改内容:
+ *
+ */
+//@Configuration
+public class DefaultView extends WebMvcConfigurerAdapter {
+ @Override
+ public void addViewControllers(ViewControllerRegistry registry) {
+ registry.addViewController("/").setViewName("index");
+ registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
+ super.addViewControllers(registry);
+ }
+}
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/core/Constants.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/core/CommonConsts.java
similarity index 97%
rename from code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/core/Constants.java
rename to code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/core/CommonConsts.java
index 31127d7..7c75fe8 100644
--- a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/core/Constants.java
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/core/CommonConsts.java
@@ -7,7 +7,7 @@
* @author Nicky
* @date 2017年3月6日
*/
-public class Constants {
+public class CommonConsts {
//定义统一Locale.CHINA,程序中所有和Locale相关操作均默认使用此Locale
public static final Locale LOCALE_CHINA = Locale.CHINA;
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/core/shiro/ShiroRealm.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/core/shiro/ShiroRealm.java
index 6dfda18..a9a918d 100644
--- a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/core/shiro/ShiroRealm.java
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/core/shiro/ShiroRealm.java
@@ -20,6 +20,7 @@
* @author Nicky
* @date 2017年3月12日
*/
+//登录机制代码搬到单点登录工程实现
public class ShiroRealm extends AuthorizingRealm {
/**注解引入业务类**/
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/exception/CustomException.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/exception/CustomException.java
new file mode 100644
index 0000000..909f51b
--- /dev/null
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/exception/CustomException.java
@@ -0,0 +1,30 @@
+package org.muses.jeeplatform.exception;
+
+/**
+ *
+ * 自定义异常类
+ *
+ *
+ * @author nicky
+ *
+ * 修改记录
+ * 修改后版本: 修改人: 修改日期: 2019年12月01日 修改内容:
+ *
+ */
+public class CustomException extends RuntimeException{
+
+ private Integer code;//自定义异常码
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ public CustomException(String message, Integer code) {
+ super(message);// 父类的构造函数;调用底层的Throwable的构造函数,将参数message赋值到detailMessage (Throwable的属性)
+ this.code = code;//赋值code码
+ }
+}
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/util/DateUtils.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/util/DateUtils.java
index d945df3..fad42c8 100644
--- a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/util/DateUtils.java
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/util/DateUtils.java
@@ -2,7 +2,7 @@
-import org.muses.jeeplatform.core.Constants;
+import org.muses.jeeplatform.core.CommonConsts;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -40,7 +40,7 @@ public static String formatDate(Date date,String format){
* @return
*/
public static Date parse(String pattern, String date){
- return parse(pattern, date, Constants.LOCALE_CHINA);
+ return parse(pattern, date, CommonConsts.LOCALE_CHINA);
}
/**
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/CodeController.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/CodeController.java
index ffbf2bb..71e299f 100644
--- a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/CodeController.java
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/CodeController.java
@@ -3,7 +3,7 @@
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
-import org.muses.jeeplatform.core.Constants;
+import org.muses.jeeplatform.core.CommonConsts;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -30,7 +30,7 @@ public void generate(HttpServletResponse response){
Subject currentUser = SecurityUtils.getSubject();
Session session = currentUser.getSession();
- session.setAttribute(Constants.SESSION_SECURITY_CODE, code);
+ session.setAttribute(CommonConsts.SESSION_SECURITY_CODE, code);
try {
ServletOutputStream out = response.getOutputStream();
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/LoginController.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/LoginController.java
index a6022d6..1079f37 100644
--- a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/LoginController.java
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/LoginController.java
@@ -8,7 +8,7 @@
import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
-import org.muses.jeeplatform.core.Constants;
+import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.ResultVO;
import org.muses.jeeplatform.core.entity.admin.Menu;
import org.muses.jeeplatform.core.entity.admin.Permission;
@@ -95,7 +95,7 @@ public ResultVO loginCheck(HttpServletRequest request)throws AuthenticationExcep
//获取Shiro管理的Session
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
- String codeSession = (String)session.getAttribute(Constants.SESSION_SECURITY_CODE);
+ String codeSession = (String)session.getAttribute(CommonConsts.SESSION_SECURITY_CODE);
String code = logindata[2];
/**检测页面验证码是否为空,调用工具类检测**/
if(Tools.isEmpty(code)){
@@ -116,9 +116,9 @@ public ResultVO loginCheck(HttpServletRequest request)throws AuthenticationExcep
}else{
//Shiro添加会话
session.setAttribute("username", username);
- session.setAttribute(Constants.SESSION_USER, user);
+ session.setAttribute(CommonConsts.SESSION_USER, user);
//删除验证码Session
- session.removeAttribute(Constants.SESSION_SECURITY_CODE);
+ session.removeAttribute(CommonConsts.SESSION_SECURITY_CODE);
//保存登录IP
this.getRemortIP(username);
/**Shiro加入身份验证**/
@@ -153,7 +153,7 @@ public ModelAndView toMain() throws AuthenticationException{
/**获取Shiro管理的Session**/
Subject subject = SecurityUtils.getSubject();
Session session = subject.getSession();
- User user = (User)session.getAttribute(Constants.SESSION_USER);
+ User user = (User)session.getAttribute(CommonConsts.SESSION_USER);
if(user != null){
Set roles = user.getRoles();
@@ -218,8 +218,8 @@ public ModelAndView logout(){
/**Shiro管理Session**/
Subject sub = SecurityUtils.getSubject();
Session session = sub.getSession();
- session.removeAttribute(Constants.SESSION_USER);
- session.removeAttribute(Constants.SESSION_SECURITY_CODE);
+ session.removeAttribute(CommonConsts.SESSION_USER);
+ session.removeAttribute(CommonConsts.SESSION_SECURITY_CODE);
/**Shiro销毁登录**/
Subject subject = SecurityUtils.getSubject();
subject.logout();
@@ -228,5 +228,11 @@ public ModelAndView logout(){
return mv;
}
+ @RequestMapping("/403")
+ public ModelAndView to403PAge(){
+ ModelAndView mv = this.getModelAndView();
+ mv.setViewName("admin/frame/403");
+ return mv;
+ }
}
diff --git a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/MenuController.java b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/MenuController.java
index 291c42c..cc39189 100644
--- a/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/MenuController.java
+++ b/code/jeeplatform-admin/src/main/java/org/muses/jeeplatform/web/controller/MenuController.java
@@ -2,7 +2,7 @@
import com.alibaba.fastjson.JSON;
import org.muses.jeeplatform.annotation.LogController;
-import org.muses.jeeplatform.core.Constants;
+import org.muses.jeeplatform.core.CommonConsts;
import org.muses.jeeplatform.core.entity.admin.Menu;
import org.muses.jeeplatform.core.entity.admin.Permission;
import org.muses.jeeplatform.service.MenuService;
@@ -39,7 +39,7 @@ public class MenuController extends BaseController {
public ModelAndView toMenuList(HttpServletRequest request, HttpServletResponse response, Model model) throws IOException {
String pageIndexStr = request.getParameter("pageIndex");
- int pageSize = Constants.PAGE_SIZE;
+ int pageSize = CommonConsts.PAGE_SIZE;
ModelAndView mv = this.getModelAndView();
Page