├── .gitignore ├── README.md ├── chapter1 └── lesson-1-4 │ ├── .gitignore │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ ├── Lesson14Application.java │ │ │ ├── controller │ │ │ ├── DebugController.java │ │ │ ├── HelloController.java │ │ │ └── StudentController.java │ │ │ ├── model │ │ │ └── Student.java │ │ │ └── service │ │ │ ├── DebugService.java │ │ │ └── DebugServiceImpl.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── kucw │ └── security │ └── Lesson14ApplicationTests.java ├── chapter10 ├── lesson-10-2 │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson102Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson102ApplicationTests.java ├── lesson-10-3 │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson103Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson103ApplicationTests.java ├── lesson-10-4 │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson104Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson104ApplicationTests.java ├── lesson-10-5 │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson105Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson105ApplicationTests.java └── lesson-10-6 │ ├── pom.xml │ ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson106Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ ├── dao │ │ │ │ ├── OAuth2MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── OAuth2MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── OAuth2Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── OAuth2MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MyOAuth2UserService.java │ │ │ │ ├── MyOidcUserService.java │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson106ApplicationTests.java │ └── 準備數據 │ └── 10-6 oauth2_member 數據.txt ├── chapter12 ├── lesson-12-4 │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson124Application.java │ │ │ │ ├── controller │ │ │ │ └── OrderController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson124ApplicationTests.java ├── lesson-12-5 │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson125Application.java │ │ │ │ ├── controller │ │ │ │ └── OrderController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson125ApplicationTests.java └── lesson-12-6-product │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ ├── Lesson126ProductApplication.java │ │ │ ├── controller │ │ │ └── ProductController.java │ │ │ ├── scheduler │ │ │ ├── KeycloakTokenResponse.java │ │ │ └── ProductScheduler.java │ │ │ └── security │ │ │ └── MySecurityConfig.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── kucw │ └── security │ └── Lesson126ProductApplicationTests.java ├── chapter2 ├── lesson-2-1 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson21Application.java │ │ │ │ └── controller │ │ │ │ └── MyController.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson21ApplicationTests.java ├── lesson-2-11 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson211Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MyController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson211ApplicationTests.java ├── lesson-2-12 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson212Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MyController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson212ApplicationTests.java ├── lesson-2-13 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson213Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MyController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson213ApplicationTests.java ├── lesson-2-4 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson24Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson24ApplicationTests.java ├── lesson-2-5 │ ├── .gitignore │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── kucw │ │ │ │ │ └── security │ │ │ │ │ ├── Lesson25Application.java │ │ │ │ │ ├── controller │ │ │ │ │ └── MyController.java │ │ │ │ │ ├── dao │ │ │ │ │ ├── MemberDao.java │ │ │ │ │ └── impl │ │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ │ ├── model │ │ │ │ │ └── Member.java │ │ │ │ │ ├── rowmapper │ │ │ │ │ └── MemberRowMapper.java │ │ │ │ │ └── security │ │ │ │ │ └── MySecurityConfig.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── Lesson25ApplicationTests.java │ └── 準備數據 │ │ └── 2-5 member 數據.txt ├── lesson-2-6 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson26Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson26ApplicationTests.java ├── lesson-2-7 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson27Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MyController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson27ApplicationTests.java ├── lesson-2-8 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson28Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MyController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson28ApplicationTests.java └── lesson-2-9 │ ├── .gitignore │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ ├── Lesson29Application.java │ │ │ ├── controller │ │ │ ├── MemberController.java │ │ │ └── MyController.java │ │ │ ├── dao │ │ │ ├── MemberDao.java │ │ │ └── impl │ │ │ │ └── MemberDaoImpl.java │ │ │ ├── model │ │ │ └── Member.java │ │ │ ├── rowmapper │ │ │ └── MemberRowMapper.java │ │ │ └── security │ │ │ ├── MySecurityConfig.java │ │ │ └── MyUserDetailsService.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── kucw │ └── security │ └── Lesson29ApplicationTests.java ├── chapter3 ├── lesson-3-2 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson32Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson32ApplicationTests.java ├── lesson-3-4 │ ├── .gitignore │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── kucw │ │ │ │ │ └── security │ │ │ │ │ ├── Lesson34Application.java │ │ │ │ │ ├── controller │ │ │ │ │ ├── MemberController.java │ │ │ │ │ ├── MyController.java │ │ │ │ │ └── movie │ │ │ │ │ │ └── MovieController.java │ │ │ │ │ ├── dao │ │ │ │ │ ├── MemberDao.java │ │ │ │ │ └── impl │ │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ │ ├── model │ │ │ │ │ ├── Member.java │ │ │ │ │ └── Role.java │ │ │ │ │ ├── rowmapper │ │ │ │ │ ├── MemberRowMapper.java │ │ │ │ │ └── RoleRowMapper.java │ │ │ │ │ └── security │ │ │ │ │ ├── MySecurityConfig.java │ │ │ │ │ └── MyUserDetailsService.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── Lesson34ApplicationTests.java │ └── 準備數據 │ │ ├── 3-4 RBAC 數據.txt │ │ └── 3-4 查詢語法.txt ├── lesson-3-5 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson35Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ ├── MyController.java │ │ │ │ └── movie │ │ │ │ │ └── MovieController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ ├── Member.java │ │ │ │ └── Role.java │ │ │ │ ├── rowmapper │ │ │ │ ├── MemberRowMapper.java │ │ │ │ └── RoleRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson35ApplicationTests.java ├── lesson-3-6 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson36Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ ├── MyController.java │ │ │ │ └── movie │ │ │ │ │ └── MovieController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ ├── Member.java │ │ │ │ └── Role.java │ │ │ │ ├── rowmapper │ │ │ │ ├── MemberRowMapper.java │ │ │ │ └── RoleRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson36ApplicationTests.java ├── lesson-3-7 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson37Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ ├── MyController.java │ │ │ │ └── movie │ │ │ │ │ └── MovieController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ ├── Member.java │ │ │ │ └── Role.java │ │ │ │ ├── rowmapper │ │ │ │ ├── MemberRowMapper.java │ │ │ │ └── RoleRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson37ApplicationTests.java └── lesson-3-8 │ ├── .gitignore │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ ├── Lesson38Application.java │ │ │ ├── controller │ │ │ └── MyController.java │ │ │ ├── dao │ │ │ ├── MyDao.java │ │ │ └── MyDaoImpl.java │ │ │ ├── security │ │ │ └── MySecurityConfig.java │ │ │ └── service │ │ │ ├── MyService.java │ │ │ └── MyServiceImpl.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── kucw │ └── security │ └── Lesson38ApplicationTests.java ├── chapter4 ├── lesson-4-1 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson41Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson41ApplicationTests.java ├── lesson-4-3 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson43Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ └── security │ │ │ │ ├── MyFilter1.java │ │ │ │ ├── MyFilter2.java │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson43ApplicationTests.java ├── lesson-4-4 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson44Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ └── security │ │ │ │ ├── MyFilter1.java │ │ │ │ ├── MyFilter2.java │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson44ApplicationTests.java ├── lesson-4-5 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson45Application.java │ │ │ │ ├── controller │ │ │ │ └── MyController.java │ │ │ │ └── security │ │ │ │ ├── MyFilter1.java │ │ │ │ ├── MyFilter2.java │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson45ApplicationTests.java └── lesson-4-6 │ ├── .gitignore │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ ├── Lesson46Application.java │ │ │ ├── controller │ │ │ └── MyController.java │ │ │ └── security │ │ │ ├── MyFilter1.java │ │ │ ├── MyFilter2.java │ │ │ └── MySecurityConfig.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── kucw │ └── security │ └── Lesson46ApplicationTests.java ├── chapter5 ├── lesson-5-1 │ ├── .gitignore │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── kucw │ │ │ │ │ └── security │ │ │ │ │ ├── Lesson51Application.java │ │ │ │ │ ├── controller │ │ │ │ │ ├── HelloController.java │ │ │ │ │ └── WelcomeController.java │ │ │ │ │ └── security │ │ │ │ │ └── MySecurityConfig.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── Lesson51ApplicationTests.java │ └── 前端頁面 │ │ └── cors-demo.html ├── lesson-5-2 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson52Application.java │ │ │ │ ├── controller │ │ │ │ ├── HelloController.java │ │ │ │ └── WelcomeController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson52ApplicationTests.java ├── lesson-5-3 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson53Application.java │ │ │ │ ├── controller │ │ │ │ ├── HelloController.java │ │ │ │ └── WelcomeController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson53ApplicationTests.java ├── lesson-5-4 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson54Application.java │ │ │ │ └── controller │ │ │ │ ├── HelloController.java │ │ │ │ └── WelcomeController.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson54ApplicationTests.java └── lesson-5-5 │ ├── .gitignore │ ├── Nginx設定檔 │ └── my_nginx.conf │ ├── pom.xml │ ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson55Application.java │ │ │ │ └── controller │ │ │ │ ├── HelloController.java │ │ │ │ └── WelcomeController.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson55ApplicationTests.java │ └── 前端頁面 │ └── cors-demo.html ├── chapter6 ├── lesson-6-2 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson62Application.java │ │ │ │ ├── controller │ │ │ │ ├── MyController.java │ │ │ │ └── movie │ │ │ │ │ ├── MovieController.java │ │ │ │ │ └── UserController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson62ApplicationTests.java ├── lesson-6-3 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson63Application.java │ │ │ │ ├── controller │ │ │ │ ├── MyController.java │ │ │ │ └── movie │ │ │ │ │ ├── MovieController.java │ │ │ │ │ └── UserController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson63ApplicationTests.java ├── lesson-6-5 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson65Application.java │ │ │ │ ├── controller │ │ │ │ ├── MyController.java │ │ │ │ └── movie │ │ │ │ │ ├── MovieController.java │ │ │ │ │ └── UserController.java │ │ │ │ └── security │ │ │ │ └── MySecurityConfig.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson65ApplicationTests.java └── lesson-6-6 │ ├── .gitignore │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ ├── Lesson66Application.java │ │ │ ├── controller │ │ │ ├── MyController.java │ │ │ └── movie │ │ │ │ ├── MovieController.java │ │ │ │ └── UserController.java │ │ │ └── security │ │ │ └── MySecurityConfig.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── kucw │ └── security │ └── Lesson66ApplicationTests.java ├── chapter7 ├── lesson-7-2 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson72Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MyController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ ├── Member.java │ │ │ │ └── Role.java │ │ │ │ ├── rowmapper │ │ │ │ ├── MemberRowMapper.java │ │ │ │ └── RoleRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── MyTests.java │ │ └── resources │ │ ├── application.properties │ │ ├── data.sql │ │ └── schema.sql └── lesson-7-3 │ ├── .gitignore │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ ├── Lesson73Application.java │ │ │ ├── controller │ │ │ ├── HelloController.java │ │ │ └── WelcomeController.java │ │ │ └── security │ │ │ └── MySecurityConfig.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── kucw │ └── security │ └── MyTests.java ├── chapter8 ├── lesson-8-1 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson81Application.java │ │ │ │ └── controller │ │ │ │ └── MovieController.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson81ApplicationTests.java ├── lesson-8-10 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson810Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ ├── MovieController.java │ │ │ │ └── SubscriptionController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ ├── RoleDao.java │ │ │ │ └── impl │ │ │ │ │ ├── MemberDaoImpl.java │ │ │ │ │ └── RoleDaoImpl.java │ │ │ │ ├── dto │ │ │ │ ├── SubscribeRequest.java │ │ │ │ └── UnsubscribeRequest.java │ │ │ │ ├── model │ │ │ │ ├── Member.java │ │ │ │ └── Role.java │ │ │ │ ├── rowmapper │ │ │ │ ├── MemberRowMapper.java │ │ │ │ └── RoleRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── controller │ │ │ ├── MemberControllerTest.java │ │ │ ├── MovieControllerTest.java │ │ │ └── SubscriptionControllerTest.java │ │ └── resources │ │ ├── application.properties │ │ ├── data.sql │ │ └── schema.sql ├── lesson-8-11 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson811Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ ├── MovieController.java │ │ │ │ └── SubscriptionController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ ├── RoleDao.java │ │ │ │ └── impl │ │ │ │ │ ├── MemberDaoImpl.java │ │ │ │ │ └── RoleDaoImpl.java │ │ │ │ ├── dto │ │ │ │ ├── SubscribeRequest.java │ │ │ │ └── UnsubscribeRequest.java │ │ │ │ ├── model │ │ │ │ ├── Member.java │ │ │ │ └── Role.java │ │ │ │ ├── rowmapper │ │ │ │ ├── MemberRowMapper.java │ │ │ │ └── RoleRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MyFilter.java │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── controller │ │ │ ├── MemberControllerTest.java │ │ │ ├── MovieControllerTest.java │ │ │ └── SubscriptionControllerTest.java │ │ └── resources │ │ ├── application.properties │ │ ├── data.sql │ │ └── schema.sql ├── lesson-8-12 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson812Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ ├── MovieController.java │ │ │ │ └── SubscriptionController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ ├── RoleDao.java │ │ │ │ └── impl │ │ │ │ │ ├── MemberDaoImpl.java │ │ │ │ │ └── RoleDaoImpl.java │ │ │ │ ├── dto │ │ │ │ ├── SubscribeRequest.java │ │ │ │ └── UnsubscribeRequest.java │ │ │ │ ├── model │ │ │ │ ├── Member.java │ │ │ │ └── Role.java │ │ │ │ ├── rowmapper │ │ │ │ ├── MemberRowMapper.java │ │ │ │ └── RoleRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MyFilter.java │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── controller │ │ │ ├── CorsTest.java │ │ │ ├── MemberControllerTest.java │ │ │ ├── MovieControllerTest.java │ │ │ └── SubscriptionControllerTest.java │ │ └── resources │ │ ├── application.properties │ │ ├── data.sql │ │ └── schema.sql ├── lesson-8-13 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson813Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ ├── MovieController.java │ │ │ │ └── SubscriptionController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ ├── RoleDao.java │ │ │ │ └── impl │ │ │ │ │ ├── MemberDaoImpl.java │ │ │ │ │ └── RoleDaoImpl.java │ │ │ │ ├── dto │ │ │ │ ├── SubscribeRequest.java │ │ │ │ └── UnsubscribeRequest.java │ │ │ │ ├── model │ │ │ │ ├── Member.java │ │ │ │ └── Role.java │ │ │ │ ├── rowmapper │ │ │ │ ├── MemberRowMapper.java │ │ │ │ └── RoleRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MyFilter.java │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── controller │ │ │ ├── CorsTest.java │ │ │ ├── CsrfTest.java │ │ │ ├── MemberControllerTest.java │ │ │ ├── MovieControllerTest.java │ │ │ └── SubscriptionControllerTest.java │ │ └── resources │ │ ├── application.properties │ │ ├── data.sql │ │ └── schema.sql ├── lesson-8-2 │ ├── .gitignore │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── kucw │ │ │ │ │ └── security │ │ │ │ │ ├── Lesson82Application.java │ │ │ │ │ ├── controller │ │ │ │ │ └── MovieController.java │ │ │ │ │ ├── dao │ │ │ │ │ ├── MemberDao.java │ │ │ │ │ └── impl │ │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ │ ├── model │ │ │ │ │ └── Member.java │ │ │ │ │ ├── rowmapper │ │ │ │ │ └── MemberRowMapper.java │ │ │ │ │ └── security │ │ │ │ │ ├── MySecurityConfig.java │ │ │ │ │ └── MyUserDetailsService.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── Lesson82ApplicationTests.java │ └── 準備數據 │ │ └── 8-2 member 數據.txt ├── lesson-8-3 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson83Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MovieController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson83ApplicationTests.java ├── lesson-8-4 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson84Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MovieController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson84ApplicationTests.java ├── lesson-8-5 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson85Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MovieController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson85ApplicationTests.java ├── lesson-8-6 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson86Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MovieController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ └── Member.java │ │ │ │ ├── rowmapper │ │ │ │ └── MemberRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── controller │ │ │ └── MemberControllerTest.java │ │ └── resources │ │ ├── application.properties │ │ ├── data.sql │ │ └── schema.sql ├── lesson-8-7 │ ├── .gitignore │ ├── pom.xml │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── kucw │ │ │ │ │ └── security │ │ │ │ │ ├── Lesson87Application.java │ │ │ │ │ ├── controller │ │ │ │ │ ├── MemberController.java │ │ │ │ │ └── MovieController.java │ │ │ │ │ ├── dao │ │ │ │ │ ├── MemberDao.java │ │ │ │ │ └── impl │ │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ │ ├── model │ │ │ │ │ ├── Member.java │ │ │ │ │ └── Role.java │ │ │ │ │ ├── rowmapper │ │ │ │ │ ├── MemberRowMapper.java │ │ │ │ │ └── RoleRowMapper.java │ │ │ │ │ └── security │ │ │ │ │ ├── MySecurityConfig.java │ │ │ │ │ └── MyUserDetailsService.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ └── test │ │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ └── controller │ │ │ │ └── MemberControllerTest.java │ │ │ └── resources │ │ │ ├── application.properties │ │ │ ├── data.sql │ │ │ └── schema.sql │ └── 準備數據 │ │ ├── 8-7 創建 table.txt │ │ └── 8-7 插入數據.txt ├── lesson-8-8 │ ├── .gitignore │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson88Application.java │ │ │ │ ├── controller │ │ │ │ ├── MemberController.java │ │ │ │ └── MovieController.java │ │ │ │ ├── dao │ │ │ │ ├── MemberDao.java │ │ │ │ └── impl │ │ │ │ │ └── MemberDaoImpl.java │ │ │ │ ├── model │ │ │ │ ├── Member.java │ │ │ │ └── Role.java │ │ │ │ ├── rowmapper │ │ │ │ ├── MemberRowMapper.java │ │ │ │ └── RoleRowMapper.java │ │ │ │ └── security │ │ │ │ ├── MySecurityConfig.java │ │ │ │ └── MyUserDetailsService.java │ │ └── resources │ │ │ └── application.properties │ │ └── test │ │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ └── controller │ │ │ ├── MemberControllerTest.java │ │ │ └── MovieControllerTest.java │ │ └── resources │ │ ├── application.properties │ │ ├── data.sql │ │ └── schema.sql └── lesson-8-9 │ ├── .gitignore │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ ├── Lesson89Application.java │ │ │ ├── controller │ │ │ ├── MemberController.java │ │ │ └── MovieController.java │ │ │ ├── dao │ │ │ ├── MemberDao.java │ │ │ ├── RoleDao.java │ │ │ └── impl │ │ │ │ ├── MemberDaoImpl.java │ │ │ │ └── RoleDaoImpl.java │ │ │ ├── model │ │ │ ├── Member.java │ │ │ └── Role.java │ │ │ ├── rowmapper │ │ │ ├── MemberRowMapper.java │ │ │ └── RoleRowMapper.java │ │ │ └── security │ │ │ ├── MySecurityConfig.java │ │ │ └── MyUserDetailsService.java │ └── resources │ │ └── application.properties │ └── test │ ├── java │ └── com │ │ └── kucw │ │ └── security │ │ └── controller │ │ ├── MemberControllerTest.java │ │ └── MovieControllerTest.java │ └── resources │ ├── application.properties │ ├── data.sql │ └── schema.sql └── chapter9 ├── lesson-9-11 ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ ├── Lesson911Application.java │ │ │ ├── controller │ │ │ ├── FacebookOAuthController.java │ │ │ ├── GithubOAuthController.java │ │ │ ├── GoogleOAuthController.java │ │ │ ├── LineOAuthController.java │ │ │ └── PkceGoogleOAuthController.java │ │ │ └── dto │ │ │ ├── ExchangeTokenRequest.java │ │ │ └── RefreshTokenRequest.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── kucw │ └── security │ └── Lesson911ApplicationTests.java ├── lesson-9-2 ├── .gitignore ├── Postman的API │ └── postman (oauth2) │ │ ├── archive.json │ │ └── collection │ │ └── d24f8d5b-3cd7-4243-bea0-cc5d8d835c75.json ├── pom.xml ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── kucw │ │ │ │ └── security │ │ │ │ ├── Lesson92Application.java │ │ │ │ ├── controller │ │ │ │ ├── FacebookOAuthController.java │ │ │ │ ├── GithubOAuthController.java │ │ │ │ ├── GoogleOAuthController.java │ │ │ │ ├── LineOAuthController.java │ │ │ │ └── PkceGoogleOAuthController.java │ │ │ │ └── dto │ │ │ │ ├── ExchangeTokenRequest.java │ │ │ │ └── RefreshTokenRequest.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── kucw │ │ └── security │ │ └── Lesson92ApplicationTests.java └── 前端頁面 │ └── oauth2-demo-html │ ├── oauth2-facebook-demo.html │ ├── oauth2-github-demo.html │ ├── oauth2-google-demo.html │ └── oauth2-line-demo.html ├── lesson-9-3 ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── kucw │ │ │ └── security │ │ │ ├── Lesson93Application.java │ │ │ ├── controller │ │ │ ├── FacebookOAuthController.java │ │ │ ├── GithubOAuthController.java │ │ │ ├── GoogleOAuthController.java │ │ │ ├── LineOAuthController.java │ │ │ └── PkceGoogleOAuthController.java │ │ │ └── dto │ │ │ ├── ExchangeTokenRequest.java │ │ │ └── RefreshTokenRequest.java │ └── resources │ │ └── application.properties │ └── test │ └── java │ └── com │ └── kucw │ └── security │ └── Lesson93ApplicationTests.java └── lesson-9-8 ├── .gitignore ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── kucw │ │ └── security │ │ ├── Lesson98Application.java │ │ ├── controller │ │ ├── FacebookOAuthController.java │ │ ├── GithubOAuthController.java │ │ ├── GoogleOAuthController.java │ │ ├── LineOAuthController.java │ │ └── PkceGoogleOAuthController.java │ │ └── dto │ │ ├── ExchangeTokenRequest.java │ │ └── RefreshTokenRequest.java └── resources │ └── application.properties └── test └── java └── com └── kucw └── security └── Lesson98ApplicationTests.java /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | ._.DS_Store 3 | **/.DS_Store 4 | **/._.DS_Store -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spring-security-course 2 | 3 | 這是 Hahow 線上課程「資安一把罩!Spring Security 零基礎入門」的範例程式 4 | -------------------------------------------------------------------------------- /chapter1/lesson-1-4/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter1/lesson-1-4/src/main/java/com/kucw/security/Lesson14Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson14Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson14Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter1/lesson-1-4/src/main/java/com/kucw/security/controller/DebugController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import com.kucw.security.service.DebugService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import java.util.List; 9 | 10 | @RestController 11 | public class DebugController { 12 | 13 | @Autowired 14 | private DebugService debugService; 15 | 16 | @GetMapping("/debug") 17 | public String debug() { 18 | Double number = 123 / 10.0; 19 | 20 | List nameList = debugService.getAllNames(); 21 | 22 | return "Finish debug"; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter1/lesson-1-4/src/main/java/com/kucw/security/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello Spring Boot!"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /chapter1/lesson-1-4/src/main/java/com/kucw/security/model/Student.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Student { 4 | 5 | private Integer id; 6 | private String name; 7 | 8 | public Integer getId() { 9 | return id; 10 | } 11 | 12 | public void setId(Integer id) { 13 | this.id = id; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter1/lesson-1-4/src/main/java/com/kucw/security/service/DebugService.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.service; 2 | 3 | import java.util.List; 4 | 5 | public interface DebugService { 6 | 7 | List getAllNames(); 8 | } 9 | -------------------------------------------------------------------------------- /chapter1/lesson-1-4/src/main/java/com/kucw/security/service/DebugServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.service; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | @Component 9 | public class DebugServiceImpl implements DebugService { 10 | 11 | @Override 12 | public List getAllNames() { 13 | List nameList = new ArrayList<>(); 14 | 15 | nameList.add("Judy"); 16 | nameList.add("Amy"); 17 | nameList.add("Mark"); 18 | 19 | return nameList; 20 | } 21 | } -------------------------------------------------------------------------------- /chapter1/lesson-1-4/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /chapter1/lesson-1-4/src/test/java/com/kucw/security/Lesson14ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson14ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-2/src/main/java/com/kucw/security/Lesson102Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson102Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson102Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-2/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/") 10 | public String index() { 11 | return "Hello!"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Google Social Login 2 | spring.security.oauth2.client.registration.google.client-id=592985493804-6hmrasp9iup1diu8i7i06l9oqklt1uik.apps.googleusercontent.com 3 | spring.security.oauth2.client.registration.google.client-secret=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 -------------------------------------------------------------------------------- /chapter10/lesson-10-2/src/test/java/com/kucw/security/Lesson102ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson102ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-3/src/main/java/com/kucw/security/Lesson103Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson103Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson103Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-3/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/") 10 | public String index() { 11 | return "Hello!"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-3/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Google Social Login 2 | spring.security.oauth2.client.registration.google.client-id=592985493804-6hmrasp9iup1diu8i7i06l9oqklt1uik.apps.googleusercontent.com 3 | spring.security.oauth2.client.registration.google.client-secret=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 4 | 5 | # GitHub Social Login 6 | spring.security.oauth2.client.registration.github.client-id=Ov23liye0zCsvprik4yv 7 | spring.security.oauth2.client.registration.github.client-secret=0f84f908e50acdb1c40a02385eed7a488c1757c9 -------------------------------------------------------------------------------- /chapter10/lesson-10-3/src/test/java/com/kucw/security/Lesson103ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson103ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-4/src/main/java/com/kucw/security/Lesson104Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson104Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson104Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-4/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/") 10 | public String index() { 11 | return "Hello!"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-4/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Google Social Login 2 | spring.security.oauth2.client.registration.google.client-id=592985493804-6hmrasp9iup1diu8i7i06l9oqklt1uik.apps.googleusercontent.com 3 | spring.security.oauth2.client.registration.google.client-secret=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 4 | 5 | # GitHub Social Login 6 | spring.security.oauth2.client.registration.github.client-id=Ov23liye0zCsvprik4yv 7 | spring.security.oauth2.client.registration.github.client-secret=0f84f908e50acdb1c40a02385eed7a488c1757c9 8 | 9 | # Facebook Social Login 10 | spring.security.oauth2.client.registration.facebook.client-id=2776680939176451 11 | spring.security.oauth2.client.registration.facebook.client-secret=2fb0bbf401eea02514b422bc3a020f0b -------------------------------------------------------------------------------- /chapter10/lesson-10-4/src/test/java/com/kucw/security/Lesson104ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson104ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-5/src/main/java/com/kucw/security/Lesson105Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson105Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson105Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-5/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/") 10 | public String index() { 11 | return "Hello!"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-5/src/test/java/com/kucw/security/Lesson105ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson105ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-6/src/main/java/com/kucw/security/Lesson106Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson106Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson106Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-6/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.security.core.Authentication; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class MyController { 9 | 10 | @GetMapping("/") 11 | public String index(Authentication authentication) { 12 | 13 | // 取得使用者的帳號(若使用 OAuth2 登入,會使用 providerId 的值當作帳號) 14 | String username = authentication.getName(); 15 | 16 | return "Hello " + username; 17 | } 18 | 19 | @GetMapping("/welcome") 20 | public String welcome() { 21 | return "Welcome!"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter10/lesson-10-6/src/main/java/com/kucw/security/dao/OAuth2MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.OAuth2Member; 4 | 5 | public interface OAuth2MemberDao { 6 | 7 | OAuth2Member getOAuth2Member(String provider, String providerId); 8 | 9 | Integer createOAuth2Member(OAuth2Member OAuth2Member); 10 | } 11 | -------------------------------------------------------------------------------- /chapter10/lesson-10-6/src/test/java/com/kucw/security/Lesson106ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson106ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter10/lesson-10-6/準備數據/10-6 oauth2_member 數據.txt: -------------------------------------------------------------------------------- 1 | # OAuth 2.0 社交登入 2 | CREATE DATABASE myoauth2; 3 | 4 | USE myoauth2; 5 | 6 | CREATE TABLE oauth2_member 7 | ( 8 | oauth2_member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 9 | provider VARCHAR(256) NOT NULL, 10 | provider_id VARCHAR(256) NOT NULL, 11 | name VARCHAR(256), 12 | email VARCHAR(256), 13 | access_token TEXT, 14 | expires_at TIMESTAMP 15 | ); -------------------------------------------------------------------------------- /chapter12/lesson-12-4/src/main/java/com/kucw/security/Lesson124Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson124Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson124Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter12/lesson-12-4/src/main/java/com/kucw/security/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class OrderController { 8 | 9 | @GetMapping("/order") 10 | public String order() { 11 | return "返回訂單數據"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /chapter12/lesson-12-4/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Keycloak (Authorization Server)'s public key 2 | spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:5500/realms/master/protocol/openid-connect/certs -------------------------------------------------------------------------------- /chapter12/lesson-12-4/src/test/java/com/kucw/security/Lesson124ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson124ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter12/lesson-12-5/src/main/java/com/kucw/security/Lesson125Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson125Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson125Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter12/lesson-12-5/src/main/java/com/kucw/security/controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.security.core.annotation.AuthenticationPrincipal; 4 | import org.springframework.security.oauth2.jwt.Jwt; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | public class OrderController { 10 | 11 | @GetMapping("/order") 12 | public String order(@AuthenticationPrincipal Jwt jwt) { 13 | 14 | jwt.getIssuedAt(); 15 | 16 | return "返回訂單數據"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter12/lesson-12-5/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Keycloak (Authorization Server)'s public key 2 | spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:5500/realms/master/protocol/openid-connect/certs -------------------------------------------------------------------------------- /chapter12/lesson-12-5/src/test/java/com/kucw/security/Lesson125ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson125ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter12/lesson-12-6-product/src/main/java/com/kucw/security/Lesson126ProductApplication.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.scheduling.annotation.EnableScheduling; 6 | 7 | @EnableScheduling 8 | @SpringBootApplication 9 | public class Lesson126ProductApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(Lesson126ProductApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /chapter12/lesson-12-6-product/src/main/java/com/kucw/security/controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class ProductController { 8 | 9 | @GetMapping("/product") 10 | public String product() { 11 | return "返回商品數據"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /chapter12/lesson-12-6-product/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Keycloak (Authorization Server)'s public key 2 | spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://localhost:5500/realms/master/protocol/openid-connect/certs 3 | 4 | server.port=8081 -------------------------------------------------------------------------------- /chapter12/lesson-12-6-product/src/test/java/com/kucw/security/Lesson126ProductApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson126ProductApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-1/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter2/lesson-2-1/src/main/java/com/kucw/security/Lesson21Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson21Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson21Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-1/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter2/lesson-2-1/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.security.user.name=test 2 | spring.security.user.password=123 3 | -------------------------------------------------------------------------------- /chapter2/lesson-2-1/src/test/java/com/kucw/security/Lesson21ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson21ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-11/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter2/lesson-2-11/src/main/java/com/kucw/security/Lesson211Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson211Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson211Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-11/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter2/lesson-2-11/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | Member getMemberById(Integer memberId); 8 | 9 | Member getMemberByEmail(String email); 10 | 11 | Integer createMember(Member member); 12 | } 13 | -------------------------------------------------------------------------------- /chapter2/lesson-2-11/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter2/lesson-2-11/src/test/java/com/kucw/security/Lesson211ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson211ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-12/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter2/lesson-2-12/src/main/java/com/kucw/security/Lesson212Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson212Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson212Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-12/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | Member getMemberById(Integer memberId); 8 | 9 | Member getMemberByEmail(String email); 10 | 11 | Integer createMember(Member member); 12 | } 13 | -------------------------------------------------------------------------------- /chapter2/lesson-2-12/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter2/lesson-2-12/src/test/java/com/kucw/security/Lesson212ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson212ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-13/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter2/lesson-2-13/src/main/java/com/kucw/security/Lesson213Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson213Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson213Application.class, args); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /chapter2/lesson-2-13/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | Member getMemberById(Integer memberId); 8 | 9 | Member getMemberByEmail(String email); 10 | 11 | Integer createMember(Member member); 12 | } 13 | -------------------------------------------------------------------------------- /chapter2/lesson-2-13/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter2/lesson-2-13/src/test/java/com/kucw/security/Lesson213ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson213ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-4/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter2/lesson-2-4/src/main/java/com/kucw/security/Lesson24Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson24Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson24Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-4/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter2/lesson-2-4/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter2/lesson-2-4/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter2/lesson-2-4/src/test/java/com/kucw/security/Lesson24ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson24ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-5/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter2/lesson-2-5/src/main/java/com/kucw/security/Lesson25Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson25Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson25Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-5/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter2/lesson-2-5/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | Member getMemberById(Integer memberId); 8 | 9 | Member getMemberByEmail(String email); 10 | 11 | Integer createMember(Member member); 12 | } 13 | -------------------------------------------------------------------------------- /chapter2/lesson-2-5/src/main/java/com/kucw/security/rowmapper/MemberRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Member; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class MemberRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Member mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Member member = new Member(); 16 | member.setMemberId(resultSet.getInt("member_id")); 17 | member.setEmail(resultSet.getString("email")); 18 | member.setPassword(resultSet.getString("password")); 19 | member.setName(resultSet.getString("name")); 20 | member.setAge(resultSet.getInt("age")); 21 | 22 | return member; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter2/lesson-2-5/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter2/lesson-2-5/src/test/java/com/kucw/security/Lesson25ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson25ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-5/準備數據/2-5 member 數據.txt: -------------------------------------------------------------------------------- 1 | CREATE DATABASE mysecurity; 2 | 3 | USE mysecurity; 4 | 5 | CREATE TABLE member 6 | ( 7 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 8 | email VARCHAR(256) NOT NULL UNIQUE KEY, 9 | password VARCHAR(256) NOT NULL, 10 | name VARCHAR(256) NOT NULL, 11 | age INT NOT NULL 12 | ); 13 | 14 | INSERT INTO member(email, password, name, age) VALUES ('test3@gmail.com', 333, 'Test 3', '20'); 15 | INSERT INTO member(email, password, name, age) VALUES ('test4@gmail.com', 444, 'Test 4', '30'); 16 | INSERT INTO member(email, password, name, age) VALUES ('test5@gmail.com', 555, 'Test 5', '22'); -------------------------------------------------------------------------------- /chapter2/lesson-2-6/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter2/lesson-2-6/src/main/java/com/kucw/security/Lesson26Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson26Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson26Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-6/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter2/lesson-2-6/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | Member getMemberById(Integer memberId); 8 | 9 | Member getMemberByEmail(String email); 10 | 11 | Integer createMember(Member member); 12 | } 13 | -------------------------------------------------------------------------------- /chapter2/lesson-2-6/src/main/java/com/kucw/security/rowmapper/MemberRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Member; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class MemberRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Member mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Member member = new Member(); 16 | member.setMemberId(resultSet.getInt("member_id")); 17 | member.setEmail(resultSet.getString("email")); 18 | member.setPassword(resultSet.getString("password")); 19 | member.setName(resultSet.getString("name")); 20 | member.setAge(resultSet.getInt("age")); 21 | 22 | return member; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter2/lesson-2-6/src/main/java/com/kucw/security/security/MySecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.security; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 6 | import org.springframework.security.crypto.password.NoOpPasswordEncoder; 7 | import org.springframework.security.crypto.password.PasswordEncoder; 8 | 9 | @Configuration 10 | @EnableWebSecurity 11 | public class MySecurityConfig { 12 | 13 | @Bean 14 | public PasswordEncoder passwordEncoder() { 15 | return NoOpPasswordEncoder.getInstance(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /chapter2/lesson-2-6/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter2/lesson-2-6/src/test/java/com/kucw/security/Lesson26ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson26ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-7/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter2/lesson-2-7/src/main/java/com/kucw/security/Lesson27Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson27Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson27Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-7/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter2/lesson-2-7/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | Member getMemberById(Integer memberId); 8 | 9 | Member getMemberByEmail(String email); 10 | 11 | Integer createMember(Member member); 12 | } 13 | -------------------------------------------------------------------------------- /chapter2/lesson-2-7/src/main/java/com/kucw/security/rowmapper/MemberRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Member; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class MemberRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Member mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Member member = new Member(); 16 | member.setMemberId(resultSet.getInt("member_id")); 17 | member.setEmail(resultSet.getString("email")); 18 | member.setPassword(resultSet.getString("password")); 19 | member.setName(resultSet.getString("name")); 20 | member.setAge(resultSet.getInt("age")); 21 | 22 | return member; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter2/lesson-2-7/src/main/java/com/kucw/security/security/MySecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.security; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 6 | import org.springframework.security.crypto.password.NoOpPasswordEncoder; 7 | import org.springframework.security.crypto.password.PasswordEncoder; 8 | 9 | @Configuration 10 | @EnableWebSecurity 11 | public class MySecurityConfig { 12 | 13 | @Bean 14 | public PasswordEncoder passwordEncoder() { 15 | return NoOpPasswordEncoder.getInstance(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /chapter2/lesson-2-7/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter2/lesson-2-7/src/test/java/com/kucw/security/Lesson27ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson27ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-8/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter2/lesson-2-8/src/main/java/com/kucw/security/Lesson28Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson28Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson28Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-8/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter2/lesson-2-8/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | Member getMemberById(Integer memberId); 8 | 9 | Member getMemberByEmail(String email); 10 | 11 | Integer createMember(Member member); 12 | } 13 | -------------------------------------------------------------------------------- /chapter2/lesson-2-8/src/main/java/com/kucw/security/rowmapper/MemberRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Member; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class MemberRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Member mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Member member = new Member(); 16 | member.setMemberId(resultSet.getInt("member_id")); 17 | member.setEmail(resultSet.getString("email")); 18 | member.setPassword(resultSet.getString("password")); 19 | member.setName(resultSet.getString("name")); 20 | member.setAge(resultSet.getInt("age")); 21 | 22 | return member; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter2/lesson-2-8/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter2/lesson-2-8/src/test/java/com/kucw/security/Lesson28ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson28ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-9/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter2/lesson-2-9/src/main/java/com/kucw/security/Lesson29Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson29Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson29Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter2/lesson-2-9/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter2/lesson-2-9/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | Member getMemberById(Integer memberId); 8 | 9 | Member getMemberByEmail(String email); 10 | 11 | Integer createMember(Member member); 12 | } 13 | -------------------------------------------------------------------------------- /chapter2/lesson-2-9/src/main/java/com/kucw/security/rowmapper/MemberRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Member; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class MemberRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Member mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Member member = new Member(); 16 | member.setMemberId(resultSet.getInt("member_id")); 17 | member.setEmail(resultSet.getString("email")); 18 | member.setPassword(resultSet.getString("password")); 19 | member.setName(resultSet.getString("name")); 20 | member.setAge(resultSet.getInt("age")); 21 | 22 | return member; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter2/lesson-2-9/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter2/lesson-2-9/src/test/java/com/kucw/security/Lesson29ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson29ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-2/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter3/lesson-3-2/src/main/java/com/kucw/security/Lesson32Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson32Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson32Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-2/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter3/lesson-3-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter3/lesson-3-2/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter3/lesson-3-2/src/test/java/com/kucw/security/Lesson32ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson32ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-4/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter3/lesson-3-4/src/main/java/com/kucw/security/Lesson34Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson34Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson34Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-4/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | Member getMemberById(Integer memberId); 11 | 12 | Member getMemberByEmail(String email); 13 | 14 | Integer createMember(Member member); 15 | 16 | List getRolesByMemberId(Integer memberId); 17 | } 18 | -------------------------------------------------------------------------------- /chapter3/lesson-3-4/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter3/lesson-3-4/src/main/java/com/kucw/security/rowmapper/MemberRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Member; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class MemberRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Member mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Member member = new Member(); 16 | member.setMemberId(resultSet.getInt("member_id")); 17 | member.setEmail(resultSet.getString("email")); 18 | member.setPassword(resultSet.getString("password")); 19 | member.setName(resultSet.getString("name")); 20 | member.setAge(resultSet.getInt("age")); 21 | 22 | return member; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter3/lesson-3-4/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter3/lesson-3-4/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter3/lesson-3-4/src/test/java/com/kucw/security/Lesson34ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson34ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-4/準備數據/3-4 查詢語法.txt: -------------------------------------------------------------------------------- 1 | SELECT member.member_id, member.email, role.role_name FROM member 2 | JOIN member_has_role ON member.member_id = member_has_role.member_id 3 | JOIN role ON member_has_role.role_id = role.role_id; -------------------------------------------------------------------------------- /chapter3/lesson-3-5/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter3/lesson-3-5/src/main/java/com/kucw/security/Lesson35Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson35Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson35Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-5/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | Member getMemberById(Integer memberId); 11 | 12 | Member getMemberByEmail(String email); 13 | 14 | Integer createMember(Member member); 15 | 16 | List getRolesByMemberId(Integer memberId); 17 | } 18 | -------------------------------------------------------------------------------- /chapter3/lesson-3-5/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter3/lesson-3-5/src/main/java/com/kucw/security/rowmapper/MemberRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Member; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class MemberRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Member mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Member member = new Member(); 16 | member.setMemberId(resultSet.getInt("member_id")); 17 | member.setEmail(resultSet.getString("email")); 18 | member.setPassword(resultSet.getString("password")); 19 | member.setName(resultSet.getString("name")); 20 | member.setAge(resultSet.getInt("age")); 21 | 22 | return member; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter3/lesson-3-5/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter3/lesson-3-5/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter3/lesson-3-5/src/test/java/com/kucw/security/Lesson35ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson35ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-6/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter3/lesson-3-6/src/main/java/com/kucw/security/Lesson36Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson36Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson36Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-6/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | Member getMemberById(Integer memberId); 11 | 12 | Member getMemberByEmail(String email); 13 | 14 | Integer createMember(Member member); 15 | 16 | List getRolesByMemberId(Integer memberId); 17 | } 18 | -------------------------------------------------------------------------------- /chapter3/lesson-3-6/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter3/lesson-3-6/src/main/java/com/kucw/security/rowmapper/MemberRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Member; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class MemberRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Member mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Member member = new Member(); 16 | member.setMemberId(resultSet.getInt("member_id")); 17 | member.setEmail(resultSet.getString("email")); 18 | member.setPassword(resultSet.getString("password")); 19 | member.setName(resultSet.getString("name")); 20 | member.setAge(resultSet.getInt("age")); 21 | 22 | return member; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter3/lesson-3-6/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter3/lesson-3-6/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter3/lesson-3-6/src/test/java/com/kucw/security/Lesson36ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson36ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-7/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter3/lesson-3-7/src/main/java/com/kucw/security/Lesson37Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson37Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson37Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-7/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | Member getMemberById(Integer memberId); 11 | 12 | Member getMemberByEmail(String email); 13 | 14 | Integer createMember(Member member); 15 | 16 | List getRolesByMemberId(Integer memberId); 17 | } 18 | -------------------------------------------------------------------------------- /chapter3/lesson-3-7/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter3/lesson-3-7/src/main/java/com/kucw/security/rowmapper/MemberRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Member; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class MemberRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Member mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Member member = new Member(); 16 | member.setMemberId(resultSet.getInt("member_id")); 17 | member.setEmail(resultSet.getString("email")); 18 | member.setPassword(resultSet.getString("password")); 19 | member.setName(resultSet.getString("name")); 20 | member.setAge(resultSet.getInt("age")); 21 | 22 | return member; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /chapter3/lesson-3-7/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter3/lesson-3-7/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter3/lesson-3-7/src/test/java/com/kucw/security/Lesson37ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson37ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-8/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter3/lesson-3-8/src/main/java/com/kucw/security/Lesson38Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson38Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson38Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter3/lesson-3-8/src/main/java/com/kucw/security/dao/MyDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | public interface MyDao { 4 | 5 | String getMovie(); 6 | 7 | String deleteMovie(); 8 | } 9 | -------------------------------------------------------------------------------- /chapter3/lesson-3-8/src/main/java/com/kucw/security/dao/MyDaoImpl.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import org.springframework.stereotype.Component; 4 | 5 | @Component 6 | public class MyDaoImpl implements MyDao { 7 | 8 | @Override 9 | public String getMovie() { 10 | System.out.println("執行 MyDao 的 getMovie 方法"); 11 | 12 | return "成功取得電影"; 13 | } 14 | 15 | @Override 16 | public String deleteMovie() { 17 | System.out.println("執行 MyDao 的 deleteMovie 方法"); 18 | 19 | return "成功刪除電影"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter3/lesson-3-8/src/main/java/com/kucw/security/service/MyService.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.service; 2 | 3 | public interface MyService { 4 | 5 | String getMovie(); 6 | 7 | String deleteMovie(); 8 | } 9 | -------------------------------------------------------------------------------- /chapter3/lesson-3-8/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter3/lesson-3-8/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter3/lesson-3-8/src/test/java/com/kucw/security/Lesson38ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson38ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter4/lesson-4-1/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter4/lesson-4-1/src/main/java/com/kucw/security/Lesson41Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson41Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson41Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter4/lesson-4-1/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /chapter4/lesson-4-1/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter4/lesson-4-1/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter4/lesson-4-1/src/test/java/com/kucw/security/Lesson41ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson41ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter4/lesson-4-3/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter4/lesson-4-3/src/main/java/com/kucw/security/Lesson43Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson43Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson43Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter4/lesson-4-3/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /chapter4/lesson-4-3/src/main/java/com/kucw/security/security/MyFilter1.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.security; 2 | 3 | import jakarta.servlet.*; 4 | 5 | import java.io.IOException; 6 | 7 | public class MyFilter1 implements Filter { 8 | 9 | @Override 10 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { 11 | System.out.println("執行 MyFilter1"); 12 | 13 | // 把 request 和 response 傳下去,交給下一個 Filter 繼續處理 14 | filterChain.doFilter(servletRequest, servletResponse); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /chapter4/lesson-4-3/src/main/java/com/kucw/security/security/MyFilter2.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.security; 2 | 3 | import jakarta.servlet.FilterChain; 4 | import jakarta.servlet.ServletException; 5 | import jakarta.servlet.http.HttpServletRequest; 6 | import jakarta.servlet.http.HttpServletResponse; 7 | import org.springframework.web.filter.OncePerRequestFilter; 8 | 9 | import java.io.IOException; 10 | 11 | public class MyFilter2 extends OncePerRequestFilter { 12 | 13 | @Override 14 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { 15 | System.out.println("執行 MyFilter2"); 16 | 17 | // 把 request 和 response 傳下去,交給下一個 Filter 繼續處理 18 | filterChain.doFilter(request, response); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /chapter4/lesson-4-3/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter4/lesson-4-3/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter4/lesson-4-3/src/test/java/com/kucw/security/Lesson43ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson43ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter4/lesson-4-4/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter4/lesson-4-4/src/main/java/com/kucw/security/Lesson44Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson44Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson44Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter4/lesson-4-4/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /chapter4/lesson-4-4/src/main/java/com/kucw/security/security/MyFilter1.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.security; 2 | 3 | import jakarta.servlet.*; 4 | 5 | import java.io.IOException; 6 | 7 | public class MyFilter1 implements Filter { 8 | 9 | @Override 10 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { 11 | System.out.println("執行 MyFilter1"); 12 | 13 | // 把 request 和 response 傳下去,交給下一個 Filter 繼續處理 14 | filterChain.doFilter(servletRequest, servletResponse); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /chapter4/lesson-4-4/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter4/lesson-4-4/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter4/lesson-4-4/src/test/java/com/kucw/security/Lesson44ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson44ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter4/lesson-4-5/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter4/lesson-4-5/src/main/java/com/kucw/security/Lesson45Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson45Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson45Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter4/lesson-4-5/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /chapter4/lesson-4-5/src/main/java/com/kucw/security/security/MyFilter1.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.security; 2 | 3 | import jakarta.servlet.*; 4 | 5 | import java.io.IOException; 6 | 7 | public class MyFilter1 implements Filter { 8 | 9 | @Override 10 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { 11 | System.out.println("執行 MyFilter1"); 12 | 13 | // 把 request 和 response 傳下去,交給下一個 Filter 繼續處理 14 | filterChain.doFilter(servletRequest, servletResponse); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /chapter4/lesson-4-5/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter4/lesson-4-5/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter4/lesson-4-5/src/test/java/com/kucw/security/Lesson45ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson45ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter4/lesson-4-6/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter4/lesson-4-6/src/main/java/com/kucw/security/Lesson46Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson46Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson46Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter4/lesson-4-6/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | 20 | -------------------------------------------------------------------------------- /chapter4/lesson-4-6/src/main/java/com/kucw/security/security/MyFilter1.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.security; 2 | 3 | import jakarta.servlet.*; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.io.IOException; 7 | 8 | @Component 9 | public class MyFilter1 implements Filter { 10 | 11 | @Override 12 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { 13 | System.out.println("執行 MyFilter1"); 14 | 15 | // 把 request 和 response 傳下去,交給下一個 Filter 繼續處理 16 | filterChain.doFilter(servletRequest, servletResponse); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter4/lesson-4-6/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter4/lesson-4-6/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter4/lesson-4-6/src/test/java/com/kucw/security/Lesson46ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson46ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/lesson-5-1/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter5/lesson-5-1/src/main/java/com/kucw/security/Lesson51Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson51Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson51Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/lesson-5-1/src/main/java/com/kucw/security/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @RequestMapping("/hello") 10 | public String hello() { 11 | System.out.println("執行 /hello"); 12 | return "Hello!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter5/lesson-5-1/src/main/java/com/kucw/security/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class WelcomeController { 8 | 9 | @RequestMapping("/welcome") 10 | public String welcome() { 11 | System.out.println("執行 /welcome"); 12 | return "Welcome!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter5/lesson-5-1/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter5/lesson-5-1/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter5/lesson-5-1/src/test/java/com/kucw/security/Lesson51ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson51ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/lesson-5-2/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter5/lesson-5-2/src/main/java/com/kucw/security/Lesson52Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson52Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson52Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/lesson-5-2/src/main/java/com/kucw/security/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @RequestMapping("/hello") 10 | public String hello() { 11 | System.out.println("執行 /hello"); 12 | return "Hello!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter5/lesson-5-2/src/main/java/com/kucw/security/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class WelcomeController { 8 | 9 | @RequestMapping("/welcome") 10 | public String welcome() { 11 | System.out.println("執行 /welcome"); 12 | return "Welcome!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter5/lesson-5-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter5/lesson-5-2/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter5/lesson-5-2/src/test/java/com/kucw/security/Lesson52ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson52ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/lesson-5-3/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter5/lesson-5-3/src/main/java/com/kucw/security/Lesson53Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson53Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson53Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/lesson-5-3/src/main/java/com/kucw/security/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @RequestMapping("/hello") 10 | public String hello() { 11 | System.out.println("執行 /hello"); 12 | return "Hello!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter5/lesson-5-3/src/main/java/com/kucw/security/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class WelcomeController { 8 | 9 | @RequestMapping("/welcome") 10 | public String welcome() { 11 | System.out.println("執行 /welcome"); 12 | return "Welcome!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter5/lesson-5-3/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter5/lesson-5-3/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter5/lesson-5-3/src/test/java/com/kucw/security/Lesson53ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson53ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/lesson-5-4/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter5/lesson-5-4/src/main/java/com/kucw/security/Lesson54Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson54Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson54Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/lesson-5-4/src/main/java/com/kucw/security/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.CrossOrigin; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @CrossOrigin(origins = "*") 8 | @RestController 9 | public class HelloController { 10 | 11 | @RequestMapping("/hello") 12 | public String hello() { 13 | System.out.println("執行 /hello"); 14 | return "Hello!"; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /chapter5/lesson-5-4/src/main/java/com/kucw/security/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class WelcomeController { 8 | 9 | @RequestMapping("/welcome") 10 | public String welcome() { 11 | System.out.println("執行 /welcome"); 12 | return "Welcome!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter5/lesson-5-4/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter5/lesson-5-4/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter5/lesson-5-4/src/test/java/com/kucw/security/Lesson54ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson54ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/lesson-5-5/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter5/lesson-5-5/Nginx設定檔/my_nginx.conf: -------------------------------------------------------------------------------- 1 | events { 2 | worker_connections 1024; 3 | } 4 | 5 | http { 6 | server { 7 | # 指定 Nginx 要 listen 的 port 8 | listen 222; 9 | server_name localhost; 10 | 11 | location / { 12 | # 設定 CORS 跨域相關的 header 13 | add_header Access-Control-Allow-Origin '*' always; 14 | add_header Access-Control-Allow-Headers '*'; 15 | add_header Access-Control-Allow-Methods '*'; 16 | 17 | # for pre-flight request 18 | if ($request_method = 'OPTIONS') { 19 | return 204; 20 | } 21 | 22 | # 轉發請求到 Spring Boot 程式 23 | proxy_pass http://host.docker.internal:8080; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /chapter5/lesson-5-5/src/main/java/com/kucw/security/Lesson55Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson55Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson55Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter5/lesson-5-5/src/main/java/com/kucw/security/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.CrossOrigin; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class HelloController { 9 | 10 | @RequestMapping("/hello") 11 | public String hello() { 12 | System.out.println("執行 /hello"); 13 | return "Hello!"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /chapter5/lesson-5-5/src/main/java/com/kucw/security/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class WelcomeController { 8 | 9 | @RequestMapping("/welcome") 10 | public String welcome() { 11 | System.out.println("執行 /welcome"); 12 | return "Welcome!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter5/lesson-5-5/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter5/lesson-5-5/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter5/lesson-5-5/src/test/java/com/kucw/security/Lesson55ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson55ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter6/lesson-6-2/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter6/lesson-6-2/src/main/java/com/kucw/security/Lesson62Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson62Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson62Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter6/lesson-6-2/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class MyController { 8 | 9 | @GetMapping("/hello") 10 | public String hello() { 11 | return "Hello!"; 12 | } 13 | 14 | @GetMapping("/welcome") 15 | public String welcome() { 16 | return "Welcome!"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /chapter6/lesson-6-2/src/main/java/com/kucw/security/controller/movie/MovieController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller.movie; 2 | 3 | import org.springframework.web.bind.annotation.*; 4 | 5 | @RestController 6 | public class MovieController { 7 | 8 | @GetMapping("/getMovie") 9 | public String getMovie() { 10 | return "取得電影"; 11 | } 12 | 13 | @PostMapping("/createMovie") 14 | public String createMovie() { 15 | return "新增電影"; 16 | } 17 | 18 | @PutMapping("/updateMovie") 19 | public String updateMovie() { 20 | return "修改電影"; 21 | } 22 | 23 | @DeleteMapping("/deleteMovie") 24 | public String deleteMovie() { 25 | return "刪除電影"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter6/lesson-6-2/src/main/java/com/kucw/security/controller/movie/UserController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller.movie; 2 | 3 | import org.springframework.web.bind.annotation.PostMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class UserController { 8 | 9 | @PostMapping("/register") 10 | public String register() { 11 | return "註冊新帳號"; 12 | } 13 | 14 | @PostMapping("/userLogin") 15 | public String userLogin() { 16 | return "登入"; 17 | } 18 | } -------------------------------------------------------------------------------- /chapter6/lesson-6-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter6/lesson-6-2/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter6/lesson-6-2/src/test/java/com/kucw/security/Lesson62ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson62ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter6/lesson-6-3/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter6/lesson-6-3/src/main/java/com/kucw/security/Lesson63Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson63Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson63Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter6/lesson-6-3/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.PostMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class MyController { 9 | 10 | @GetMapping("/hello") 11 | public String hello() { 12 | return "Hello!"; 13 | } 14 | 15 | @PostMapping("/welcome") 16 | public String welcome() { 17 | return "Welcome!"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /chapter6/lesson-6-3/src/main/java/com/kucw/security/controller/movie/MovieController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller.movie; 2 | 3 | import org.springframework.web.bind.annotation.*; 4 | 5 | @RestController 6 | public class MovieController { 7 | 8 | @GetMapping("/getMovie") 9 | public String getMovie() { 10 | return "取得電影"; 11 | } 12 | 13 | @PostMapping("/createMovie") 14 | public String createMovie() { 15 | return "新增電影"; 16 | } 17 | 18 | @PutMapping("/updateMovie") 19 | public String updateMovie() { 20 | return "修改電影"; 21 | } 22 | 23 | @DeleteMapping("/deleteMovie") 24 | public String deleteMovie() { 25 | return "刪除電影"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter6/lesson-6-3/src/main/java/com/kucw/security/controller/movie/UserController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller.movie; 2 | 3 | import org.springframework.web.bind.annotation.PostMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class UserController { 8 | 9 | @PostMapping("/register") 10 | public String register() { 11 | return "註冊新帳號"; 12 | } 13 | 14 | @PostMapping("/userLogin") 15 | public String userLogin() { 16 | return "登入"; 17 | } 18 | } -------------------------------------------------------------------------------- /chapter6/lesson-6-3/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter6/lesson-6-3/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter6/lesson-6-3/src/test/java/com/kucw/security/Lesson63ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson63ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter6/lesson-6-5/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter6/lesson-6-5/src/main/java/com/kucw/security/Lesson65Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson65Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson65Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter6/lesson-6-5/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.PostMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class MyController { 9 | 10 | @GetMapping("/hello") 11 | public String hello() { 12 | return "Hello!"; 13 | } 14 | 15 | @PostMapping("/welcome") 16 | public String welcome() { 17 | return "Welcome!"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /chapter6/lesson-6-5/src/main/java/com/kucw/security/controller/movie/MovieController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller.movie; 2 | 3 | import org.springframework.web.bind.annotation.*; 4 | 5 | @RestController 6 | public class MovieController { 7 | 8 | @GetMapping("/getMovie") 9 | public String getMovie() { 10 | return "取得電影"; 11 | } 12 | 13 | @PostMapping("/createMovie") 14 | public String createMovie() { 15 | return "新增電影"; 16 | } 17 | 18 | @PutMapping("/updateMovie") 19 | public String updateMovie() { 20 | return "修改電影"; 21 | } 22 | 23 | @DeleteMapping("/deleteMovie") 24 | public String deleteMovie() { 25 | return "刪除電影"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter6/lesson-6-5/src/main/java/com/kucw/security/controller/movie/UserController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller.movie; 2 | 3 | import org.springframework.web.bind.annotation.PostMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class UserController { 8 | 9 | @PostMapping("/register") 10 | public String register() { 11 | return "註冊新帳號"; 12 | } 13 | 14 | @PostMapping("/userLogin") 15 | public String userLogin() { 16 | return "登入"; 17 | } 18 | } -------------------------------------------------------------------------------- /chapter6/lesson-6-5/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter6/lesson-6-5/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter6/lesson-6-5/src/test/java/com/kucw/security/Lesson65ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson65ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter6/lesson-6-6/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter6/lesson-6-6/src/main/java/com/kucw/security/Lesson66Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson66Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson66Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter6/lesson-6-6/src/main/java/com/kucw/security/controller/MyController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.GetMapping; 4 | import org.springframework.web.bind.annotation.PostMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | @RestController 8 | public class MyController { 9 | 10 | @GetMapping("/hello") 11 | public String hello() { 12 | return "Hello!"; 13 | } 14 | 15 | @PostMapping("/welcome") 16 | public String welcome() { 17 | return "Welcome!"; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /chapter6/lesson-6-6/src/main/java/com/kucw/security/controller/movie/MovieController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller.movie; 2 | 3 | import org.springframework.web.bind.annotation.*; 4 | 5 | @RestController 6 | public class MovieController { 7 | 8 | @GetMapping("/getMovie") 9 | public String getMovie() { 10 | return "取得電影"; 11 | } 12 | 13 | @PostMapping("/createMovie") 14 | public String createMovie() { 15 | return "新增電影"; 16 | } 17 | 18 | @PutMapping("/updateMovie") 19 | public String updateMovie() { 20 | return "修改電影"; 21 | } 22 | 23 | @DeleteMapping("/deleteMovie") 24 | public String deleteMovie() { 25 | return "刪除電影"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /chapter6/lesson-6-6/src/main/java/com/kucw/security/controller/movie/UserController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller.movie; 2 | 3 | import org.springframework.web.bind.annotation.PostMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class UserController { 8 | 9 | @PostMapping("/register") 10 | public String register() { 11 | return "註冊新帳號"; 12 | } 13 | 14 | @PostMapping("/userLogin") 15 | public String userLogin() { 16 | return "登入"; 17 | } 18 | } -------------------------------------------------------------------------------- /chapter6/lesson-6-6/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter6/lesson-6-6/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter6/lesson-6-6/src/test/java/com/kucw/security/Lesson66ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson66ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter7/lesson-7-2/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter7/lesson-7-2/src/main/java/com/kucw/security/Lesson72Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson72Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson72Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter7/lesson-7-2/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | Member getMemberById(Integer memberId); 11 | 12 | Member getMemberByEmail(String email); 13 | 14 | Integer createMember(Member member); 15 | 16 | List getRolesByMemberId(Integer memberId); 17 | } 18 | -------------------------------------------------------------------------------- /chapter7/lesson-7-2/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter7/lesson-7-2/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter7/lesson-7-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mysecurity?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter7/lesson-7-2/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | # H2 database connection 2 | spring.datasource.driver-class-name=org.h2.Driver 3 | spring.datasource.url=jdbc:h2:mem:testdb 4 | spring.datasource.username=sa 5 | spring.datasource.password=sa -------------------------------------------------------------------------------- /chapter7/lesson-7-2/src/test/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS member 2 | ( 3 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 4 | email VARCHAR(256) NOT NULL UNIQUE, 5 | password VARCHAR(256) NOT NULL, 6 | name VARCHAR(256) NOT NULL, 7 | age INT NOT NULL 8 | ); 9 | 10 | CREATE TABLE IF NOT EXISTS role 11 | ( 12 | role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 13 | role_name VARCHAR(256) NOT NULL UNIQUE 14 | ); 15 | 16 | CREATE TABLE IF NOT EXISTS member_has_role 17 | ( 18 | member_has_role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 19 | member_id INT NOT NULL, 20 | role_id INT NOT NULL 21 | ); -------------------------------------------------------------------------------- /chapter7/lesson-7-3/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter7/lesson-7-3/src/main/java/com/kucw/security/Lesson73Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson73Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson73Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter7/lesson-7-3/src/main/java/com/kucw/security/controller/HelloController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloController { 8 | 9 | @RequestMapping("/hello") 10 | public String hello() { 11 | System.out.println("執行 /hello"); 12 | return "Hello!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter7/lesson-7-3/src/main/java/com/kucw/security/controller/WelcomeController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class WelcomeController { 8 | 9 | @RequestMapping("/welcome") 10 | public String welcome() { 11 | System.out.println("執行 /welcome"); 12 | return "Welcome!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter7/lesson-7-3/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter7/lesson-7-3/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter8/lesson-8-1/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-1/src/main/java/com/kucw/security/Lesson81Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson81Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson81Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-1/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter8/lesson-8-1/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter8/lesson-8-1/src/test/java/com/kucw/security/Lesson81ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson81ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-10/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-10/src/main/java/com/kucw/security/Lesson810Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson810Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson810Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-10/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | // 基本 Member 操作 11 | Member getMemberByEmail(String email); 12 | 13 | Integer createMember(Member member); 14 | 15 | // 權限相關 16 | List getRolesByMemberId(Integer memberId); 17 | 18 | void addRoleForMemberId(Integer memberId, Role role); 19 | 20 | void removeRoleFromMemberId(Integer memberId, Role role); 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-10/src/main/java/com/kucw/security/dao/RoleDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Role; 4 | 5 | public interface RoleDao { 6 | 7 | Role getRoleByName(String roleName); 8 | } 9 | -------------------------------------------------------------------------------- /chapter8/lesson-8-10/src/main/java/com/kucw/security/dto/SubscribeRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class SubscribeRequest { 4 | 5 | private Integer memberId; 6 | 7 | public Integer getMemberId() { 8 | return memberId; 9 | } 10 | 11 | public void setMemberId(Integer memberId) { 12 | this.memberId = memberId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter8/lesson-8-10/src/main/java/com/kucw/security/dto/UnsubscribeRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class UnsubscribeRequest { 4 | 5 | private Integer memberId; 6 | 7 | public Integer getMemberId() { 8 | return memberId; 9 | } 10 | 11 | public void setMemberId(Integer memberId) { 12 | this.memberId = memberId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter8/lesson-8-10/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter8/lesson-8-10/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-10/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-10/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.h2.Driver 2 | spring.datasource.url=jdbc:h2:mem:testdb 3 | spring.datasource.username=sa 4 | spring.datasource.password=sa -------------------------------------------------------------------------------- /chapter8/lesson-8-10/src/test/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS member 2 | ( 3 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 4 | email VARCHAR(256) NOT NULL UNIQUE, 5 | password VARCHAR(256) NOT NULL, 6 | name VARCHAR(256) NOT NULL, 7 | age INT NOT NULL 8 | ); 9 | 10 | CREATE TABLE IF NOT EXISTS role 11 | ( 12 | role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 13 | role_name VARCHAR(256) NOT NULL 14 | ); 15 | 16 | CREATE TABLE IF NOT EXISTS member_has_role 17 | ( 18 | member_has_role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 19 | member_id INT NOT NULL, 20 | role_id INT NOT NULL 21 | ); 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-11/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-11/src/main/java/com/kucw/security/Lesson811Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson811Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson811Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-11/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | // 基本 Member 操作 11 | Member getMemberByEmail(String email); 12 | 13 | Integer createMember(Member member); 14 | 15 | // 權限相關 16 | List getRolesByMemberId(Integer memberId); 17 | 18 | void addRoleForMemberId(Integer memberId, Role role); 19 | 20 | void removeRoleFromMemberId(Integer memberId, Role role); 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-11/src/main/java/com/kucw/security/dao/RoleDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Role; 4 | 5 | public interface RoleDao { 6 | 7 | Role getRoleByName(String roleName); 8 | } 9 | -------------------------------------------------------------------------------- /chapter8/lesson-8-11/src/main/java/com/kucw/security/dto/SubscribeRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class SubscribeRequest { 4 | 5 | private Integer memberId; 6 | 7 | public Integer getMemberId() { 8 | return memberId; 9 | } 10 | 11 | public void setMemberId(Integer memberId) { 12 | this.memberId = memberId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter8/lesson-8-11/src/main/java/com/kucw/security/dto/UnsubscribeRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class UnsubscribeRequest { 4 | 5 | private Integer memberId; 6 | 7 | public Integer getMemberId() { 8 | return memberId; 9 | } 10 | 11 | public void setMemberId(Integer memberId) { 12 | this.memberId = memberId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter8/lesson-8-11/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter8/lesson-8-11/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-11/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-11/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.h2.Driver 2 | spring.datasource.url=jdbc:h2:mem:testdb 3 | spring.datasource.username=sa 4 | spring.datasource.password=sa -------------------------------------------------------------------------------- /chapter8/lesson-8-11/src/test/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS member 2 | ( 3 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 4 | email VARCHAR(256) NOT NULL UNIQUE, 5 | password VARCHAR(256) NOT NULL, 6 | name VARCHAR(256) NOT NULL, 7 | age INT NOT NULL 8 | ); 9 | 10 | CREATE TABLE IF NOT EXISTS role 11 | ( 12 | role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 13 | role_name VARCHAR(256) NOT NULL 14 | ); 15 | 16 | CREATE TABLE IF NOT EXISTS member_has_role 17 | ( 18 | member_has_role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 19 | member_id INT NOT NULL, 20 | role_id INT NOT NULL 21 | ); 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-12/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-12/src/main/java/com/kucw/security/Lesson812Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson812Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson812Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-12/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | // 基本 Member 操作 11 | Member getMemberByEmail(String email); 12 | 13 | Integer createMember(Member member); 14 | 15 | // 權限相關 16 | List getRolesByMemberId(Integer memberId); 17 | 18 | void addRoleForMemberId(Integer memberId, Role role); 19 | 20 | void removeRoleFromMemberId(Integer memberId, Role role); 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-12/src/main/java/com/kucw/security/dao/RoleDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Role; 4 | 5 | public interface RoleDao { 6 | 7 | Role getRoleByName(String roleName); 8 | } 9 | -------------------------------------------------------------------------------- /chapter8/lesson-8-12/src/main/java/com/kucw/security/dto/SubscribeRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class SubscribeRequest { 4 | 5 | private Integer memberId; 6 | 7 | public Integer getMemberId() { 8 | return memberId; 9 | } 10 | 11 | public void setMemberId(Integer memberId) { 12 | this.memberId = memberId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter8/lesson-8-12/src/main/java/com/kucw/security/dto/UnsubscribeRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class UnsubscribeRequest { 4 | 5 | private Integer memberId; 6 | 7 | public Integer getMemberId() { 8 | return memberId; 9 | } 10 | 11 | public void setMemberId(Integer memberId) { 12 | this.memberId = memberId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter8/lesson-8-12/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter8/lesson-8-12/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-12/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-12/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.h2.Driver 2 | spring.datasource.url=jdbc:h2:mem:testdb 3 | spring.datasource.username=sa 4 | spring.datasource.password=sa -------------------------------------------------------------------------------- /chapter8/lesson-8-12/src/test/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS member 2 | ( 3 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 4 | email VARCHAR(256) NOT NULL UNIQUE, 5 | password VARCHAR(256) NOT NULL, 6 | name VARCHAR(256) NOT NULL, 7 | age INT NOT NULL 8 | ); 9 | 10 | CREATE TABLE IF NOT EXISTS role 11 | ( 12 | role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 13 | role_name VARCHAR(256) NOT NULL 14 | ); 15 | 16 | CREATE TABLE IF NOT EXISTS member_has_role 17 | ( 18 | member_has_role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 19 | member_id INT NOT NULL, 20 | role_id INT NOT NULL 21 | ); 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-13/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-13/src/main/java/com/kucw/security/Lesson813Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson813Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson813Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-13/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | // 基本 Member 操作 11 | Member getMemberByEmail(String email); 12 | 13 | Integer createMember(Member member); 14 | 15 | // 權限相關 16 | List getRolesByMemberId(Integer memberId); 17 | 18 | void addRoleForMemberId(Integer memberId, Role role); 19 | 20 | void removeRoleFromMemberId(Integer memberId, Role role); 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-13/src/main/java/com/kucw/security/dao/RoleDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Role; 4 | 5 | public interface RoleDao { 6 | 7 | Role getRoleByName(String roleName); 8 | } 9 | -------------------------------------------------------------------------------- /chapter8/lesson-8-13/src/main/java/com/kucw/security/dto/SubscribeRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class SubscribeRequest { 4 | 5 | private Integer memberId; 6 | 7 | public Integer getMemberId() { 8 | return memberId; 9 | } 10 | 11 | public void setMemberId(Integer memberId) { 12 | this.memberId = memberId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter8/lesson-8-13/src/main/java/com/kucw/security/dto/UnsubscribeRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class UnsubscribeRequest { 4 | 5 | private Integer memberId; 6 | 7 | public Integer getMemberId() { 8 | return memberId; 9 | } 10 | 11 | public void setMemberId(Integer memberId) { 12 | this.memberId = memberId; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter8/lesson-8-13/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter8/lesson-8-13/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-13/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-13/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.h2.Driver 2 | spring.datasource.url=jdbc:h2:mem:testdb 3 | spring.datasource.username=sa 4 | spring.datasource.password=sa -------------------------------------------------------------------------------- /chapter8/lesson-8-13/src/test/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS member 2 | ( 3 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 4 | email VARCHAR(256) NOT NULL UNIQUE, 5 | password VARCHAR(256) NOT NULL, 6 | name VARCHAR(256) NOT NULL, 7 | age INT NOT NULL 8 | ); 9 | 10 | CREATE TABLE IF NOT EXISTS role 11 | ( 12 | role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 13 | role_name VARCHAR(256) NOT NULL 14 | ); 15 | 16 | CREATE TABLE IF NOT EXISTS member_has_role 17 | ( 18 | member_has_role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 19 | member_id INT NOT NULL, 20 | role_id INT NOT NULL 21 | ); 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-2/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-2/src/main/java/com/kucw/security/Lesson82Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson82Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson82Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-2/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | // 基本 Member 操作 8 | Member getMemberByEmail(String email); 9 | } 10 | -------------------------------------------------------------------------------- /chapter8/lesson-8-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-2/src/test/java/com/kucw/security/Lesson82ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson82ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-2/準備數據/8-2 member 數據.txt: -------------------------------------------------------------------------------- 1 | -- 儲存會員的數據 2 | CREATE TABLE member 3 | ( 4 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 5 | email VARCHAR(256) NOT NULL UNIQUE KEY, 6 | password VARCHAR(256) NOT NULL, 7 | name VARCHAR(256) NOT NULL, 8 | age INT NOT NULL 9 | ); 10 | 11 | INSERT INTO member(email, password, name, age) VALUES ('test1@gmail.com', '111', 'Test 1', '20'); 12 | -------------------------------------------------------------------------------- /chapter8/lesson-8-3/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-3/src/main/java/com/kucw/security/Lesson83Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson83Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson83Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-3/src/main/java/com/kucw/security/controller/MemberController.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.controller; 2 | 3 | import com.kucw.security.dao.MemberDao; 4 | import com.kucw.security.model.Member; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.PostMapping; 7 | import org.springframework.web.bind.annotation.RequestBody; 8 | import org.springframework.web.bind.annotation.RestController; 9 | 10 | @RestController 11 | public class MemberController { 12 | 13 | @Autowired 14 | private MemberDao memberDao; 15 | 16 | @PostMapping("/register") 17 | public String register(@RequestBody Member member) { 18 | // 省略參數檢查 (ex: email 是否被註冊過) 19 | 20 | // 在資料庫中插入 Member 數據 21 | Integer memberId = memberDao.createMember(member); 22 | 23 | return "註冊成功"; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /chapter8/lesson-8-3/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | // 基本 Member 操作 8 | Member getMemberByEmail(String email); 9 | 10 | Integer createMember(Member member); 11 | } 12 | -------------------------------------------------------------------------------- /chapter8/lesson-8-3/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-3/src/test/java/com/kucw/security/Lesson83ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson83ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-4/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-4/src/main/java/com/kucw/security/Lesson84Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson84Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson84Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-4/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | // 基本 Member 操作 8 | Member getMemberByEmail(String email); 9 | 10 | Integer createMember(Member member); 11 | } 12 | -------------------------------------------------------------------------------- /chapter8/lesson-8-4/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-4/src/test/java/com/kucw/security/Lesson84ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson84ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-5/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-5/src/main/java/com/kucw/security/Lesson85Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson85Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson85Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-5/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | // 基本 Member 操作 8 | Member getMemberByEmail(String email); 9 | 10 | Integer createMember(Member member); 11 | } 12 | -------------------------------------------------------------------------------- /chapter8/lesson-8-5/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-5/src/test/java/com/kucw/security/Lesson85ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson85ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-6/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-6/src/main/java/com/kucw/security/Lesson86Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson86Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson86Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-6/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | 5 | public interface MemberDao { 6 | 7 | // 基本 Member 操作 8 | Member getMemberByEmail(String email); 9 | 10 | Integer createMember(Member member); 11 | } 12 | -------------------------------------------------------------------------------- /chapter8/lesson-8-6/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-6/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.h2.Driver 2 | spring.datasource.url=jdbc:h2:mem:testdb 3 | spring.datasource.username=sa 4 | spring.datasource.password=sa -------------------------------------------------------------------------------- /chapter8/lesson-8-6/src/test/resources/data.sql: -------------------------------------------------------------------------------- 1 | -- 密碼的值為「帳號去掉 @gmail.com」,例如 admin@gmail.com 的密碼為 admin 2 | INSERT INTO member(email, password, name, age) VALUES ('admin@gmail.com', '$2a$10$DuMH/aNBaYtHT0j/b2swG.0Z7eYJ8Sckw06PSdbY4Kqy4PzZxQJeu', 'Admin', '20'); 3 | INSERT INTO member(email, password, name, age) VALUES ('normal@gmail.com', '$2a$10$B/OtT9gtlgsh/w8tdO.ISeFHNNzcILIgRuh2vDwFRUSPGRC.WqWRq', 'Normal Member', '30'); 4 | INSERT INTO member(email, password, name, age) VALUES ('vip@gmail.com', '$2a$10$/cAcYaD3L4cvf09pC4YwkOB.KHPi.JzAXG1qoqtTVniaOeDog5Atm', 'VIP Member', '22'); 5 | INSERT INTO member(email, password, name, age) VALUES ('movie-manager@gmail.com', '$2a$10$4ygMq.sezGuSU7UxNPiVwefcWSVZq17z98MrTK1KhsO2AMQU1qbDa', 'Movie Manager', '25'); 6 | -------------------------------------------------------------------------------- /chapter8/lesson-8-6/src/test/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS member 2 | ( 3 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 4 | email VARCHAR(256) NOT NULL UNIQUE, 5 | password VARCHAR(256) NOT NULL, 6 | name VARCHAR(256) NOT NULL, 7 | age INT NOT NULL 8 | ); 9 | -------------------------------------------------------------------------------- /chapter8/lesson-8-7/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-7/src/main/java/com/kucw/security/Lesson87Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson87Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson87Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-7/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | // 基本 Member 操作 11 | Member getMemberByEmail(String email); 12 | 13 | Integer createMember(Member member); 14 | 15 | // 權限相關 16 | List getRolesByMemberId(Integer memberId); 17 | } 18 | -------------------------------------------------------------------------------- /chapter8/lesson-8-7/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter8/lesson-8-7/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-7/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-7/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.h2.Driver 2 | spring.datasource.url=jdbc:h2:mem:testdb 3 | spring.datasource.username=sa 4 | spring.datasource.password=sa -------------------------------------------------------------------------------- /chapter8/lesson-8-7/src/test/resources/data.sql: -------------------------------------------------------------------------------- 1 | -- 密碼的值為「帳號去掉 @gmail.com」,例如 admin@gmail.com 的密碼為 admin 2 | INSERT INTO member(email, password, name, age) VALUES ('admin@gmail.com', '$2a$10$DuMH/aNBaYtHT0j/b2swG.0Z7eYJ8Sckw06PSdbY4Kqy4PzZxQJeu', 'Admin', '20'); 3 | INSERT INTO member(email, password, name, age) VALUES ('normal@gmail.com', '$2a$10$B/OtT9gtlgsh/w8tdO.ISeFHNNzcILIgRuh2vDwFRUSPGRC.WqWRq', 'Normal Member', '30'); 4 | INSERT INTO member(email, password, name, age) VALUES ('vip@gmail.com', '$2a$10$/cAcYaD3L4cvf09pC4YwkOB.KHPi.JzAXG1qoqtTVniaOeDog5Atm', 'VIP Member', '22'); 5 | INSERT INTO member(email, password, name, age) VALUES ('movie-manager@gmail.com', '$2a$10$4ygMq.sezGuSU7UxNPiVwefcWSVZq17z98MrTK1KhsO2AMQU1qbDa', 'Movie Manager', '25'); 6 | -------------------------------------------------------------------------------- /chapter8/lesson-8-7/src/test/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS member 2 | ( 3 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 4 | email VARCHAR(256) NOT NULL UNIQUE, 5 | password VARCHAR(256) NOT NULL, 6 | name VARCHAR(256) NOT NULL, 7 | age INT NOT NULL 8 | ); 9 | -------------------------------------------------------------------------------- /chapter8/lesson-8-7/準備數據/8-7 創建 table.txt: -------------------------------------------------------------------------------- 1 | CREATE TABLE member 2 | ( 3 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 4 | email VARCHAR(256) NOT NULL UNIQUE KEY, 5 | password VARCHAR(256) NOT NULL, 6 | name VARCHAR(256) NOT NULL, 7 | age INT NOT NULL 8 | ); 9 | 10 | CREATE TABLE role 11 | ( 12 | role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 13 | role_name VARCHAR(256) NOT NULL 14 | ); 15 | 16 | CREATE TABLE member_has_role 17 | ( 18 | member_has_role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 19 | member_id INT NOT NULL, 20 | role_id INT NOT NULL 21 | ); 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-8/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-8/src/main/java/com/kucw/security/Lesson88Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson88Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson88Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-8/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | // 基本 Member 操作 11 | Member getMemberByEmail(String email); 12 | 13 | Integer createMember(Member member); 14 | 15 | // 權限相關 16 | List getRolesByMemberId(Integer memberId); 17 | } 18 | -------------------------------------------------------------------------------- /chapter8/lesson-8-8/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter8/lesson-8-8/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-8/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-8/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.h2.Driver 2 | spring.datasource.url=jdbc:h2:mem:testdb 3 | spring.datasource.username=sa 4 | spring.datasource.password=sa -------------------------------------------------------------------------------- /chapter8/lesson-8-8/src/test/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS member 2 | ( 3 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 4 | email VARCHAR(256) NOT NULL UNIQUE, 5 | password VARCHAR(256) NOT NULL, 6 | name VARCHAR(256) NOT NULL, 7 | age INT NOT NULL 8 | ); 9 | 10 | CREATE TABLE IF NOT EXISTS role 11 | ( 12 | role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 13 | role_name VARCHAR(256) NOT NULL 14 | ); 15 | 16 | CREATE TABLE IF NOT EXISTS member_has_role 17 | ( 18 | member_has_role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 19 | member_id INT NOT NULL, 20 | role_id INT NOT NULL 21 | ); 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-9/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter8/lesson-8-9/src/main/java/com/kucw/security/Lesson89Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson89Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson89Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter8/lesson-8-9/src/main/java/com/kucw/security/dao/MemberDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Member; 4 | import com.kucw.security.model.Role; 5 | 6 | import java.util.List; 7 | 8 | public interface MemberDao { 9 | 10 | // 基本 Member 操作 11 | Member getMemberByEmail(String email); 12 | 13 | Integer createMember(Member member); 14 | 15 | // 權限相關 16 | List getRolesByMemberId(Integer memberId); 17 | 18 | void addRoleForMemberId(Integer memberId, Role role); 19 | } 20 | -------------------------------------------------------------------------------- /chapter8/lesson-8-9/src/main/java/com/kucw/security/dao/RoleDao.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dao; 2 | 3 | import com.kucw.security.model.Role; 4 | 5 | public interface RoleDao { 6 | 7 | Role getRoleByName(String roleName); 8 | } 9 | -------------------------------------------------------------------------------- /chapter8/lesson-8-9/src/main/java/com/kucw/security/model/Role.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.model; 2 | 3 | public class Role { 4 | 5 | private Integer roleId; 6 | private String roleName; 7 | 8 | public Integer getRoleId() { 9 | return roleId; 10 | } 11 | 12 | public void setRoleId(Integer roleId) { 13 | this.roleId = roleId; 14 | } 15 | 16 | public String getRoleName() { 17 | return roleName; 18 | } 19 | 20 | public void setRoleName(String roleName) { 21 | this.roleName = roleName; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /chapter8/lesson-8-9/src/main/java/com/kucw/security/rowmapper/RoleRowMapper.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.rowmapper; 2 | 3 | import com.kucw.security.model.Role; 4 | import org.springframework.jdbc.core.RowMapper; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | 10 | @Component 11 | public class RoleRowMapper implements RowMapper { 12 | 13 | @Override 14 | public Role mapRow(ResultSet resultSet, int i) throws SQLException { 15 | Role role = new Role(); 16 | role.setRoleId(resultSet.getInt("role_id")); 17 | role.setRoleName(resultSet.getString("role_name")); 18 | 19 | return role; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chapter8/lesson-8-9/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # MySQL database connection 2 | spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 3 | spring.datasource.url=jdbc:mysql://localhost:3306/mymovie?serverTimezone=Asia/Taipei&characterEncoding=utf-8 4 | spring.datasource.username=root 5 | spring.datasource.password=springboot -------------------------------------------------------------------------------- /chapter8/lesson-8-9/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.datasource.driver-class-name=org.h2.Driver 2 | spring.datasource.url=jdbc:h2:mem:testdb 3 | spring.datasource.username=sa 4 | spring.datasource.password=sa -------------------------------------------------------------------------------- /chapter8/lesson-8-9/src/test/resources/schema.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS member 2 | ( 3 | member_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 4 | email VARCHAR(256) NOT NULL UNIQUE, 5 | password VARCHAR(256) NOT NULL, 6 | name VARCHAR(256) NOT NULL, 7 | age INT NOT NULL 8 | ); 9 | 10 | CREATE TABLE IF NOT EXISTS role 11 | ( 12 | role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 13 | role_name VARCHAR(256) NOT NULL 14 | ); 15 | 16 | CREATE TABLE IF NOT EXISTS member_has_role 17 | ( 18 | member_has_role_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, 19 | member_id INT NOT NULL, 20 | role_id INT NOT NULL 21 | ); 22 | -------------------------------------------------------------------------------- /chapter9/lesson-9-11/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter9/lesson-9-11/src/main/java/com/kucw/security/Lesson911Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson911Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson911Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter9/lesson-9-11/src/main/java/com/kucw/security/dto/ExchangeTokenRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class ExchangeTokenRequest { 4 | 5 | private String code; 6 | 7 | public String getCode() { 8 | return code; 9 | } 10 | 11 | public void setCode(String code) { 12 | this.code = code; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter9/lesson-9-11/src/main/java/com/kucw/security/dto/RefreshTokenRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class RefreshTokenRequest { 4 | 5 | private String refreshToken; 6 | 7 | public String getRefreshToken() { 8 | return refreshToken; 9 | } 10 | 11 | public void setRefreshToken(String refreshToken) { 12 | this.refreshToken = refreshToken; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter9/lesson-9-11/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter9/lesson-9-11/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter9/lesson-9-11/src/test/java/com/kucw/security/Lesson911ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson911ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter9/lesson-9-2/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter9/lesson-9-2/Postman的API/postman (oauth2)/archive.json: -------------------------------------------------------------------------------- 1 | { 2 | "collection": { 3 | "d24f8d5b-3cd7-4243-bea0-cc5d8d835c75": true 4 | } 5 | } -------------------------------------------------------------------------------- /chapter9/lesson-9-2/src/main/java/com/kucw/security/Lesson92Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson92Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson92Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter9/lesson-9-2/src/main/java/com/kucw/security/dto/ExchangeTokenRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class ExchangeTokenRequest { 4 | 5 | private String code; 6 | 7 | public String getCode() { 8 | return code; 9 | } 10 | 11 | public void setCode(String code) { 12 | this.code = code; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter9/lesson-9-2/src/main/java/com/kucw/security/dto/RefreshTokenRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class RefreshTokenRequest { 4 | 5 | private String refreshToken; 6 | 7 | public String getRefreshToken() { 8 | return refreshToken; 9 | } 10 | 11 | public void setRefreshToken(String refreshToken) { 12 | this.refreshToken = refreshToken; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter9/lesson-9-2/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter9/lesson-9-2/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter9/lesson-9-2/src/test/java/com/kucw/security/Lesson92ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson92ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter9/lesson-9-3/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter9/lesson-9-3/src/main/java/com/kucw/security/Lesson93Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson93Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson93Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter9/lesson-9-3/src/main/java/com/kucw/security/dto/ExchangeTokenRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class ExchangeTokenRequest { 4 | 5 | private String code; 6 | 7 | public String getCode() { 8 | return code; 9 | } 10 | 11 | public void setCode(String code) { 12 | this.code = code; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter9/lesson-9-3/src/main/java/com/kucw/security/dto/RefreshTokenRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class RefreshTokenRequest { 4 | 5 | private String refreshToken; 6 | 7 | public String getRefreshToken() { 8 | return refreshToken; 9 | } 10 | 11 | public void setRefreshToken(String refreshToken) { 12 | this.refreshToken = refreshToken; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter9/lesson-9-3/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter9/lesson-9-3/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter9/lesson-9-3/src/test/java/com/kucw/security/Lesson93ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson93ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter9/lesson-9-8/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /chapter9/lesson-9-8/src/main/java/com/kucw/security/Lesson98Application.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class Lesson98Application { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(Lesson98Application.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /chapter9/lesson-9-8/src/main/java/com/kucw/security/dto/ExchangeTokenRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class ExchangeTokenRequest { 4 | 5 | private String code; 6 | 7 | public String getCode() { 8 | return code; 9 | } 10 | 11 | public void setCode(String code) { 12 | this.code = code; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter9/lesson-9-8/src/main/java/com/kucw/security/dto/RefreshTokenRequest.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security.dto; 2 | 3 | public class RefreshTokenRequest { 4 | 5 | private String refreshToken; 6 | 7 | public String getRefreshToken() { 8 | return refreshToken; 9 | } 10 | 11 | public void setRefreshToken(String refreshToken) { 12 | this.refreshToken = refreshToken; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /chapter9/lesson-9-8/src/main/resources/application.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kucw/spring-security-course/077678be87876893886a9479a9a3bd137c5a21b0/chapter9/lesson-9-8/src/main/resources/application.properties -------------------------------------------------------------------------------- /chapter9/lesson-9-8/src/test/java/com/kucw/security/Lesson98ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.kucw.security; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Lesson98ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | --------------------------------------------------------------------------------