├── README.md ├── cas-capcha-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ ├── DefaultCaptchaWebflowConfigurer.java │ │ │ ├── RememberMeUsernamePasswordCaptchaAuthenticationHandler.java │ │ │ └── RememberMeUsernamePasswordCaptchaCredential.java │ │ ├── config │ │ ├── CaptchaWebflowConfiguration.java │ │ ├── DataSourceConfig.java │ │ ├── RememberMeConfiguration.java │ │ └── SpringConfig.java │ │ ├── controller │ │ └── CaptchaController.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ ├── global │ │ └── utils │ │ │ └── CaptchaUtil.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── app1.properties │ ├── app2.properties │ ├── application.properties │ ├── log4j2.xml │ ├── services │ ├── APP1-1000.json │ └── APP2-1001.json │ ├── sql │ ├── sys_permission.sql │ ├── sys_role.sql │ ├── sys_role_permission.sql │ ├── sys_user_role.sql │ └── user_info.sql │ ├── static │ └── themes │ │ ├── app1 │ │ ├── css │ │ │ └── cas.css │ │ └── js │ │ │ └── jquery-1.4.2.min.js │ │ └── app2 │ │ ├── css │ │ └── cas.css │ │ └── js │ │ └── jquery-1.4.2.min.js │ └── templates │ ├── app1 │ └── casLoginView.html │ ├── app2 │ └── casLoginView.html │ └── casConfirmLogoutView.html ├── cas-client-spring-boot-starter ├── pom.xml └── src │ └── main │ └── java │ └── priv │ └── wangsaichao │ └── cas │ └── client │ └── configuration │ ├── CasClientConfiguration.java │ ├── CasClientConfigurationProperties.java │ └── EnableCasClient.java ├── cas-exception-message-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ ├── DefaultCaptchaWebflowConfigurer.java │ │ │ ├── RememberMeUsernamePasswordCaptchaAuthenticationHandler.java │ │ │ └── RememberMeUsernamePasswordCaptchaCredential.java │ │ ├── config │ │ ├── CaptchaWebflowConfiguration.java │ │ ├── DataSourceConfig.java │ │ ├── RememberMeConfiguration.java │ │ └── SpringConfig.java │ │ ├── controller │ │ └── CaptchaController.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ ├── exception │ │ ├── CaptchaErrorException.java │ │ └── MyAccountNotFoundException.java │ │ ├── global │ │ └── utils │ │ │ └── CaptchaUtil.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── app1.properties │ ├── app2.properties │ ├── application.properties │ ├── log4j2.xml │ ├── messages_zh_CN.properties │ ├── services │ ├── APP1-1000.json │ └── APP2-1001.json │ ├── sql │ ├── sys_permission.sql │ ├── sys_role.sql │ ├── sys_role_permission.sql │ ├── sys_user_role.sql │ └── user_info.sql │ ├── static │ └── themes │ │ ├── app1 │ │ ├── css │ │ │ └── cas.css │ │ └── js │ │ │ └── jquery-1.4.2.min.js │ │ └── app2 │ │ ├── css │ │ └── cas.css │ │ └── js │ │ └── jquery-1.4.2.min.js │ └── templates │ ├── app1 │ └── casLoginView.html │ ├── app2 │ └── casLoginView.html │ └── casConfirmLogoutView.html ├── cas-ignore-client1 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── config │ │ └── SimpleUrlPatternMatcherStrategy.java │ │ ├── controller │ │ └── UserController.java │ │ ├── dao │ │ └── UserMapper.java │ │ └── service │ │ ├── UserService.java │ │ └── impl │ │ └── UserServiceImpl.java │ ├── resources │ ├── config │ │ └── application.properties │ ├── logback.xml │ ├── mapper │ │ └── UserMapper.xml │ └── spring │ │ ├── spring-mvc.xml │ │ ├── spring-mybatis.xml │ │ └── spring.xml │ └── webapp │ ├── WEB-INF │ ├── images │ │ └── meinv.jpg │ ├── jsp │ │ └── result.jsp │ └── web.xml │ ├── index.jsp │ └── logout.jsp ├── cas-ignore-client2 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── Application.java │ │ ├── config │ │ ├── DataSourceConfig.java │ │ ├── SimpleUrlPatternMatcherStrategy.java │ │ ├── SpringContext.java │ │ └── SpringMVC.java │ │ ├── controller │ │ ├── IndexController.java │ │ └── UserController.java │ │ ├── dao │ │ └── UserMapper.java │ │ └── service │ │ ├── UserService.java │ │ └── impl │ │ └── UserServiceImpl.java │ ├── resources │ ├── config │ │ ├── application.properties │ │ └── logback-spring.xml │ ├── mapper │ │ └── UserMapper.xml │ └── static │ │ └── images │ │ └── meinv.jpg │ └── webapp │ └── WEB-INF │ └── jsp │ ├── index.jsp │ └── result.jsp ├── cas-login-client1 ├── pom.xml └── src │ └── main │ ├── resources │ └── log4j.xml │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── index.jsp │ └── logout.jsp ├── cas-login-client2 ├── pom.xml └── src │ └── main │ ├── resources │ └── log4j.xml │ └── webapp │ ├── WEB-INF │ └── web.xml │ ├── index.jsp │ └── logout.jsp ├── cas-login-page-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ └── ShiroAuthenticationHandler.java │ │ ├── config │ │ ├── DataSourceConfig.java │ │ ├── ShiroAuthenticationConfiguration.java │ │ ├── ShiroRealm.java │ │ └── SpringConfig.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── app1.properties │ ├── app2.properties │ ├── application.properties │ ├── log4j2.xml │ ├── services │ ├── APP1-1000.json │ └── APP2-1001.json │ ├── sql │ ├── sys_permission.sql │ ├── sys_role.sql │ ├── sys_role_permission.sql │ ├── sys_user_role.sql │ └── user_info.sql │ ├── static │ └── themes │ │ ├── app1 │ │ ├── css │ │ │ └── cas.css │ │ └── js │ │ │ └── jquery-1.4.2.min.js │ │ └── app2 │ │ ├── css │ │ └── cas.css │ │ └── js │ │ └── jquery-1.4.2.min.js │ └── templates │ ├── app1 │ └── casLoginView.html │ └── app2 │ └── casLoginView.html ├── cas-login-remember-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ └── ShiroAuthenticationHandler.java │ │ ├── config │ │ ├── DataSourceConfig.java │ │ ├── ShiroAuthenticationConfiguration.java │ │ ├── ShiroRealm.java │ │ └── SpringConfig.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── app1.properties │ ├── app2.properties │ ├── application.properties │ ├── log4j2.xml │ ├── services │ ├── APP1-1000.json │ └── APP2-1001.json │ ├── sql │ ├── sys_permission.sql │ ├── sys_role.sql │ ├── sys_role_permission.sql │ ├── sys_user_role.sql │ └── user_info.sql │ ├── static │ └── themes │ │ ├── app1 │ │ ├── css │ │ │ └── cas.css │ │ └── js │ │ │ └── jquery-1.4.2.min.js │ │ └── app2 │ │ ├── css │ │ └── cas.css │ │ └── js │ │ └── jquery-1.4.2.min.js │ └── templates │ ├── app1 │ └── casLoginView.html │ ├── app2 │ └── casLoginView.html │ └── casConfirmLogoutView.html ├── cas-login-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ └── ShiroAuthenticationHandler.java │ │ ├── config │ │ ├── DataSourceConfig.java │ │ ├── ShiroAuthenticationConfiguration.java │ │ ├── ShiroRealm.java │ │ └── SpringConfig.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── application.properties │ ├── log4j2.xml │ ├── services │ └── HTTPSandIMAPS-10000001.json │ └── sql │ ├── sys_permission.sql │ ├── sys_role.sql │ ├── sys_role_permission.sql │ ├── sys_user_role.sql │ └── user_info.sql ├── cas-login-spring-client1 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── controller │ │ └── UserController.java │ │ ├── dao │ │ └── UserMapper.java │ │ └── service │ │ ├── UserService.java │ │ └── impl │ │ └── UserServiceImpl.java │ ├── resources │ ├── config │ │ └── application.properties │ ├── logback.xml │ ├── mapper │ │ └── UserMapper.xml │ └── spring │ │ ├── spring-mvc.xml │ │ ├── spring-mybatis.xml │ │ └── spring.xml │ └── webapp │ ├── WEB-INF │ ├── jsp │ │ └── result.jsp │ └── web.xml │ ├── index.jsp │ └── logout.jsp ├── cas-login-springboot-client2 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── Application.java │ │ ├── config │ │ ├── DataSourceConfig.java │ │ ├── SpringContext.java │ │ └── SpringMVC.java │ │ ├── controller │ │ ├── IndexController.java │ │ └── UserController.java │ │ ├── dao │ │ └── UserMapper.java │ │ └── service │ │ ├── UserService.java │ │ └── impl │ │ └── UserServiceImpl.java │ ├── resources │ ├── config │ │ ├── application.properties │ │ └── logback-spring.xml │ ├── lib │ │ ├── cas-client-autoconfig-support-1.4.0-GA-sources.jar │ │ └── cas-client-autoconfig-support-1.4.0-GA.jar │ └── mapper │ │ └── UserMapper.xml │ └── webapp │ └── WEB-INF │ └── jsp │ ├── index.jsp │ └── result.jsp ├── cas-logout-client1 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── controller │ │ └── UserController.java │ │ ├── dao │ │ └── UserMapper.java │ │ └── service │ │ ├── UserService.java │ │ └── impl │ │ └── UserServiceImpl.java │ ├── resources │ ├── config │ │ └── application.properties │ ├── logback.xml │ ├── mapper │ │ └── UserMapper.xml │ └── spring │ │ ├── spring-mvc.xml │ │ ├── spring-mybatis.xml │ │ └── spring.xml │ └── webapp │ ├── WEB-INF │ ├── jsp │ │ └── result.jsp │ └── web.xml │ ├── index.jsp │ └── logout.jsp ├── cas-logout-client2 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── Application.java │ │ ├── config │ │ ├── DataSourceConfig.java │ │ ├── SpringContext.java │ │ └── SpringMVC.java │ │ ├── controller │ │ ├── IndexController.java │ │ └── UserController.java │ │ ├── dao │ │ └── UserMapper.java │ │ └── service │ │ ├── UserService.java │ │ └── impl │ │ └── UserServiceImpl.java │ ├── resources │ ├── config │ │ ├── application.properties │ │ └── logback-spring.xml │ └── mapper │ │ └── UserMapper.xml │ └── webapp │ └── WEB-INF │ └── jsp │ ├── index.jsp │ └── result.jsp ├── cas-logout-confirm-page-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ └── ShiroAuthenticationHandler.java │ │ ├── config │ │ ├── DataSourceConfig.java │ │ ├── ShiroAuthenticationConfiguration.java │ │ ├── ShiroRealm.java │ │ └── SpringConfig.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── app1.properties │ ├── app2.properties │ ├── application.properties │ ├── log4j2.xml │ ├── services │ ├── APP1-1000.json │ └── APP2-1001.json │ ├── sql │ ├── sys_permission.sql │ ├── sys_role.sql │ ├── sys_role_permission.sql │ ├── sys_user_role.sql │ └── user_info.sql │ ├── static │ └── themes │ │ ├── app1 │ │ ├── css │ │ │ └── cas.css │ │ └── js │ │ │ └── jquery-1.4.2.min.js │ │ └── app2 │ │ ├── css │ │ └── cas.css │ │ └── js │ │ └── jquery-1.4.2.min.js │ └── templates │ ├── app1 │ └── casLoginView.html │ ├── app2 │ └── casLoginView.html │ └── casConfirmLogoutView.html ├── cas-management-overlay ├── pom.xml └── src │ └── main │ └── resources │ ├── application.properties │ ├── messages_zh_CN.properties │ └── user-details.properties ├── cas-oauth-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ ├── DefaultCaptchaWebflowConfigurer.java │ │ │ ├── RememberMeUsernamePasswordCaptchaAuthenticationHandler.java │ │ │ └── RememberMeUsernamePasswordCaptchaCredential.java │ │ ├── config │ │ ├── CaptchaWebflowConfiguration.java │ │ ├── DataSourceConfig.java │ │ ├── RememberMeConfiguration.java │ │ └── SpringConfig.java │ │ ├── controller │ │ └── CaptchaController.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ ├── exception │ │ ├── CaptchaErrorException.java │ │ └── MyAccountNotFoundException.java │ │ ├── global │ │ └── utils │ │ │ └── CaptchaUtil.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── app1.properties │ ├── app2.properties │ ├── application.properties │ ├── log4j2.xml │ ├── messages_zh_CN.properties │ ├── services │ ├── APP1-1000.json │ ├── APP2-1001.json │ └── OAUTH-1002.json │ ├── sql │ ├── sys_permission.sql │ ├── sys_role.sql │ ├── sys_role_permission.sql │ ├── sys_user_role.sql │ └── user_info.sql │ ├── static │ └── themes │ │ ├── app1 │ │ ├── css │ │ │ └── cas.css │ │ └── js │ │ │ └── jquery-1.4.2.min.js │ │ └── app2 │ │ ├── css │ │ └── cas.css │ │ └── js │ │ └── jquery-1.4.2.min.js │ └── templates │ ├── app1 │ └── casLoginView.html │ ├── app2 │ └── casLoginView.html │ └── casConfirmLogoutView.html ├── cas-redis-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ ├── DefaultCaptchaWebflowConfigurer.java │ │ │ ├── RememberMeUsernamePasswordCaptchaAuthenticationHandler.java │ │ │ └── RememberMeUsernamePasswordCaptchaCredential.java │ │ ├── config │ │ ├── CaptchaWebflowConfiguration.java │ │ ├── DataSourceConfig.java │ │ ├── RememberMeConfiguration.java │ │ └── SpringConfig.java │ │ ├── controller │ │ └── CaptchaController.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ ├── exception │ │ ├── CaptchaErrorException.java │ │ └── MyAccountNotFoundException.java │ │ ├── global │ │ └── utils │ │ │ └── CaptchaUtil.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── app1.properties │ ├── app2.properties │ ├── application.properties │ ├── log4j2.xml │ ├── messages_zh_CN.properties │ ├── services │ ├── APP1-1000.json │ └── APP2-1001.json │ ├── static │ └── themes │ │ ├── app1 │ │ ├── css │ │ │ └── cas.css │ │ └── js │ │ │ └── jquery-1.4.2.min.js │ │ └── app2 │ │ ├── css │ │ └── cas.css │ │ └── js │ │ └── jquery-1.4.2.min.js │ └── templates │ ├── app1 │ └── casLoginView.html │ ├── app2 │ └── casLoginView.html │ └── casConfirmLogoutView.html ├── cas-rest-demo ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── controller │ │ └── UserController.java │ │ ├── dao │ │ ├── UserMapper.java │ │ └── entity │ │ │ └── SysUser.java │ │ └── service │ │ ├── UserService.java │ │ └── impl │ │ └── UserServiceImpl.java │ ├── resources │ ├── config │ │ └── application.properties │ ├── logback.xml │ ├── mapper │ │ └── UserMapper.xml │ └── spring │ │ ├── spring-mvc.xml │ │ ├── spring-mybatis.xml │ │ └── spring.xml │ └── webapp │ ├── WEB-INF │ └── web.xml │ └── index.jsp ├── cas-rest-server ├── pom.xml └── src │ └── main │ └── resources │ ├── META-INF │ └── spring.factories │ ├── application.properties │ └── log4j2.xml ├── cas-return-server ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ ├── DefaultCaptchaWebflowConfigurer.java │ │ │ ├── RememberMeUsernamePasswordCaptchaAuthenticationHandler.java │ │ │ └── RememberMeUsernamePasswordCaptchaCredential.java │ │ ├── config │ │ ├── CaptchaWebflowConfiguration.java │ │ ├── DataSourceConfig.java │ │ ├── RememberMeConfiguration.java │ │ └── SpringConfig.java │ │ ├── controller │ │ └── CaptchaController.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ ├── exception │ │ ├── CaptchaErrorException.java │ │ └── MyAccountNotFoundException.java │ │ ├── global │ │ └── utils │ │ │ └── CaptchaUtil.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── app1.properties │ ├── app2.properties │ ├── application.properties │ ├── log4j2.xml │ ├── messages_zh_CN.properties │ ├── services │ ├── APP1-1000.json │ └── APP2-1001.json │ ├── sql │ ├── sys_permission.sql │ ├── sys_role.sql │ ├── sys_role_permission.sql │ ├── sys_user_role.sql │ └── user_info.sql │ ├── static │ └── themes │ │ ├── app1 │ │ ├── css │ │ │ └── cas.css │ │ └── js │ │ │ └── jquery-1.4.2.min.js │ │ └── app2 │ │ ├── css │ │ └── cas.css │ │ └── js │ │ └── jquery-1.4.2.min.js │ └── templates │ ├── app1 │ └── casLoginView.html │ ├── app2 │ └── casLoginView.html │ └── casConfirmLogoutView.html ├── cas-server-auto-regist-service ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ └── ShiroAuthenticationHandler.java │ │ ├── config │ │ ├── CasCoreAuditConfiguration.java │ │ ├── DataSourceConfig.java │ │ ├── ShiroAuthenticationConfiguration.java │ │ ├── ShiroRealm.java │ │ ├── SpringConfig.java │ │ └── SpringMVC.java │ │ ├── controller │ │ └── ServiceController.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ ├── resolver │ │ ├── DeleteServiceActionResolver.java │ │ └── DeleteServiceResourceResolver.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── application.properties │ ├── log4j2.xml │ ├── services │ └── HTTPSandIMAPS-10000001.json │ └── sql │ ├── sys_permission.sql │ ├── sys_role.sql │ ├── sys_role_permission.sql │ ├── sys_user_role.sql │ └── user_info.sql ├── cas-server-base ├── pom.xml └── src │ └── main │ └── resources │ ├── META-INF │ └── spring.factories │ ├── application.properties │ └── log4j2.xml ├── cas-server-core-audit ├── pom.xml └── src │ └── main │ ├── java │ └── org │ │ └── apereo │ │ └── cas │ │ └── audit │ │ └── spi │ │ └── config │ │ ├── CasCoreAuditConfiguration.java │ │ ├── DeleteServiceActionResolver.java │ │ └── DeleteServiceResourceResolver.java │ └── resources │ └── META-INF │ └── spring.factories ├── cas-server-custom-verifify ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── cas │ │ └── CustomPasswordEncoder.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── application.properties │ └── log4j2.xml ├── cas-server-custom-verifify2 ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ ├── cas │ │ └── CustomPasswordEncoder.java │ │ └── wangsaichao │ │ └── cas │ │ ├── config │ │ └── MyAuthenticationConfiguration.java │ │ └── custom │ │ └── MyAuthenticationHandler.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── application.properties │ └── log4j2.xml ├── cas-server-jdbc ├── pom.xml └── src │ └── main │ └── resources │ ├── META-INF │ └── spring.factories │ ├── application.properties │ └── log4j2.xml ├── cas-server-shiro ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── wangsaichao │ │ └── cas │ │ ├── adaptors │ │ └── generic │ │ │ └── ShiroAuthenticationHandler.java │ │ ├── config │ │ ├── DataSourceConfig.java │ │ ├── ShiroAuthenticationConfiguration.java │ │ ├── ShiroRealm.java │ │ └── SpringConfig.java │ │ ├── dao │ │ ├── RoleDao.java │ │ └── UserDao.java │ │ └── service │ │ ├── RoleService.java │ │ ├── UserService.java │ │ └── impl │ │ ├── RoleServiceImpl.java │ │ └── UserServiceImpl.java │ └── resources │ ├── META-INF │ └── spring.factories │ ├── application.properties │ ├── log4j2.xml │ └── sql │ ├── sys_permission.sql │ ├── sys_role.sql │ ├── sys_role_permission.sql │ ├── sys_user_role.sql │ └── user_info.sql ├── cas-server-shiro1 ├── pom.xml └── src │ └── main │ └── resources │ ├── META-INF │ └── spring.factories │ ├── application.properties │ ├── log4j2.xml │ └── shiro.ini └── cas-sslogout-server ├── pom.xml └── src └── main ├── java └── com │ └── wangsaichao │ └── cas │ ├── adaptors │ └── generic │ │ └── ShiroAuthenticationHandler.java │ ├── config │ ├── DataSourceConfig.java │ ├── ShiroAuthenticationConfiguration.java │ ├── ShiroRealm.java │ └── SpringConfig.java │ ├── dao │ ├── RoleDao.java │ └── UserDao.java │ └── service │ ├── RoleService.java │ ├── UserService.java │ └── impl │ ├── RoleServiceImpl.java │ └── UserServiceImpl.java └── resources ├── META-INF └── spring.factories ├── application.properties ├── log4j2.xml ├── services └── HTTPSandIMAPS-10000001.json └── sql ├── sys_permission.sql ├── sys_role.sql ├── sys_role_permission.sql ├── sys_user_role.sql └── user_info.sql /README.md: -------------------------------------------------------------------------------- 1 | # spring-boot-cas 2 | springboot整合cas系列 3 | 如果对您有帮助,请点击一下,右上角的★Star,谢谢! 4 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/java/com/wangsaichao/cas/adaptors/generic/RememberMeUsernamePasswordCaptchaCredential.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.adaptors.generic; 2 | 3 | import org.apache.commons.lang.builder.HashCodeBuilder; 4 | import org.apereo.cas.authentication.RememberMeUsernamePasswordCredential; 5 | 6 | import javax.validation.constraints.Size; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/31 11 | * @description: 验证码 Credential 12 | */ 13 | public class RememberMeUsernamePasswordCaptchaCredential extends RememberMeUsernamePasswordCredential { 14 | 15 | @Size(min = 5,max = 5, message = "require captcha") 16 | private String captcha; 17 | 18 | public String getCaptcha() { 19 | return captcha; 20 | } 21 | 22 | public void setCaptcha(String captcha) { 23 | this.captcha = captcha; 24 | } 25 | 26 | @Override 27 | public int hashCode() { 28 | return new HashCodeBuilder() 29 | .appendSuper(super.hashCode()) 30 | .append(this.captcha) 31 | .toHashCode(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/18 13 | * @description: 操作用户信息 14 | */ 15 | @Repository("userDao") 16 | public class UserDao { 17 | 18 | @Autowired 19 | private JdbcTemplate jdbcTemplate; 20 | 21 | /** 22 | * 通过用户名查询用户角色信息 23 | * @param userName 24 | * @return 25 | */ 26 | public Map findByUserName(String userName){ 27 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.RememberMeConfiguration,\ 3 | com.wangsaichao.cas.config.CaptchaWebflowConfiguration,\ 4 | com.wangsaichao.cas.config.DataSourceConfig -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/app1.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 2 | cas.standard.css.file=/css/cas.css 3 | #\u81EA\u5DF1\u7684\u6837\u5F0F 4 | cas.myself.css=/themes/app1/css/cas.css 5 | cas.javascript.file=/themes/app1/js/jquery-1.4.2.min.js 6 | cas.page.title=app1\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/app2.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 cas.standard.css.file=/css/cas.css #\u81EA\u5DF1\u7684\u6837\u5F0F cas.myself.css=/themes/app2/css/cas.css cas.javascript.file=/themes/app2/js/jquery-1.4.2.min.js cas.page.title=app2\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/services/APP1-1000.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app1.cas.com.*", 4 | "name" : "测试客户端app1", 5 | "id" : 1000, 6 | "description" : "这是app1的客户端", 7 | "evaluationOrder" : 10, 8 | "theme" : "app1" 9 | } -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/services/APP2-1001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app2.cas.com.*", 4 | "name" : "测试客户端app2", 5 | "id" : 1001, 6 | "description" : "这是app2的客户端", 7 | "evaluationOrder" : 11, 8 | "theme" : "app2" 9 | } -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/sql/user_info.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:37 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `user_info` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `user_info`; 24 | CREATE TABLE `user_info` ( 25 | `uid` int(11) NOT NULL AUTO_INCREMENT, 26 | `username` varchar(50) DEFAULT '' COMMENT '用户名', 27 | `password` varchar(256) DEFAULT NULL COMMENT '登录密码', 28 | `name` varchar(256) DEFAULT NULL COMMENT '用户真实姓名', 29 | `id_card_num` varchar(256) DEFAULT NULL COMMENT '用户身份证号', 30 | `state` char(1) DEFAULT '0' COMMENT '用户状态:0:正常状态,1:用户被锁定', 31 | PRIMARY KEY (`uid`), 32 | UNIQUE KEY `username` (`username`) USING BTREE, 33 | UNIQUE KEY `id_card_num` (`id_card_num`) USING BTREE 34 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 35 | 36 | -- ---------------------------- 37 | -- Records of `user_info` 38 | -- ---------------------------- 39 | BEGIN; 40 | INSERT INTO `user_info` VALUES ('1', 'admin', 'e10adc3949ba59abbe56e057f20f883e', '超哥', '133333333333333333', '0'), ('2', 'test', 'ed0290f05224a188160858124a5f5077', '孙悟空', '155555555555555555', '1'), ('3', 'wangsaichao', '123456', '王赛超', '177777777777777777', '0'); 41 | COMMIT; 42 | 43 | SET FOREIGN_KEY_CHECKS = 1; 44 | -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/static/themes/app1/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: red; } -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/static/themes/app2/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: pink; } -------------------------------------------------------------------------------- /cas-capcha-server/src/main/resources/templates/casConfirmLogoutView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Confirm Logout View 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |

Do you want to log out completely?

17 |

18 | 确认退出将结束你的会话,跳转到登录页面。 19 |

20 |


你确认退出吗?

21 | 22 |
23 |
24 | 25 | 26 | 27 | 33 |
34 |
35 |
36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /cas-client-spring-boot-starter/src/main/java/priv/wangsaichao/cas/client/configuration/EnableCasClient.java: -------------------------------------------------------------------------------- 1 | package priv.wangsaichao.cas.client.configuration; 2 | 3 | import org.springframework.context.annotation.Import; 4 | 5 | import java.lang.annotation.*; 6 | 7 | /** 8 | * @author: WangSaiChao 9 | * @date: 2018/8/6 10 | * @description: 配置该注解开启cas功能 11 | */ 12 | @Target(ElementType.TYPE) 13 | @Retention(RetentionPolicy.RUNTIME) 14 | @Documented 15 | @Inherited 16 | @Import(CasClientConfiguration.class) 17 | public @interface EnableCasClient { 18 | 19 | } 20 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/java/com/wangsaichao/cas/adaptors/generic/RememberMeUsernamePasswordCaptchaCredential.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.adaptors.generic; 2 | 3 | import org.apache.commons.lang.builder.HashCodeBuilder; 4 | import org.apereo.cas.authentication.RememberMeUsernamePasswordCredential; 5 | 6 | import javax.validation.constraints.Size; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/31 11 | * @description: 验证码 Credential 12 | */ 13 | public class RememberMeUsernamePasswordCaptchaCredential extends RememberMeUsernamePasswordCredential { 14 | 15 | @Size(min = 5,max = 5, message = "require captcha") 16 | private String captcha; 17 | 18 | public String getCaptcha() { 19 | return captcha; 20 | } 21 | 22 | public void setCaptcha(String captcha) { 23 | this.captcha = captcha; 24 | } 25 | 26 | @Override 27 | public int hashCode() { 28 | return new HashCodeBuilder() 29 | .appendSuper(super.hashCode()) 30 | .append(this.captcha) 31 | .toHashCode(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.dao.DataAccessException; 6 | import org.springframework.dao.EmptyResultDataAccessException; 7 | import org.springframework.jdbc.core.JdbcTemplate; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * @author: wangsaichao 14 | * @date: 2018/7/18 15 | * @description: 操作用户信息 16 | */ 17 | @Repository("userDao") 18 | public class UserDao { 19 | 20 | @Autowired 21 | private JdbcTemplate jdbcTemplate; 22 | 23 | /** 24 | * 通过用户名查询用户角色信息 25 | * @param userName 26 | * @return 27 | */ 28 | public Map findByUserName(String userName){ 29 | try { 30 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 31 | } catch (EmptyResultDataAccessException e) { 32 | return null; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/java/com/wangsaichao/cas/exception/CaptchaErrorException.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.exception; 2 | 3 | import javax.security.auth.login.AccountException; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/8/31 8 | * @description: 验证码错误异常类 9 | */ 10 | public class CaptchaErrorException extends AccountException { 11 | 12 | public CaptchaErrorException() { 13 | super(); 14 | } 15 | 16 | public CaptchaErrorException(String msg) { 17 | super(msg); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/java/com/wangsaichao/cas/exception/MyAccountNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.exception; 2 | 3 | import javax.security.auth.login.AccountException; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/8/31 8 | * @description: 用户没找到异常 9 | */ 10 | public class MyAccountNotFoundException extends AccountException { 11 | public MyAccountNotFoundException() { 12 | super(); 13 | } 14 | 15 | public MyAccountNotFoundException(String msg) { 16 | super(msg); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.RememberMeConfiguration,\ 3 | com.wangsaichao.cas.config.CaptchaWebflowConfiguration,\ 4 | com.wangsaichao.cas.config.DataSourceConfig -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/app1.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 2 | cas.standard.css.file=/css/cas.css 3 | #\u81EA\u5DF1\u7684\u6837\u5F0F 4 | cas.myself.css=/themes/app1/css/cas.css 5 | cas.javascript.file=/themes/app1/js/jquery-1.4.2.min.js 6 | cas.page.title=app1\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/app2.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 cas.standard.css.file=/css/cas.css #\u81EA\u5DF1\u7684\u6837\u5F0F cas.myself.css=/themes/app2/css/cas.css cas.javascript.file=/themes/app2/js/jquery-1.4.2.min.js cas.page.title=app2\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/services/APP1-1000.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app1.cas.com.*", 4 | "name" : "测试客户端app1", 5 | "id" : 1000, 6 | "description" : "这是app1的客户端", 7 | "evaluationOrder" : 10, 8 | "theme" : "app1" 9 | } -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/services/APP2-1001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app2.cas.com.*", 4 | "name" : "测试客户端app2", 5 | "id" : 1001, 6 | "description" : "这是app2的客户端", 7 | "evaluationOrder" : 11, 8 | "theme" : "app2" 9 | } -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/static/themes/app1/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: red; } -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/static/themes/app2/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: pink; } -------------------------------------------------------------------------------- /cas-exception-message-server/src/main/resources/templates/casConfirmLogoutView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Confirm Logout View 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |

Do you want to log out completely?

17 |

18 | 确认退出将结束你的会话,跳转到登录页面。 19 |

20 |


你确认退出吗?

21 | 22 |
23 |
24 | 25 | 26 | 27 | 33 |
34 |
35 |
36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /cas-ignore-client1/src/main/java/com/wangsaichao/cas/config/SimpleUrlPatternMatcherStrategy.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.jasig.cas.client.authentication.UrlPatternMatcherStrategy; 4 | 5 | import java.util.regex.Pattern; 6 | 7 | /** 8 | * @author: wangsaichao 9 | * @date: 2018/8/7 10 | * @description: 自定义鉴权路径 11 | */ 12 | public class SimpleUrlPatternMatcherStrategy implements UrlPatternMatcherStrategy { 13 | 14 | private Pattern pattern; 15 | 16 | @Override 17 | public boolean matches(String url) { 18 | 19 | //在此可以做额外的扩展,比如判断是insert也放行 可以通过查询数据库来进行动态判断 20 | if(url.contains("/insert")){ 21 | return true; 22 | } 23 | 24 | //默认是根据cas.ignore-pattern来判断是否否满足过滤 25 | return this.pattern.matcher(url).find(); 26 | } 27 | 28 | /** 29 | * 这个pattern就是 在application.properties中配置的cas.ignore-pattern 30 | * @param pattern 31 | */ 32 | @Override 33 | public void setPattern(String pattern) { 34 | this.pattern = Pattern.compile(pattern); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /cas-ignore-client1/src/main/java/com/wangsaichao/cas/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | 5 | /** 6 | * @author: WangSaiChao 7 | * @date: 2018/8/1 8 | * @description: 用户操作 dao层 9 | */ 10 | public interface UserMapper { 11 | 12 | /** 13 | * 创建用户 14 | * @param username 15 | * @param password 16 | * @return 17 | */ 18 | void insert(@Param("username") String username, @Param("password") String password); 19 | } 20 | -------------------------------------------------------------------------------- /cas-ignore-client1/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | /** 4 | * @author: WangSaiChao 5 | * @date: 2018/8/1 6 | * @description: 用户操作service层 7 | */ 8 | public interface UserService { 9 | 10 | /** 11 | * 创建用户 12 | * @param username 13 | * @return 14 | */ 15 | void insert(String username); 16 | } 17 | -------------------------------------------------------------------------------- /cas-ignore-client1/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserMapper; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/1 11 | * @description: 12 | */ 13 | @Service 14 | public class UserServiceImpl implements UserService{ 15 | 16 | @Autowired 17 | private UserMapper userMapper; 18 | 19 | @Override 20 | public void insert(String username) { 21 | userMapper.insert(username,"123456"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cas-ignore-client1/src/main/resources/config/application.properties: -------------------------------------------------------------------------------- 1 | jdbc.driver=com.mysql.jdbc.Driver 2 | jdbc.url=jdbc:mysql://127.0.0.1:3306/testshiro?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false 3 | jdbc.username=root 4 | jdbc.password=123456 -------------------------------------------------------------------------------- /cas-ignore-client1/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | insert into user_info 8 | 9 | 10 | username, 11 | 12 | 13 | password, 14 | 15 | 16 | 17 | 18 | #{username}, 19 | 20 | 21 | #{password}, 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /cas-ignore-client1/src/main/resources/spring/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /cas-ignore-client1/src/main/webapp/WEB-INF/images/meinv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Negan1994/spring-boot-cas/ba8906c71b687998cff49bb3cf9eef59eed44e7b/cas-ignore-client1/src/main/webapp/WEB-INF/images/meinv.jpg -------------------------------------------------------------------------------- /cas-ignore-client1/src/main/webapp/WEB-INF/jsp/result.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | 4 | 6 | 7 | 8 | 9 | 10 | CAS Example Java Web App 11 | 12 | 13 | 14 |

添加用户成功

15 | 16 | 17 | -------------------------------------------------------------------------------- /cas-ignore-client1/src/main/webapp/logout.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | <%@ page import="java.util.Map" %> 4 | <%@ page import="java.util.Iterator" %> 5 | <%@ page import="org.jasig.cas.client.authentication.AttributePrincipal" %> 6 | 7 | 9 | 10 | <% 11 | session.invalidate(); 12 | %> 13 | 14 | 15 | 16 | 17 | CAS Example Java Web App 18 | 19 | 20 |

CAS Example Java Web App

21 |

Application session is now invalidated. You may also issue a request to "/cas/logout" to destroy the CAS SSO Session as well.

22 |
23 | 24 | Back to Home 25 | 26 | 27 | -------------------------------------------------------------------------------- /cas-ignore-client2/src/main/java/com/wangsaichao/cas/config/SimpleUrlPatternMatcherStrategy.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.jasig.cas.client.authentication.UrlPatternMatcherStrategy; 4 | 5 | import java.util.regex.Pattern; 6 | 7 | /** 8 | * @author: wangsaichao 9 | * @date: 2018/8/7 10 | * @description: 自定义鉴权路径 11 | */ 12 | public class SimpleUrlPatternMatcherStrategy implements UrlPatternMatcherStrategy { 13 | 14 | private Pattern pattern; 15 | 16 | @Override 17 | public boolean matches(String url) { 18 | 19 | //在此可以做额外的扩展,比如判断是insert也放行 可以通过查询数据库来进行动态判断 20 | if(url.contains("/insert")){ 21 | return true; 22 | } 23 | 24 | //默认是根据cas.ignore-pattern来判断是否否满足过滤 25 | return this.pattern.matcher(url).find(); 26 | } 27 | 28 | /** 29 | * 这个pattern就是 在application.properties中配置的cas.ignore-pattern 30 | * @param pattern 31 | */ 32 | @Override 33 | public void setPattern(String pattern) { 34 | this.pattern = Pattern.compile(pattern); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /cas-ignore-client2/src/main/java/com/wangsaichao/cas/config/SpringContext.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class SpringContext implements ApplicationContextAware{ 10 | 11 | private static ApplicationContext applicationContext; 12 | 13 | @Override 14 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 15 | if(SpringContext.applicationContext == null) { 16 | SpringContext.applicationContext = applicationContext; 17 | } 18 | } 19 | 20 | //获取applicationContext 21 | public static ApplicationContext getApplicationContext() { 22 | return applicationContext; 23 | } 24 | 25 | //通过name获取 Bean. 26 | public static Object getBean(String name){ 27 | return getApplicationContext().getBean(name); 28 | } 29 | 30 | //通过class获取Bean. 31 | public static T getBean(Class clazz){ 32 | return getApplicationContext().getBean(clazz); 33 | } 34 | 35 | //通过name,以及Clazz返回指定的Bean 36 | public static T getBean(String name,Class clazz){ 37 | return getApplicationContext().getBean(name, clazz); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /cas-ignore-client2/src/main/java/com/wangsaichao/cas/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.controller; 2 | 3 | import com.wangsaichao.cas.service.UserService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | import javax.servlet.http.HttpSession; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/8/1 13 | * @description: 用户相关操作controller 14 | */ 15 | @Controller 16 | public class UserController { 17 | 18 | @Autowired 19 | private UserService userService; 20 | 21 | @RequestMapping("insert") 22 | public String insert(String username){ 23 | 24 | userService.insert(username); 25 | return "result"; 26 | } 27 | 28 | 29 | /** 30 | * 跳转到默认页面 31 | * @param session 32 | * @return 33 | */ 34 | @RequestMapping("/logout1") 35 | public String loginOut(HttpSession session){ 36 | //session.invalidate(); 37 | //这个是直接退出,走的是默认退出方式 38 | return "redirect:https://server.cas.com:8443/cas/logout"; 39 | } 40 | 41 | /** 42 | * 跳转到指定页面 43 | * @param session 44 | * @return 45 | */ 46 | @RequestMapping("/logout2") 47 | public String loginOut2(HttpSession session){ 48 | //session.invalidate(); 49 | //退出登录后,跳转到退成成功的页面,不走默认页面 50 | return "redirect:https://server.cas.com:8443/cas/logout?service=http://app2.cas.com:8082"; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /cas-ignore-client2/src/main/java/com/wangsaichao/cas/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.apache.ibatis.annotations.Mapper; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | /** 7 | * @author: WangSaiChao 8 | * @date: 2018/8/1 9 | * @description: 用户操作 dao层 10 | */ 11 | @Mapper 12 | public interface UserMapper { 13 | 14 | /** 15 | * 创建用户 16 | * @param username 17 | * @param password 18 | * @return 19 | */ 20 | void insert(@Param("username") String username, @Param("password") String password); 21 | } 22 | -------------------------------------------------------------------------------- /cas-ignore-client2/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | /** 4 | * @author: WangSaiChao 5 | * @date: 2018/8/1 6 | * @description: 用户操作service层 7 | */ 8 | public interface UserService { 9 | 10 | /** 11 | * 创建用户 12 | * @param username 13 | * @return 14 | */ 15 | void insert(String username); 16 | } 17 | -------------------------------------------------------------------------------- /cas-ignore-client2/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserMapper; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/1 11 | * @description: 12 | */ 13 | @Service 14 | public class UserServiceImpl implements UserService{ 15 | 16 | @Autowired 17 | private UserMapper userMapper; 18 | 19 | @Override 20 | public void insert(String username) { 21 | userMapper.insert(username,"123456"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cas-ignore-client2/src/main/resources/config/application.properties: -------------------------------------------------------------------------------- 1 | #配置tomcat 2 | server.port=8082 3 | server.servlet.context-path=/ 4 | #日志文件的路径 5 | logging.config=classpath:config/logback-spring.xml 6 | mybatis.mapper-locations=classpath:mapper/*.xml 7 | 8 | #配置jdbc数据源 9 | jdbc.ds.driverClassName=com.mysql.jdbc.Driver 10 | jdbc.ds.url=jdbc:mysql://127.0.0.1:3306/testshiro?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false 11 | jdbc.ds.username=root 12 | jdbc.ds.password=123456 13 | #配置最大连接数 14 | jdbc.ds.maxActive=30 15 | #配置初始化连接数 16 | jdbc.ds.initialSize=20 17 | #配置最小连接数 18 | jdbc.ds.minIdle=20 19 | 20 | #jsp 支持 21 | spring.mvc.view.suffix=.jsp 22 | spring.mvc.view.prefix=/WEB-INF/jsp/ 23 | 24 | #关闭默认模板引擎 25 | spring.thymeleaf.cache=false 26 | spring.thymeleaf.enabled=false 27 | 28 | #cas配置 29 | cas.server-url-prefix=https://server.cas.com:8443/cas 30 | cas.server-login-url=https://server.cas.com:8443/cas/login 31 | cas.client-host-url=http://app2.cas.com:8082 32 | cas.ignore-pattern=/js/*|/images/*|/view/*|/css/* 33 | cas.ignore-url-pattern-type=com.wangsaichao.cas.config.SimpleUrlPatternMatcherStrategy -------------------------------------------------------------------------------- /cas-ignore-client2/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | insert into user_info 8 | 9 | 10 | username, 11 | 12 | 13 | password, 14 | 15 | 16 | 17 | 18 | #{username}, 19 | 20 | 21 | #{password}, 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /cas-ignore-client2/src/main/resources/static/images/meinv.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Negan1994/spring-boot-cas/ba8906c71b687998cff49bb3cf9eef59eed44e7b/cas-ignore-client2/src/main/resources/static/images/meinv.jpg -------------------------------------------------------------------------------- /cas-ignore-client2/src/main/webapp/WEB-INF/jsp/result.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | 4 | 6 | 7 | 8 | 9 | 10 | CAS Example Java Web App 11 | 12 | 13 | 14 |

添加用户成功

15 | 16 | 17 | -------------------------------------------------------------------------------- /cas-login-client1/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /cas-login-client1/src/main/webapp/logout.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | <%@ page import="java.util.Map" %> 4 | <%@ page import="java.util.Iterator" %> 5 | <%@ page import="org.jasig.cas.client.authentication.AttributePrincipal" %> 6 | 7 | 9 | 10 | <% 11 | session.invalidate(); 12 | %> 13 | 14 | 15 | 16 | 17 | CAS Example Java Web App 18 | 19 | 20 |

CAS Example Java Web App

21 |

Application session is now invalidated. You may also issue a request to "/cas/logout" to destroy the CAS SSO Session as well.

22 |
23 | 24 | Back to Home 25 | 26 | 27 | -------------------------------------------------------------------------------- /cas-login-client2/src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /cas-login-client2/src/main/webapp/logout.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | <%@ page import="java.util.Map" %> 4 | <%@ page import="java.util.Iterator" %> 5 | <%@ page import="org.jasig.cas.client.authentication.AttributePrincipal" %> 6 | 7 | 9 | 10 | <% 11 | session.invalidate(); 12 | %> 13 | 14 | 15 | 16 | 17 | CAS Example Java Web App 18 | 19 | 20 |

CAS Example Java Web App

21 |

Application session is now invalidated. You may also issue a request to "/cas/logout" to destroy the CAS SSO Session as well.

22 |
23 | 24 | Back to Home 25 | 26 | 27 | -------------------------------------------------------------------------------- /cas-login-page-server/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-login-page-server/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/18 13 | * @description: 操作用户信息 14 | */ 15 | @Repository("userDao") 16 | public class UserDao { 17 | 18 | @Autowired 19 | private JdbcTemplate jdbcTemplate; 20 | 21 | /** 22 | * 通过用户名查询用户角色信息 23 | * @param userName 24 | * @return 25 | */ 26 | public Map findByUserName(String userName){ 27 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cas-login-page-server/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-login-page-server/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-login-page-server/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-login-page-server/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-login-page-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.DataSourceConfig,\ 3 | com.wangsaichao.cas.config.ShiroAuthenticationConfiguration -------------------------------------------------------------------------------- /cas-login-page-server/src/main/resources/app1.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 2 | cas.standard.css.file=/css/cas.css 3 | #\u81EA\u5DF1\u7684\u6837\u5F0F 4 | cas.myself.css=/themes/app1/css/cas.css 5 | cas.javascript.file=/themes/app1/js/jquery-1.4.2.min.js 6 | cas.page.title=app1\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-login-page-server/src/main/resources/app2.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 cas.standard.css.file=/css/cas.css #\u81EA\u5DF1\u7684\u6837\u5F0F cas.myself.css=/themes/app2/css/cas.css cas.javascript.file=/themes/app2/js/jquery-1.4.2.min.js cas.page.title=app2\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-login-page-server/src/main/resources/services/APP1-1000.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app1.cas.com.*", 4 | "name" : "测试客户端app1", 5 | "id" : 1000, 6 | "description" : "这是app1的客户端", 7 | "evaluationOrder" : 10, 8 | "theme" : "app1" 9 | } -------------------------------------------------------------------------------- /cas-login-page-server/src/main/resources/services/APP2-1001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app2.cas.com.*", 4 | "name" : "测试客户端app2", 5 | "id" : 1001, 6 | "description" : "这是app2的客户端", 7 | "evaluationOrder" : 11, 8 | "theme" : "app2" 9 | } -------------------------------------------------------------------------------- /cas-login-page-server/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-login-page-server/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-login-page-server/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-login-page-server/src/main/resources/static/themes/app1/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: red; } -------------------------------------------------------------------------------- /cas-login-page-server/src/main/resources/static/themes/app2/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: pink; } -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/18 13 | * @description: 操作用户信息 14 | */ 15 | @Repository("userDao") 16 | public class UserDao { 17 | 18 | @Autowired 19 | private JdbcTemplate jdbcTemplate; 20 | 21 | /** 22 | * 通过用户名查询用户角色信息 23 | * @param userName 24 | * @return 25 | */ 26 | public Map findByUserName(String userName){ 27 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.DataSourceConfig,\ 3 | com.wangsaichao.cas.config.ShiroAuthenticationConfiguration -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/app1.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 2 | cas.standard.css.file=/css/cas.css 3 | #\u81EA\u5DF1\u7684\u6837\u5F0F 4 | cas.myself.css=/themes/app1/css/cas.css 5 | cas.javascript.file=/themes/app1/js/jquery-1.4.2.min.js 6 | cas.page.title=app1\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/app2.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 cas.standard.css.file=/css/cas.css #\u81EA\u5DF1\u7684\u6837\u5F0F cas.myself.css=/themes/app2/css/cas.css cas.javascript.file=/themes/app2/js/jquery-1.4.2.min.js cas.page.title=app2\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/services/APP1-1000.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app1.cas.com.*", 4 | "name" : "测试客户端app1", 5 | "id" : 1000, 6 | "description" : "这是app1的客户端", 7 | "evaluationOrder" : 10, 8 | "theme" : "app1" 9 | } -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/services/APP2-1001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app2.cas.com.*", 4 | "name" : "测试客户端app2", 5 | "id" : 1001, 6 | "description" : "这是app2的客户端", 7 | "evaluationOrder" : 11, 8 | "theme" : "app2" 9 | } -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/static/themes/app1/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: red; } -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/static/themes/app2/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: pink; } -------------------------------------------------------------------------------- /cas-login-remember-server/src/main/resources/templates/casConfirmLogoutView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Confirm Logout View 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |

Do you want to log out completely?

17 |

18 | 确认退出将结束你的会话,跳转到登录页面。 19 |

20 |


你确认退出吗?

21 | 22 |
23 |
24 | 25 | 26 | 27 | 33 |
34 |
35 |
36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /cas-login-server/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-login-server/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/18 13 | * @description: 操作用户信息 14 | */ 15 | @Repository("userDao") 16 | public class UserDao { 17 | 18 | @Autowired 19 | private JdbcTemplate jdbcTemplate; 20 | 21 | /** 22 | * 通过用户名查询用户角色信息 23 | * @param userName 24 | * @return 25 | */ 26 | public Map findByUserName(String userName){ 27 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cas-login-server/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-login-server/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-login-server/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-login-server/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-login-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.DataSourceConfig,\ 3 | com.wangsaichao.cas.config.ShiroAuthenticationConfiguration -------------------------------------------------------------------------------- /cas-login-server/src/main/resources/services/HTTPSandIMAPS-10000001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://.*", 4 | "name" : "测试客户端", 5 | "id" : 10000001, 6 | "description" : "这是一个测试客户端的服务,所有的https访问都允许通过", 7 | "evaluationOrder" : 10000 8 | } 9 | -------------------------------------------------------------------------------- /cas-login-server/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-login-server/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-login-server/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-login-server/src/main/resources/sql/user_info.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:37 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `user_info` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `user_info`; 24 | CREATE TABLE `user_info` ( 25 | `uid` int(11) NOT NULL AUTO_INCREMENT, 26 | `username` varchar(50) DEFAULT '' COMMENT '用户名', 27 | `password` varchar(256) DEFAULT NULL COMMENT '登录密码', 28 | `name` varchar(256) DEFAULT NULL COMMENT '用户真实姓名', 29 | `id_card_num` varchar(256) DEFAULT NULL COMMENT '用户身份证号', 30 | `state` char(1) DEFAULT '0' COMMENT '用户状态:0:正常状态,1:用户被锁定', 31 | PRIMARY KEY (`uid`), 32 | UNIQUE KEY `username` (`username`) USING BTREE, 33 | UNIQUE KEY `id_card_num` (`id_card_num`) USING BTREE 34 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 35 | 36 | -- ---------------------------- 37 | -- Records of `user_info` 38 | -- ---------------------------- 39 | BEGIN; 40 | INSERT INTO `user_info` VALUES ('1', 'admin', 'e10adc3949ba59abbe56e057f20f883e', '超哥', '133333333333333333', '0'), ('2', 'test', 'ed0290f05224a188160858124a5f5077', '孙悟空', '155555555555555555', '1'), ('3', 'wangsaichao', '123456', '王赛超', '177777777777777777', '0'); 41 | COMMIT; 42 | 43 | SET FOREIGN_KEY_CHECKS = 1; 44 | -------------------------------------------------------------------------------- /cas-login-spring-client1/src/main/java/com/wangsaichao/cas/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.controller; 2 | 3 | import com.wangsaichao.cas.service.UserService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.ResponseBody; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/8/1 13 | * @description: 用户相关操作controller 14 | */ 15 | @Controller 16 | public class UserController { 17 | 18 | @Autowired 19 | private UserService userService; 20 | 21 | @RequestMapping("insert") 22 | public String insert(String username){ 23 | 24 | userService.insert(username); 25 | return "result"; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /cas-login-spring-client1/src/main/java/com/wangsaichao/cas/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | 5 | /** 6 | * @author: WangSaiChao 7 | * @date: 2018/8/1 8 | * @description: 用户操作 dao层 9 | */ 10 | public interface UserMapper { 11 | 12 | /** 13 | * 创建用户 14 | * @param username 15 | * @param password 16 | * @return 17 | */ 18 | void insert(@Param("username") String username, @Param("password") String password); 19 | } 20 | -------------------------------------------------------------------------------- /cas-login-spring-client1/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | /** 4 | * @author: WangSaiChao 5 | * @date: 2018/8/1 6 | * @description: 用户操作service层 7 | */ 8 | public interface UserService { 9 | 10 | /** 11 | * 创建用户 12 | * @param username 13 | * @return 14 | */ 15 | void insert(String username); 16 | } 17 | -------------------------------------------------------------------------------- /cas-login-spring-client1/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserMapper; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/1 11 | * @description: 12 | */ 13 | @Service 14 | public class UserServiceImpl implements UserService{ 15 | 16 | @Autowired 17 | private UserMapper userMapper; 18 | 19 | @Override 20 | public void insert(String username) { 21 | userMapper.insert(username,"123456"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cas-login-spring-client1/src/main/resources/config/application.properties: -------------------------------------------------------------------------------- 1 | jdbc.driver=com.mysql.jdbc.Driver 2 | jdbc.url=jdbc:mysql://127.0.0.1:3306/testshiro?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false 3 | jdbc.username=root 4 | jdbc.password=123456 -------------------------------------------------------------------------------- /cas-login-spring-client1/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | insert into user_info 8 | 9 | 10 | username, 11 | 12 | 13 | password, 14 | 15 | 16 | 17 | 18 | #{username}, 19 | 20 | 21 | #{password}, 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /cas-login-spring-client1/src/main/resources/spring/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /cas-login-spring-client1/src/main/webapp/WEB-INF/jsp/result.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | 4 | 6 | 7 | 8 | 9 | 10 | CAS Example Java Web App 11 | 12 | 13 | 14 |

添加用户成功

15 | 16 | 17 | -------------------------------------------------------------------------------- /cas-login-spring-client1/src/main/webapp/logout.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | <%@ page import="java.util.Map" %> 4 | <%@ page import="java.util.Iterator" %> 5 | <%@ page import="org.jasig.cas.client.authentication.AttributePrincipal" %> 6 | 7 | 9 | 10 | <% 11 | session.invalidate(); 12 | %> 13 | 14 | 15 | 16 | 17 | CAS Example Java Web App 18 | 19 | 20 |

CAS Example Java Web App

21 |

Application session is now invalidated. You may also issue a request to "/cas/logout" to destroy the CAS SSO Session as well.

22 |
23 | 24 | Back to Home 25 | 26 | 27 | -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/java/com/wangsaichao/cas/Application.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas; 2 | 3 | import net.unicon.cas.client.configuration.EnableCasClient; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.context.annotation.EnableAspectJAutoProxy; 7 | import org.springframework.context.annotation.ImportResource; 8 | import org.springframework.context.annotation.PropertySource; 9 | 10 | /** 11 | * @author: WangSaiChao 12 | * @date: 2018/8/2 13 | * @description: 启动类 14 | */ 15 | @SpringBootApplication 16 | //@PropertySource(value={"classpath:config/path.properties"},ignoreResourceNotFound=true,encoding="utf-8") 17 | //@ImportResource("classpath:spring/*.xml") 18 | //@EnableAspectJAutoProxy(proxyTargetClass = true,exposeProxy = true) 19 | @EnableCasClient//开启cas 20 | public class Application { 21 | 22 | public static void main(String[] args) { 23 | SpringApplication.run(Application.class, args); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/java/com/wangsaichao/cas/config/SpringContext.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class SpringContext implements ApplicationContextAware{ 10 | 11 | private static ApplicationContext applicationContext; 12 | 13 | @Override 14 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 15 | if(SpringContext.applicationContext == null) { 16 | SpringContext.applicationContext = applicationContext; 17 | } 18 | } 19 | 20 | //获取applicationContext 21 | public static ApplicationContext getApplicationContext() { 22 | return applicationContext; 23 | } 24 | 25 | //通过name获取 Bean. 26 | public static Object getBean(String name){ 27 | return getApplicationContext().getBean(name); 28 | } 29 | 30 | //通过class获取Bean. 31 | public static T getBean(Class clazz){ 32 | return getApplicationContext().getBean(clazz); 33 | } 34 | 35 | //通过name,以及Clazz返回指定的Bean 36 | public static T getBean(String name,Class clazz){ 37 | return getApplicationContext().getBean(name, clazz); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/java/com/wangsaichao/cas/config/SpringMVC.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.http.converter.HttpMessageConverter; 6 | import org.springframework.http.converter.StringHttpMessageConverter; 7 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 8 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 9 | 10 | import java.nio.charset.Charset; 11 | import java.util.List; 12 | 13 | /** 14 | * 等价于之前的SpringMVC.xml 15 | * 可以在此配置拦截器,过滤器,监听器 16 | * 配置静态文件映射 17 | * @author xiyan 18 | * 19 | */ 20 | @Configuration 21 | public class SpringMVC implements WebMvcConfigurer { 22 | 23 | @Bean 24 | public HttpMessageConverter responseBodyConverter() { 25 | StringHttpMessageConverter converter = new StringHttpMessageConverter(Charset.forName("UTF-8")); 26 | return converter; 27 | } 28 | 29 | @Override 30 | public void configureMessageConverters(List> converters) { 31 | converters.add(responseBodyConverter()); 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/java/com/wangsaichao/cas/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.controller; 2 | 3 | import com.wangsaichao.cas.service.UserService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/1 11 | * @description: 用户相关操作controller 12 | */ 13 | @Controller 14 | public class UserController { 15 | 16 | @Autowired 17 | private UserService userService; 18 | 19 | @RequestMapping("insert") 20 | public String insert(String username){ 21 | 22 | userService.insert(username); 23 | return "result"; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/java/com/wangsaichao/cas/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.apache.ibatis.annotations.Mapper; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | /** 7 | * @author: WangSaiChao 8 | * @date: 2018/8/1 9 | * @description: 用户操作 dao层 10 | */ 11 | @Mapper 12 | public interface UserMapper { 13 | 14 | /** 15 | * 创建用户 16 | * @param username 17 | * @param password 18 | * @return 19 | */ 20 | void insert(@Param("username") String username, @Param("password") String password); 21 | } 22 | -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | /** 4 | * @author: WangSaiChao 5 | * @date: 2018/8/1 6 | * @description: 用户操作service层 7 | */ 8 | public interface UserService { 9 | 10 | /** 11 | * 创建用户 12 | * @param username 13 | * @return 14 | */ 15 | void insert(String username); 16 | } 17 | -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserMapper; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/1 11 | * @description: 12 | */ 13 | @Service 14 | public class UserServiceImpl implements UserService{ 15 | 16 | @Autowired 17 | private UserMapper userMapper; 18 | 19 | @Override 20 | public void insert(String username) { 21 | userMapper.insert(username,"123456"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/resources/config/application.properties: -------------------------------------------------------------------------------- 1 | #配置tomcat 2 | server.port=8082 3 | server.servlet.context-path=/ 4 | #日志文件的路径 5 | logging.config=classpath:config/logback-spring.xml 6 | mybatis.mapper-locations=classpath:mapper/*.xml 7 | 8 | #配置jdbc数据源 9 | jdbc.ds.driverClassName=com.mysql.jdbc.Driver 10 | jdbc.ds.url=jdbc:mysql://127.0.0.1:3306/testshiro?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false 11 | jdbc.ds.username=root 12 | jdbc.ds.password=123456 13 | #配置最大连接数 14 | jdbc.ds.maxActive=30 15 | #配置初始化连接数 16 | jdbc.ds.initialSize=20 17 | #配置最小连接数 18 | jdbc.ds.minIdle=20 19 | 20 | #jsp 支持 21 | spring.mvc.view.suffix=.jsp 22 | spring.mvc.view.prefix=/WEB-INF/jsp/ 23 | 24 | #关闭默认模板引擎 25 | spring.thymeleaf.cache=false 26 | spring.thymeleaf.enabled=false 27 | 28 | #cas配置 29 | cas.server-url-prefix=https://server.cas.com:8443/cas 30 | cas.server-login-url=https://server.cas.com:8443/cas/login 31 | cas.client-host-url=http://app2.cas.com:8082 32 | cas.validation-type=CAS3 -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/resources/lib/cas-client-autoconfig-support-1.4.0-GA-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Negan1994/spring-boot-cas/ba8906c71b687998cff49bb3cf9eef59eed44e7b/cas-login-springboot-client2/src/main/resources/lib/cas-client-autoconfig-support-1.4.0-GA-sources.jar -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/resources/lib/cas-client-autoconfig-support-1.4.0-GA.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Negan1994/spring-boot-cas/ba8906c71b687998cff49bb3cf9eef59eed44e7b/cas-login-springboot-client2/src/main/resources/lib/cas-client-autoconfig-support-1.4.0-GA.jar -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | insert into user_info 8 | 9 | 10 | username, 11 | 12 | 13 | password, 14 | 15 | 16 | 17 | 18 | #{username}, 19 | 20 | 21 | #{password}, 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /cas-login-springboot-client2/src/main/webapp/WEB-INF/jsp/result.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | 4 | 6 | 7 | 8 | 9 | 10 | CAS Example Java Web App 11 | 12 | 13 | 14 |

添加用户成功

15 | 16 | 17 | -------------------------------------------------------------------------------- /cas-logout-client1/src/main/java/com/wangsaichao/cas/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.controller; 2 | 3 | import com.wangsaichao.cas.service.UserService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | import javax.servlet.http.HttpSession; 9 | import java.util.*; 10 | 11 | /** 12 | * @author: wangsaichao 13 | * @date: 2018/8/1 14 | * @description: 用户相关操作controller 15 | */ 16 | @Controller 17 | public class UserController { 18 | 19 | @Autowired 20 | private UserService userService; 21 | 22 | @RequestMapping("insert") 23 | public String insert(String username){ 24 | 25 | userService.insert(username); 26 | return "result"; 27 | } 28 | 29 | 30 | /** 31 | * 跳转到默认页面 32 | * @param session 33 | * @return 34 | */ 35 | @RequestMapping("/logout1") 36 | public String loginOut(HttpSession session){ 37 | session.invalidate(); 38 | //这个是直接退出,走的是默认退出方式 39 | return "redirect:https://server.cas.com:8443/cas/logout"; 40 | } 41 | 42 | /** 43 | * 跳转到指定页面 44 | * @param session 45 | * @return 46 | */ 47 | @RequestMapping("/logout2") 48 | public String loginOut2(HttpSession session){ 49 | session.invalidate(); 50 | //退出登录后,跳转到退成成功的页面,不走默认页面 51 | return "redirect:https://server.cas.com:8443/cas/logout?service=http://app1.cas.com:8081"; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /cas-logout-client1/src/main/java/com/wangsaichao/cas/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.apache.ibatis.annotations.Param; 4 | 5 | /** 6 | * @author: WangSaiChao 7 | * @date: 2018/8/1 8 | * @description: 用户操作 dao层 9 | */ 10 | public interface UserMapper { 11 | 12 | /** 13 | * 创建用户 14 | * @param username 15 | * @param password 16 | * @return 17 | */ 18 | void insert(@Param("username") String username, @Param("password") String password); 19 | } 20 | -------------------------------------------------------------------------------- /cas-logout-client1/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | /** 4 | * @author: WangSaiChao 5 | * @date: 2018/8/1 6 | * @description: 用户操作service层 7 | */ 8 | public interface UserService { 9 | 10 | /** 11 | * 创建用户 12 | * @param username 13 | * @return 14 | */ 15 | void insert(String username); 16 | } 17 | -------------------------------------------------------------------------------- /cas-logout-client1/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserMapper; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/1 11 | * @description: 12 | */ 13 | @Service 14 | public class UserServiceImpl implements UserService{ 15 | 16 | @Autowired 17 | private UserMapper userMapper; 18 | 19 | @Override 20 | public void insert(String username) { 21 | userMapper.insert(username,"123456"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cas-logout-client1/src/main/resources/config/application.properties: -------------------------------------------------------------------------------- 1 | jdbc.driver=com.mysql.jdbc.Driver 2 | jdbc.url=jdbc:mysql://127.0.0.1:3306/testshiro?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false 3 | jdbc.username=root 4 | jdbc.password=123456 -------------------------------------------------------------------------------- /cas-logout-client1/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | insert into user_info 8 | 9 | 10 | username, 11 | 12 | 13 | password, 14 | 15 | 16 | 17 | 18 | #{username}, 19 | 20 | 21 | #{password}, 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /cas-logout-client1/src/main/resources/spring/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /cas-logout-client1/src/main/webapp/WEB-INF/jsp/result.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | 4 | 6 | 7 | 8 | 9 | 10 | CAS Example Java Web App 11 | 12 | 13 | 14 |

添加用户成功

15 | 16 | 17 | -------------------------------------------------------------------------------- /cas-logout-client1/src/main/webapp/logout.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | <%@ page import="java.util.Map" %> 4 | <%@ page import="java.util.Iterator" %> 5 | <%@ page import="org.jasig.cas.client.authentication.AttributePrincipal" %> 6 | 7 | 9 | 10 | <% 11 | session.invalidate(); 12 | %> 13 | 14 | 15 | 16 | 17 | CAS Example Java Web App 18 | 19 | 20 |

CAS Example Java Web App

21 |

Application session is now invalidated. You may also issue a request to "/cas/logout" to destroy the CAS SSO Session as well.

22 |
23 | 24 | Back to Home 25 | 26 | 27 | -------------------------------------------------------------------------------- /cas-logout-client2/src/main/java/com/wangsaichao/cas/Application.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import priv.wangsaichao.cas.client.configuration.EnableCasClient; 6 | 7 | /** 8 | * @author: WangSaiChao 9 | * @date: 2018/8/2 10 | * @description: 启动类 11 | */ 12 | @SpringBootApplication 13 | @EnableCasClient//开启cas 14 | public class Application { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(Application.class, args); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /cas-logout-client2/src/main/java/com/wangsaichao/cas/config/SpringContext.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class SpringContext implements ApplicationContextAware{ 10 | 11 | private static ApplicationContext applicationContext; 12 | 13 | @Override 14 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 15 | if(SpringContext.applicationContext == null) { 16 | SpringContext.applicationContext = applicationContext; 17 | } 18 | } 19 | 20 | //获取applicationContext 21 | public static ApplicationContext getApplicationContext() { 22 | return applicationContext; 23 | } 24 | 25 | //通过name获取 Bean. 26 | public static Object getBean(String name){ 27 | return getApplicationContext().getBean(name); 28 | } 29 | 30 | //通过class获取Bean. 31 | public static T getBean(Class clazz){ 32 | return getApplicationContext().getBean(clazz); 33 | } 34 | 35 | //通过name,以及Clazz返回指定的Bean 36 | public static T getBean(String name,Class clazz){ 37 | return getApplicationContext().getBean(name, clazz); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /cas-logout-client2/src/main/java/com/wangsaichao/cas/config/SpringMVC.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.core.Ordered; 6 | import org.springframework.http.converter.HttpMessageConverter; 7 | import org.springframework.http.converter.StringHttpMessageConverter; 8 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 9 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 10 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 11 | 12 | import java.nio.charset.Charset; 13 | import java.util.List; 14 | 15 | /** 16 | * 等价于之前的SpringMVC.xml 17 | * 可以在此配置拦截器,过滤器,监听器 18 | * 配置静态文件映射 19 | * @author xiyan 20 | * 21 | */ 22 | @Configuration 23 | public class SpringMVC implements WebMvcConfigurer { 24 | 25 | @Bean 26 | public HttpMessageConverter responseBodyConverter() { 27 | StringHttpMessageConverter converter = new StringHttpMessageConverter(Charset.forName("UTF-8")); 28 | return converter; 29 | } 30 | 31 | @Override 32 | public void configureMessageConverters(List> converters) { 33 | converters.add(responseBodyConverter()); 34 | } 35 | 36 | @Override 37 | public void addViewControllers(ViewControllerRegistry registry) { 38 | //设定首页为index 39 | registry.addViewController("/").setViewName("forward:/index"); 40 | //设定匹配的优先级 41 | registry.setOrder(Ordered.HIGHEST_PRECEDENCE); 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /cas-logout-client2/src/main/java/com/wangsaichao/cas/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.controller; 2 | 3 | import com.wangsaichao.cas.service.UserService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | 8 | import javax.servlet.http.HttpSession; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/8/1 13 | * @description: 用户相关操作controller 14 | */ 15 | @Controller 16 | public class UserController { 17 | 18 | @Autowired 19 | private UserService userService; 20 | 21 | @RequestMapping("insert") 22 | public String insert(String username){ 23 | 24 | userService.insert(username); 25 | return "result"; 26 | } 27 | 28 | 29 | /** 30 | * 跳转到默认页面 31 | * @param session 32 | * @return 33 | */ 34 | @RequestMapping("/logout1") 35 | public String loginOut(HttpSession session){ 36 | session.invalidate(); 37 | //这个是直接退出,走的是默认退出方式 38 | return "redirect:https://server.cas.com:8443/cas/logout"; 39 | } 40 | 41 | /** 42 | * 跳转到指定页面 43 | * @param session 44 | * @return 45 | */ 46 | @RequestMapping("/logout2") 47 | public String loginOut2(HttpSession session){ 48 | session.invalidate(); 49 | //退出登录后,跳转到退成成功的页面,不走默认页面 50 | return "redirect:https://server.cas.com:8443/cas/logout?service=http://app2.cas.com:8082"; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /cas-logout-client2/src/main/java/com/wangsaichao/cas/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.apache.ibatis.annotations.Mapper; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | /** 7 | * @author: WangSaiChao 8 | * @date: 2018/8/1 9 | * @description: 用户操作 dao层 10 | */ 11 | @Mapper 12 | public interface UserMapper { 13 | 14 | /** 15 | * 创建用户 16 | * @param username 17 | * @param password 18 | * @return 19 | */ 20 | void insert(@Param("username") String username, @Param("password") String password); 21 | } 22 | -------------------------------------------------------------------------------- /cas-logout-client2/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | /** 4 | * @author: WangSaiChao 5 | * @date: 2018/8/1 6 | * @description: 用户操作service层 7 | */ 8 | public interface UserService { 9 | 10 | /** 11 | * 创建用户 12 | * @param username 13 | * @return 14 | */ 15 | void insert(String username); 16 | } 17 | -------------------------------------------------------------------------------- /cas-logout-client2/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserMapper; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/1 11 | * @description: 12 | */ 13 | @Service 14 | public class UserServiceImpl implements UserService{ 15 | 16 | @Autowired 17 | private UserMapper userMapper; 18 | 19 | @Override 20 | public void insert(String username) { 21 | userMapper.insert(username,"123456"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /cas-logout-client2/src/main/resources/config/application.properties: -------------------------------------------------------------------------------- 1 | #配置tomcat 2 | server.port=8082 3 | server.servlet.context-path=/ 4 | #日志文件的路径 5 | logging.config=classpath:config/logback-spring.xml 6 | mybatis.mapper-locations=classpath:mapper/*.xml 7 | 8 | #配置jdbc数据源 9 | jdbc.ds.driverClassName=com.mysql.jdbc.Driver 10 | jdbc.ds.url=jdbc:mysql://127.0.0.1:3306/testshiro?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false 11 | jdbc.ds.username=root 12 | jdbc.ds.password=123456 13 | #配置最大连接数 14 | jdbc.ds.maxActive=30 15 | #配置初始化连接数 16 | jdbc.ds.initialSize=20 17 | #配置最小连接数 18 | jdbc.ds.minIdle=20 19 | 20 | #jsp 支持 21 | spring.mvc.view.suffix=.jsp 22 | spring.mvc.view.prefix=/WEB-INF/jsp/ 23 | 24 | #关闭默认模板引擎 25 | spring.thymeleaf.cache=false 26 | spring.thymeleaf.enabled=false 27 | 28 | #cas配置 29 | cas.server-url-prefix=https://server.cas.com:8443/cas 30 | cas.server-login-url=https://server.cas.com:8443/cas/login 31 | cas.client-host-url=http://app2.cas.com:8082 -------------------------------------------------------------------------------- /cas-logout-client2/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | insert into user_info 8 | 9 | 10 | username, 11 | 12 | 13 | password, 14 | 15 | 16 | 17 | 18 | #{username}, 19 | 20 | 21 | #{password}, 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /cas-logout-client2/src/main/webapp/WEB-INF/jsp/result.jsp: -------------------------------------------------------------------------------- 1 | <%@page contentType="text/html" %> 2 | <%@page pageEncoding="UTF-8" %> 3 | 4 | 6 | 7 | 8 | 9 | 10 | CAS Example Java Web App 11 | 12 | 13 | 14 |

添加用户成功

15 | 16 | 17 | -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/18 13 | * @description: 操作用户信息 14 | */ 15 | @Repository("userDao") 16 | public class UserDao { 17 | 18 | @Autowired 19 | private JdbcTemplate jdbcTemplate; 20 | 21 | /** 22 | * 通过用户名查询用户角色信息 23 | * @param userName 24 | * @return 25 | */ 26 | public Map findByUserName(String userName){ 27 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.DataSourceConfig,\ 3 | com.wangsaichao.cas.config.ShiroAuthenticationConfiguration -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/app1.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 2 | cas.standard.css.file=/css/cas.css 3 | #\u81EA\u5DF1\u7684\u6837\u5F0F 4 | cas.myself.css=/themes/app1/css/cas.css 5 | cas.javascript.file=/themes/app1/js/jquery-1.4.2.min.js 6 | cas.page.title=app1\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/app2.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 cas.standard.css.file=/css/cas.css #\u81EA\u5DF1\u7684\u6837\u5F0F cas.myself.css=/themes/app2/css/cas.css cas.javascript.file=/themes/app2/js/jquery-1.4.2.min.js cas.page.title=app2\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/services/APP1-1000.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app1.cas.com.*", 4 | "name" : "测试客户端app1", 5 | "id" : 1000, 6 | "description" : "这是app1的客户端", 7 | "evaluationOrder" : 10, 8 | "theme" : "app1" 9 | } -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/services/APP2-1001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app2.cas.com.*", 4 | "name" : "测试客户端app2", 5 | "id" : 1001, 6 | "description" : "这是app2的客户端", 7 | "evaluationOrder" : 11, 8 | "theme" : "app2" 9 | } -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/static/themes/app1/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: red; } -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/static/themes/app2/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: pink; } -------------------------------------------------------------------------------- /cas-logout-confirm-page-server/src/main/resources/templates/casConfirmLogoutView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Confirm Logout View 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |

Do you want to log out completely?

17 |

18 | 确认退出将结束你的会话,跳转到登录页面。 19 |

20 |


你确认退出吗?

21 | 22 |
23 |
24 | 25 | 26 | 27 | 33 |
34 |
35 |
36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /cas-management-overlay/src/main/resources/user-details.properties: -------------------------------------------------------------------------------- 1 | # This file lists the set of users that are allowed access to the management app. 2 | # 3 | # The syntax of each entry should be in the form of: 4 | # 5 | # username=password,grantedAuthority[,grantedAutority][,enabled|disabled] 6 | admin=123456,ROLE_ADMIN,ROLE_ACTUATOR 7 | test=123456,ROLE_ADMIN -------------------------------------------------------------------------------- /cas-oauth-server/src/main/java/com/wangsaichao/cas/adaptors/generic/RememberMeUsernamePasswordCaptchaCredential.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.adaptors.generic; 2 | 3 | import org.apache.commons.lang.builder.HashCodeBuilder; 4 | import org.apereo.cas.authentication.RememberMeUsernamePasswordCredential; 5 | 6 | import javax.validation.constraints.Size; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/31 11 | * @description: 验证码 Credential 12 | */ 13 | public class RememberMeUsernamePasswordCaptchaCredential extends RememberMeUsernamePasswordCredential { 14 | 15 | @Size(min = 5,max = 5, message = "require captcha") 16 | private String captcha; 17 | 18 | public String getCaptcha() { 19 | return captcha; 20 | } 21 | 22 | public void setCaptcha(String captcha) { 23 | this.captcha = captcha; 24 | } 25 | 26 | @Override 27 | public int hashCode() { 28 | return new HashCodeBuilder() 29 | .appendSuper(super.hashCode()) 30 | .append(this.captcha) 31 | .toHashCode(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.dao.DataAccessException; 6 | import org.springframework.dao.EmptyResultDataAccessException; 7 | import org.springframework.jdbc.core.JdbcTemplate; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * @author: wangsaichao 14 | * @date: 2018/7/18 15 | * @description: 操作用户信息 16 | */ 17 | @Repository("userDao") 18 | public class UserDao { 19 | 20 | @Autowired 21 | private JdbcTemplate jdbcTemplate; 22 | 23 | /** 24 | * 通过用户名查询用户角色信息 25 | * @param userName 26 | * @return 27 | */ 28 | public Map findByUserName(String userName){ 29 | try { 30 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 31 | } catch (EmptyResultDataAccessException e) { 32 | return null; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/java/com/wangsaichao/cas/exception/CaptchaErrorException.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.exception; 2 | 3 | import javax.security.auth.login.AccountException; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/8/31 8 | * @description: 验证码错误异常类 9 | */ 10 | public class CaptchaErrorException extends AccountException { 11 | 12 | public CaptchaErrorException() { 13 | super(); 14 | } 15 | 16 | public CaptchaErrorException(String msg) { 17 | super(msg); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/java/com/wangsaichao/cas/exception/MyAccountNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.exception; 2 | 3 | import javax.security.auth.login.AccountException; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/8/31 8 | * @description: 用户没找到异常 9 | */ 10 | public class MyAccountNotFoundException extends AccountException { 11 | public MyAccountNotFoundException() { 12 | super(); 13 | } 14 | 15 | public MyAccountNotFoundException(String msg) { 16 | super(msg); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.RememberMeConfiguration,\ 3 | com.wangsaichao.cas.config.CaptchaWebflowConfiguration,\ 4 | com.wangsaichao.cas.config.DataSourceConfig -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/app1.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 2 | cas.standard.css.file=/css/cas.css 3 | #\u81EA\u5DF1\u7684\u6837\u5F0F 4 | cas.myself.css=/themes/app1/css/cas.css 5 | cas.javascript.file=/themes/app1/js/jquery-1.4.2.min.js 6 | cas.page.title=app1\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/app2.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 cas.standard.css.file=/css/cas.css #\u81EA\u5DF1\u7684\u6837\u5F0F cas.myself.css=/themes/app2/css/cas.css cas.javascript.file=/themes/app2/js/jquery-1.4.2.min.js cas.page.title=app2\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/services/APP1-1000.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app1.cas.com.*", 4 | "name" : "测试客户端app1", 5 | "id" : 1000, 6 | "description" : "这是app1的客户端", 7 | "evaluationOrder" : 10, 8 | "theme" : "app1", 9 | "attributeReleasePolicy" : { 10 | "@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy" 11 | } 12 | } -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/services/APP2-1001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app2.cas.com.*", 4 | "name" : "测试客户端app2", 5 | "id" : 1001, 6 | "description" : "这是app2的客户端", 7 | "evaluationOrder" : 11, 8 | "theme" : "app2", 9 | "attributeReleasePolicy" : { 10 | "@class" : "org.apereo.cas.services.ReturnAllowedAttributeReleasePolicy" 11 | "allowedAttributes" : [ "java.util.ArrayList", [ "name", "id_card_num" ] ] 12 | } 13 | } -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/services/OAUTH-1002.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.support.oauth.services.OAuthRegisteredService", 3 | "clientId": "20180901", 4 | "clientSecret": "123456", 5 | "serviceId" : "^(https|http|imaps)://.*", 6 | "name" : "OAuthService", 7 | "id" : 1002 8 | } -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/sql/user_info.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:37 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `user_info` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `user_info`; 24 | CREATE TABLE `user_info` ( 25 | `uid` int(11) NOT NULL AUTO_INCREMENT, 26 | `username` varchar(50) DEFAULT '' COMMENT '用户名', 27 | `password` varchar(256) DEFAULT NULL COMMENT '登录密码', 28 | `name` varchar(256) DEFAULT NULL COMMENT '用户真实姓名', 29 | `id_card_num` varchar(256) DEFAULT NULL COMMENT '用户身份证号', 30 | `state` char(1) DEFAULT '0' COMMENT '用户状态:0:正常状态,1:用户被锁定', 31 | PRIMARY KEY (`uid`), 32 | UNIQUE KEY `username` (`username`) USING BTREE, 33 | UNIQUE KEY `id_card_num` (`id_card_num`) USING BTREE 34 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 35 | 36 | -- ---------------------------- 37 | -- Records of `user_info` 38 | -- ---------------------------- 39 | BEGIN; 40 | INSERT INTO `user_info` VALUES ('1', 'admin', 'e10adc3949ba59abbe56e057f20f883e', '超哥', '133333333333333333', '0'), ('2', 'test', 'ed0290f05224a188160858124a5f5077', '孙悟空', '155555555555555555', '1'), ('3', 'wangsaichao', '123456', '王赛超', '177777777777777777', '0'); 41 | COMMIT; 42 | 43 | SET FOREIGN_KEY_CHECKS = 1; 44 | -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/static/themes/app1/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: red; } -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/static/themes/app2/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: pink; } -------------------------------------------------------------------------------- /cas-oauth-server/src/main/resources/templates/casConfirmLogoutView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Confirm Logout View 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |

Do you want to log out completely?

17 |

18 | 确认退出将结束你的会话,跳转到登录页面。 19 |

20 |


你确认退出吗?

21 | 22 |
23 |
24 | 25 | 26 | 27 | 33 |
34 |
35 |
36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /cas-redis-server/src/main/java/com/wangsaichao/cas/adaptors/generic/RememberMeUsernamePasswordCaptchaCredential.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.adaptors.generic; 2 | 3 | import org.apache.commons.lang.builder.HashCodeBuilder; 4 | import org.apereo.cas.authentication.RememberMeUsernamePasswordCredential; 5 | 6 | import javax.validation.constraints.Size; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/31 11 | * @description: 验证码 Credential 12 | */ 13 | public class RememberMeUsernamePasswordCaptchaCredential extends RememberMeUsernamePasswordCredential { 14 | 15 | @Size(min = 5,max = 5, message = "require captcha") 16 | private String captcha; 17 | 18 | public String getCaptcha() { 19 | return captcha; 20 | } 21 | 22 | public void setCaptcha(String captcha) { 23 | this.captcha = captcha; 24 | } 25 | 26 | @Override 27 | public int hashCode() { 28 | return new HashCodeBuilder() 29 | .appendSuper(super.hashCode()) 30 | .append(this.captcha) 31 | .toHashCode(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cas-redis-server/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-redis-server/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.dao.DataAccessException; 6 | import org.springframework.dao.EmptyResultDataAccessException; 7 | import org.springframework.jdbc.core.JdbcTemplate; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * @author: wangsaichao 14 | * @date: 2018/7/18 15 | * @description: 操作用户信息 16 | */ 17 | @Repository("userDao") 18 | public class UserDao { 19 | 20 | @Autowired 21 | private JdbcTemplate jdbcTemplate; 22 | 23 | /** 24 | * 通过用户名查询用户角色信息 25 | * @param userName 26 | * @return 27 | */ 28 | public Map findByUserName(String userName){ 29 | try { 30 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 31 | } catch (EmptyResultDataAccessException e) { 32 | return null; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cas-redis-server/src/main/java/com/wangsaichao/cas/exception/CaptchaErrorException.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.exception; 2 | 3 | import javax.security.auth.login.AccountException; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/8/31 8 | * @description: 验证码错误异常类 9 | */ 10 | public class CaptchaErrorException extends AccountException { 11 | 12 | public CaptchaErrorException() { 13 | super(); 14 | } 15 | 16 | public CaptchaErrorException(String msg) { 17 | super(msg); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cas-redis-server/src/main/java/com/wangsaichao/cas/exception/MyAccountNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.exception; 2 | 3 | import javax.security.auth.login.AccountException; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/8/31 8 | * @description: 用户没找到异常 9 | */ 10 | public class MyAccountNotFoundException extends AccountException { 11 | public MyAccountNotFoundException() { 12 | super(); 13 | } 14 | 15 | public MyAccountNotFoundException(String msg) { 16 | super(msg); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cas-redis-server/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-redis-server/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-redis-server/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-redis-server/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-redis-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.RememberMeConfiguration,\ 3 | com.wangsaichao.cas.config.CaptchaWebflowConfiguration,\ 4 | com.wangsaichao.cas.config.DataSourceConfig -------------------------------------------------------------------------------- /cas-redis-server/src/main/resources/app1.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 2 | cas.standard.css.file=/css/cas.css 3 | #\u81EA\u5DF1\u7684\u6837\u5F0F 4 | cas.myself.css=/themes/app1/css/cas.css 5 | cas.javascript.file=/themes/app1/js/jquery-1.4.2.min.js 6 | cas.page.title=app1\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-redis-server/src/main/resources/app2.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 cas.standard.css.file=/css/cas.css #\u81EA\u5DF1\u7684\u6837\u5F0F cas.myself.css=/themes/app2/css/cas.css cas.javascript.file=/themes/app2/js/jquery-1.4.2.min.js cas.page.title=app2\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-redis-server/src/main/resources/services/APP1-1000.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app1.cas.com.*", 4 | "name" : "测试客户端app1", 5 | "id" : 1000, 6 | "description" : "这是app1的客户端", 7 | "evaluationOrder" : 10, 8 | "theme" : "app1", 9 | "attributeReleasePolicy" : { 10 | "@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy" 11 | } 12 | } -------------------------------------------------------------------------------- /cas-redis-server/src/main/resources/services/APP2-1001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app2.cas.com.*", 4 | "name" : "测试客户端app2", 5 | "id" : 1001, 6 | "description" : "这是app2的客户端", 7 | "evaluationOrder" : 11, 8 | "theme" : "app2", 9 | "attributeReleasePolicy" : { 10 | "@class" : "org.apereo.cas.services.ReturnAllowedAttributeReleasePolicy" 11 | "allowedAttributes" : [ "java.util.ArrayList", [ "name", "id_card_num" ] ] 12 | } 13 | } -------------------------------------------------------------------------------- /cas-redis-server/src/main/resources/static/themes/app1/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: red; } -------------------------------------------------------------------------------- /cas-redis-server/src/main/resources/static/themes/app2/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: pink; } -------------------------------------------------------------------------------- /cas-redis-server/src/main/resources/templates/casConfirmLogoutView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Confirm Logout View 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |

Do you want to log out completely?

17 |

18 | 确认退出将结束你的会话,跳转到登录页面。 19 |

20 |


你确认退出吗?

21 | 22 |
23 |
24 | 25 | 26 | 27 | 33 |
34 |
35 |
36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /cas-rest-demo/src/main/java/com/wangsaichao/cas/dao/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import com.wangsaichao.cas.dao.entity.SysUser; 4 | import org.apache.ibatis.annotations.Param; 5 | 6 | /** 7 | * @author: WangSaiChao 8 | * @date: 2018/8/1 9 | * @description: 用户操作 dao层 10 | */ 11 | public interface UserMapper { 12 | 13 | /** 14 | * 根据用户名查询用户信息 15 | * @param username 16 | * @return 17 | */ 18 | SysUser selectUser(@Param("username") String username); 19 | } 20 | -------------------------------------------------------------------------------- /cas-rest-demo/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import com.wangsaichao.cas.dao.entity.SysUser; 4 | 5 | /** 6 | * @author: WangSaiChao 7 | * @date: 2018/8/1 8 | * @description: 用户操作service层 9 | */ 10 | public interface UserService { 11 | 12 | /** 13 | * 根据用户名查询用户信息 14 | * @param username 15 | * @return 16 | */ 17 | SysUser selectUser(String username); 18 | } 19 | -------------------------------------------------------------------------------- /cas-rest-demo/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserMapper; 4 | import com.wangsaichao.cas.dao.entity.SysUser; 5 | import com.wangsaichao.cas.service.UserService; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | /** 10 | * @author: wangsaichao 11 | * @date: 2018/8/1 12 | * @description: 13 | */ 14 | @Service 15 | public class UserServiceImpl implements UserService{ 16 | 17 | @Autowired 18 | private UserMapper userMapper; 19 | 20 | @Override 21 | public SysUser selectUser(String username) { 22 | return userMapper.selectUser(username); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /cas-rest-demo/src/main/resources/config/application.properties: -------------------------------------------------------------------------------- 1 | jdbc.driver=com.mysql.jdbc.Driver 2 | jdbc.url=jdbc:mysql://127.0.0.1:3306/testshiro?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false 3 | jdbc.username=root 4 | jdbc.password=123456 -------------------------------------------------------------------------------- /cas-rest-demo/src/main/resources/mapper/UserMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /cas-rest-demo/src/main/resources/spring/spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /cas-rest-demo/src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Hello World!

4 | 5 | -------------------------------------------------------------------------------- /cas-rest-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | org.apereo.cas.config.CasEmbeddedContainerTomcatConfiguration,\ 3 | org.apereo.cas.config.CasEmbeddedContainerTomcatFiltersConfiguration 4 | 5 | -------------------------------------------------------------------------------- /cas-return-server/src/main/java/com/wangsaichao/cas/adaptors/generic/RememberMeUsernamePasswordCaptchaCredential.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.adaptors.generic; 2 | 3 | import org.apache.commons.lang.builder.HashCodeBuilder; 4 | import org.apereo.cas.authentication.RememberMeUsernamePasswordCredential; 5 | 6 | import javax.validation.constraints.Size; 7 | 8 | /** 9 | * @author: wangsaichao 10 | * @date: 2018/8/31 11 | * @description: 验证码 Credential 12 | */ 13 | public class RememberMeUsernamePasswordCaptchaCredential extends RememberMeUsernamePasswordCredential { 14 | 15 | @Size(min = 5,max = 5, message = "require captcha") 16 | private String captcha; 17 | 18 | public String getCaptcha() { 19 | return captcha; 20 | } 21 | 22 | public void setCaptcha(String captcha) { 23 | this.captcha = captcha; 24 | } 25 | 26 | @Override 27 | public int hashCode() { 28 | return new HashCodeBuilder() 29 | .appendSuper(super.hashCode()) 30 | .append(this.captcha) 31 | .toHashCode(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /cas-return-server/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-return-server/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.dao.DataAccessException; 6 | import org.springframework.dao.EmptyResultDataAccessException; 7 | import org.springframework.jdbc.core.JdbcTemplate; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.Map; 11 | 12 | /** 13 | * @author: wangsaichao 14 | * @date: 2018/7/18 15 | * @description: 操作用户信息 16 | */ 17 | @Repository("userDao") 18 | public class UserDao { 19 | 20 | @Autowired 21 | private JdbcTemplate jdbcTemplate; 22 | 23 | /** 24 | * 通过用户名查询用户角色信息 25 | * @param userName 26 | * @return 27 | */ 28 | public Map findByUserName(String userName){ 29 | try { 30 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 31 | } catch (EmptyResultDataAccessException e) { 32 | return null; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cas-return-server/src/main/java/com/wangsaichao/cas/exception/CaptchaErrorException.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.exception; 2 | 3 | import javax.security.auth.login.AccountException; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/8/31 8 | * @description: 验证码错误异常类 9 | */ 10 | public class CaptchaErrorException extends AccountException { 11 | 12 | public CaptchaErrorException() { 13 | super(); 14 | } 15 | 16 | public CaptchaErrorException(String msg) { 17 | super(msg); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /cas-return-server/src/main/java/com/wangsaichao/cas/exception/MyAccountNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.exception; 2 | 3 | import javax.security.auth.login.AccountException; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/8/31 8 | * @description: 用户没找到异常 9 | */ 10 | public class MyAccountNotFoundException extends AccountException { 11 | public MyAccountNotFoundException() { 12 | super(); 13 | } 14 | 15 | public MyAccountNotFoundException(String msg) { 16 | super(msg); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /cas-return-server/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-return-server/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-return-server/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-return-server/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.RememberMeConfiguration,\ 3 | com.wangsaichao.cas.config.CaptchaWebflowConfiguration,\ 4 | com.wangsaichao.cas.config.DataSourceConfig -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/app1.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 2 | cas.standard.css.file=/css/cas.css 3 | #\u81EA\u5DF1\u7684\u6837\u5F0F 4 | cas.myself.css=/themes/app1/css/cas.css 5 | cas.javascript.file=/themes/app1/js/jquery-1.4.2.min.js 6 | cas.page.title=app1\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/app2.properties: -------------------------------------------------------------------------------- 1 | #\u539Fcas\u9ED8\u8BA4\u7684css\u6837\u5F0F,\u5982\u679C\u66F4\u6539\u4E86,\u67D0\u4E9B\u9875\u9762\u6837\u5F0F\u5C06\u4E22\u5931 cas.standard.css.file=/css/cas.css #\u81EA\u5DF1\u7684\u6837\u5F0F cas.myself.css=/themes/app2/css/cas.css cas.javascript.file=/themes/app2/js/jquery-1.4.2.min.js cas.page.title=app2\u7684\u4E3B\u9898 -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/services/APP1-1000.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app1.cas.com.*", 4 | "name" : "测试客户端app1", 5 | "id" : 1000, 6 | "description" : "这是app1的客户端", 7 | "evaluationOrder" : 10, 8 | "theme" : "app1", 9 | "attributeReleasePolicy" : { 10 | "@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy" 11 | } 12 | } -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/services/APP2-1001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app2.cas.com.*", 4 | "name" : "测试客户端app2", 5 | "id" : 1001, 6 | "description" : "这是app2的客户端", 7 | "evaluationOrder" : 11, 8 | "theme" : "app2", 9 | "attributeReleasePolicy" : { 10 | "@class" : "org.apereo.cas.services.ReturnAllowedAttributeReleasePolicy" 11 | "allowedAttributes" : [ "java.util.ArrayList", [ "name", "id_card_num" ] ] 12 | } 13 | } -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/static/themes/app1/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: red; } -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/static/themes/app2/css/cas.css: -------------------------------------------------------------------------------- 1 | h2{ color: pink; } -------------------------------------------------------------------------------- /cas-return-server/src/main/resources/templates/casConfirmLogoutView.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Confirm Logout View 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 |

Do you want to log out completely?

17 |

18 | 确认退出将结束你的会话,跳转到登录页面。 19 |

20 |


你确认退出吗?

21 | 22 |
23 |
24 | 25 | 26 | 27 | 33 |
34 |
35 |
36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/18 13 | * @description: 操作用户信息 14 | */ 15 | @Repository("userDao") 16 | public class UserDao { 17 | 18 | @Autowired 19 | private JdbcTemplate jdbcTemplate; 20 | 21 | /** 22 | * 通过用户名查询用户角色信息 23 | * @param userName 24 | * @return 25 | */ 26 | public Map findByUserName(String userName){ 27 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/java/com/wangsaichao/cas/resolver/DeleteServiceActionResolver.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.resolver; 2 | 3 | import org.apereo.inspektr.audit.annotation.Audit; 4 | import org.apereo.inspektr.audit.spi.support.AbstractSuffixAwareAuditActionResolver; 5 | import org.aspectj.lang.JoinPoint; 6 | 7 | /** 8 | * @author: wangsaichao 9 | * @date: 2018/8/10 10 | * @description: 11 | */ 12 | public class DeleteServiceActionResolver extends AbstractSuffixAwareAuditActionResolver { 13 | 14 | /** 15 | * Constructs the resolver with empty values for the two suffixes. 16 | */ 17 | public DeleteServiceActionResolver() { 18 | this("",""); 19 | } 20 | 21 | /** 22 | * Constructs the {@link DeleteServiceActionResolver} with a success suffix and failure 23 | * suffix. CANNOT be NULL. 24 | * @param successSuffix the suffix to use in the event of a success. 25 | * @param failureSuffix the suffix to use in the event of a failure. 26 | */ 27 | public DeleteServiceActionResolver(final String successSuffix, final String failureSuffix) { 28 | super(successSuffix, failureSuffix); 29 | } 30 | 31 | @Override 32 | public String resolveFrom(final JoinPoint auditableTarget, final Object retval, final Audit audit) { 33 | return audit.action() + getSuccessSuffix(); 34 | } 35 | 36 | @Override 37 | public String resolveFrom(final JoinPoint auditableTarget, final Exception exception, final Audit audit) { 38 | return audit.action() + getFailureSuffix(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/java/com/wangsaichao/cas/resolver/DeleteServiceResourceResolver.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.resolver; 2 | 3 | import org.apereo.inspektr.audit.spi.AuditResourceResolver; 4 | import org.aspectj.lang.JoinPoint; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/8/10 9 | * @description: 10 | */ 11 | public class DeleteServiceResourceResolver implements AuditResourceResolver { 12 | @Override 13 | public String[] resolveFrom(JoinPoint target, Object returnValue) { 14 | return new String[0]; 15 | } 16 | 17 | @Override 18 | public String[] resolveFrom(JoinPoint target, Exception exception) { 19 | return new String[0]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.DataSourceConfig,\ 3 | com.wangsaichao.cas.config.ShiroAuthenticationConfiguration,\ 4 | com.wangsaichao.cas.config.CasCoreAuditConfiguration -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/resources/services/HTTPSandIMAPS-10000001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://app1.cas.com.*", 4 | "name" : "测试客户端", 5 | "id" : 10000001, 6 | "description" : "这是一个测试客户端的服务,所有的https访问都允许通过", 7 | "evaluationOrder" : 10000 8 | } 9 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-server-auto-regist-service/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-server-base/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | org.apereo.cas.config.CasEmbeddedContainerTomcatConfiguration,\ 3 | org.apereo.cas.config.CasEmbeddedContainerTomcatFiltersConfiguration 4 | 5 | -------------------------------------------------------------------------------- /cas-server-core-audit/src/main/java/org/apereo/cas/audit/spi/config/DeleteServiceActionResolver.java: -------------------------------------------------------------------------------- 1 | package org.apereo.cas.audit.spi.config; 2 | 3 | import org.apereo.inspektr.audit.annotation.Audit; 4 | import org.apereo.inspektr.audit.spi.support.AbstractSuffixAwareAuditActionResolver; 5 | import org.aspectj.lang.JoinPoint; 6 | 7 | /** 8 | * @author: wangsaichao 9 | * @date: 2018/8/10 10 | * @description: 11 | */ 12 | public class DeleteServiceActionResolver extends AbstractSuffixAwareAuditActionResolver { 13 | 14 | /** 15 | * Constructs the resolver with empty values for the two suffixes. 16 | */ 17 | public DeleteServiceActionResolver() { 18 | this("",""); 19 | } 20 | 21 | /** 22 | * Constructs the {@link DeleteServiceActionResolver} with a success suffix and failure 23 | * suffix. CANNOT be NULL. 24 | * @param successSuffix the suffix to use in the event of a success. 25 | * @param failureSuffix the suffix to use in the event of a failure. 26 | */ 27 | public DeleteServiceActionResolver(final String successSuffix, final String failureSuffix) { 28 | super(successSuffix, failureSuffix); 29 | } 30 | 31 | @Override 32 | public String resolveFrom(final JoinPoint auditableTarget, final Object retval, final Audit audit) { 33 | return audit.action() + getSuccessSuffix(); 34 | } 35 | 36 | @Override 37 | public String resolveFrom(final JoinPoint auditableTarget, final Exception exception, final Audit audit) { 38 | return audit.action() + getFailureSuffix(); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /cas-server-core-audit/src/main/java/org/apereo/cas/audit/spi/config/DeleteServiceResourceResolver.java: -------------------------------------------------------------------------------- 1 | package org.apereo.cas.audit.spi.config; 2 | 3 | import org.apereo.inspektr.audit.spi.AuditResourceResolver; 4 | import org.aspectj.lang.JoinPoint; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/8/10 9 | * @description: 10 | */ 11 | public class DeleteServiceResourceResolver implements AuditResourceResolver { 12 | @Override 13 | public String[] resolveFrom(JoinPoint target, Object returnValue) { 14 | return new String[0]; 15 | } 16 | 17 | @Override 18 | public String[] resolveFrom(JoinPoint target, Exception exception) { 19 | return new String[0]; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /cas-server-core-audit/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.apereo.cas.audit.spi.config.CasCoreAuditConfiguration -------------------------------------------------------------------------------- /cas-server-custom-verifify/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | org.apereo.cas.config.CasEmbeddedContainerTomcatConfiguration,\ 3 | org.apereo.cas.config.CasEmbeddedContainerTomcatFiltersConfiguration 4 | 5 | -------------------------------------------------------------------------------- /cas-server-custom-verifify2/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.MyAuthenticationConfiguration 2 | 3 | -------------------------------------------------------------------------------- /cas-server-jdbc/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ 2 | org.apereo.cas.config.CasEmbeddedContainerTomcatConfiguration,\ 3 | org.apereo.cas.config.CasEmbeddedContainerTomcatFiltersConfiguration 4 | 5 | -------------------------------------------------------------------------------- /cas-server-shiro/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-server-shiro/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/18 13 | * @description: 操作用户信息 14 | */ 15 | @Repository("userDao") 16 | public class UserDao { 17 | 18 | @Autowired 19 | private JdbcTemplate jdbcTemplate; 20 | 21 | /** 22 | * 通过用户名查询用户角色信息 23 | * @param userName 24 | * @return 25 | */ 26 | public Map findByUserName(String userName){ 27 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cas-server-shiro/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-server-shiro/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-server-shiro/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-server-shiro/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-server-shiro/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.DataSourceConfig,\ 3 | com.wangsaichao.cas.config.ShiroAuthenticationConfiguration -------------------------------------------------------------------------------- /cas-server-shiro/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-server-shiro/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-server-shiro/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-server-shiro1/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.apereo.cas.config.ShiroAuthenticationConfiguration -------------------------------------------------------------------------------- /cas-server-shiro1/src/main/resources/shiro.ini: -------------------------------------------------------------------------------- 1 | [main] 2 | cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager 3 | securityManager.cacheManager = $cacheManager 4 | 5 | [users] 6 | #密码123 7 | admin = e10adc3949ba59abbe56e057f20f883e, admin 8 | #不可登录,因为配置了需要角色admin 9 | #密码123456 10 | test = ed0290f05224a188160858124a5f5077, test 11 | 12 | [roles] 13 | admin = userInfo:* 14 | test = commit:* -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/java/com/wangsaichao/cas/config/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.config; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | /** 7 | * @author: wangsaichao 8 | * @date: 2018/7/19 9 | * @description: 10 | * 这个配置是空值,是为了让spring 加载 这个包下 标注了 @Service @Component @Controller 等注解的Bean 11 | * 并需要在resource/META-INF/spring.factories 中配置 12 | */ 13 | @Configuration 14 | @ComponentScan("com.wangsaichao.cas") 15 | public class SpringConfig { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/java/com/wangsaichao/cas/dao/UserDao.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.dao; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Lazy; 5 | import org.springframework.jdbc.core.JdbcTemplate; 6 | import org.springframework.stereotype.Repository; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/18 13 | * @description: 操作用户信息 14 | */ 15 | @Repository("userDao") 16 | public class UserDao { 17 | 18 | @Autowired 19 | private JdbcTemplate jdbcTemplate; 20 | 21 | /** 22 | * 通过用户名查询用户角色信息 23 | * @param userName 24 | * @return 25 | */ 26 | public Map findByUserName(String userName){ 27 | return jdbcTemplate.queryForMap("SELECT * FROM user_info WHERE username =?",userName); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/java/com/wangsaichao/cas/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface RoleService { 6 | 7 | String findRolesByUserId(String uid); 8 | 9 | Set findAllRoles(); 10 | } 11 | -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/java/com/wangsaichao/cas/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * @author: wangsaichao 7 | * @date: 2018/7/19 8 | * @description: 9 | */ 10 | public interface UserService { 11 | 12 | Map findByUserName(String userName); 13 | } 14 | -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/java/com/wangsaichao/cas/service/impl/RoleServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.RoleDao; 4 | import com.wangsaichao.cas.service.RoleService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Set; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class RoleServiceImpl implements RoleService{ 17 | 18 | @Autowired 19 | private RoleDao roleDao; 20 | 21 | @Override 22 | public String findRolesByUserId(String uid) { 23 | return roleDao.findRolesByUserId(uid); 24 | } 25 | 26 | @Override 27 | public Set findAllRoles() { 28 | return roleDao.findAllRoles(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/java/com/wangsaichao/cas/service/impl/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.wangsaichao.cas.service.impl; 2 | 3 | import com.wangsaichao.cas.dao.UserDao; 4 | import com.wangsaichao.cas.service.UserService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Map; 9 | 10 | /** 11 | * @author: wangsaichao 12 | * @date: 2018/7/19 13 | * @description: 14 | */ 15 | @Service 16 | public class UserServiceImpl implements UserService { 17 | 18 | @Autowired 19 | private UserDao userDao; 20 | 21 | @Override 22 | public Map findByUserName(String userName) { 23 | return userDao.findByUserName(userName); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.wangsaichao.cas.config.SpringConfig,\ 2 | com.wangsaichao.cas.config.DataSourceConfig,\ 3 | com.wangsaichao.cas.config.ShiroAuthenticationConfiguration -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/resources/services/HTTPSandIMAPS-10000001.json: -------------------------------------------------------------------------------- 1 | { 2 | "@class" : "org.apereo.cas.services.RegexRegisteredService", 3 | "serviceId" : "^(https|imaps|http)://.*", 4 | "name" : "测试客户端", 5 | "id" : 10000001, 6 | "description" : "这是一个测试客户端的服务,所有的https访问都允许通过", 7 | "evaluationOrder" : 10000 8 | } 9 | -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/resources/sql/sys_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:45 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role`; 24 | CREATE TABLE `sys_role` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键', 26 | `available` char(1) DEFAULT '0' COMMENT '是否可用0可用 1不可用', 27 | `role` varchar(20) DEFAULT NULL COMMENT '角色标识程序中判断使用,如"admin"', 28 | `description` varchar(100) DEFAULT NULL COMMENT '角色描述,UI界面显示使用', 29 | PRIMARY KEY (`id`), 30 | UNIQUE KEY `role` (`role`) USING BTREE 31 | ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; 32 | 33 | -- ---------------------------- 34 | -- Records of `sys_role` 35 | -- ---------------------------- 36 | BEGIN; 37 | INSERT INTO `sys_role` VALUES ('1', '0', 'admin', '管理员'), ('2', '0', 'vip', 'VIP会员'), ('3', '1', 'test', '测试'); 38 | COMMIT; 39 | 40 | SET FOREIGN_KEY_CHECKS = 1; 41 | -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/resources/sql/sys_role_permission.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:57:02 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_role_permission` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_role_permission`; 24 | CREATE TABLE `sys_role_permission` ( 25 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 26 | `permission_id` int(11) DEFAULT NULL COMMENT '权限id', 27 | KEY `role_id` (`role_id`) USING BTREE, 28 | KEY `permission_id` (`permission_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_role_permission` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_role_permission` VALUES ('1', '1'), ('1', '2'), ('2', '3'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | -------------------------------------------------------------------------------- /cas-sslogout-server/src/main/resources/sql/sys_user_role.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost 5 | Source Server Type : MySQL 6 | Source Server Version : 50719 7 | Source Host : localhost 8 | Source Database : testshiro 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50719 12 | File Encoding : utf-8 13 | 14 | Date: 07/21/2018 18:56:50 PM 15 | */ 16 | 17 | SET NAMES utf8; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for `sys_user_role` 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `sys_user_role`; 24 | CREATE TABLE `sys_user_role` ( 25 | `uid` int(11) DEFAULT NULL COMMENT '用户id', 26 | `role_id` int(11) DEFAULT NULL COMMENT '角色id', 27 | KEY `uid` (`uid`) USING BTREE, 28 | KEY `role_id` (`role_id`) USING BTREE 29 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 30 | 31 | -- ---------------------------- 32 | -- Records of `sys_user_role` 33 | -- ---------------------------- 34 | BEGIN; 35 | INSERT INTO `sys_user_role` VALUES ('1', '1'), ('2', '2'); 36 | COMMIT; 37 | 38 | SET FOREIGN_KEY_CHECKS = 1; 39 | --------------------------------------------------------------------------------