├── README.md ├── Spring_React_Login ├── backend │ ├── data │ │ └── sample.txt │ ├── docs │ │ └── sample.txt │ └── src │ │ ├── src │ │ ├── main │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── donggeun │ │ │ │ │ └── springSecurity │ │ │ │ │ ├── config │ │ │ │ │ ├── UserRole.java │ │ │ │ │ ├── WebConfig.java │ │ │ │ │ ├── SwaggerConfig.java │ │ │ │ │ ├── CustomAuthenticationEntryPoint.java │ │ │ │ │ ├── CustomAccessDeniedHandler.java │ │ │ │ │ ├── SecurityConfig.java │ │ │ │ │ └── JwtRequestFilter.java │ │ │ │ │ ├── service │ │ │ │ │ ├── EmailService.java │ │ │ │ │ ├── SaltUtil.java │ │ │ │ │ ├── impl │ │ │ │ │ │ ├── EmailServiceImpl.java │ │ │ │ │ │ └── AuthServiceImpl.java │ │ │ │ │ ├── CookieUtil.java │ │ │ │ │ ├── MyUserDetailsService.java │ │ │ │ │ ├── AuthService.java │ │ │ │ │ ├── RedisUtil.java │ │ │ │ │ └── JwtUtil.java │ │ │ │ │ ├── repository │ │ │ │ │ ├── SaltRepository.java │ │ │ │ │ ├── MemberRepository.java │ │ │ │ │ └── SocialDataRepository.java │ │ │ │ │ ├── model │ │ │ │ │ ├── Request │ │ │ │ │ │ ├── RequestChangePassword2.java │ │ │ │ │ │ ├── RequestChangePassword1.java │ │ │ │ │ │ ├── RequestVerifyEmail.java │ │ │ │ │ │ ├── RequestLoginUser.java │ │ │ │ │ │ └── RequestSocialData.java │ │ │ │ │ ├── Response.java │ │ │ │ │ ├── SecurityMember.java │ │ │ │ │ ├── Salt.java │ │ │ │ │ ├── SocialData.java │ │ │ │ │ └── Member.java │ │ │ │ │ ├── SpringSecurityApplication.java │ │ │ │ │ └── controller │ │ │ │ │ ├── TestController.java │ │ │ │ │ └── OauthController.java │ │ │ └── resources │ │ │ │ └── application.properties │ │ └── test │ │ │ └── java │ │ │ └── com │ │ │ └── donggeun │ │ │ └── springSecurity │ │ │ ├── AuthServiceTest.java │ │ │ └── SpringSecurityApplicationTests.java │ │ ├── .mvn │ │ └── wrapper │ │ │ ├── maven-wrapper.properties │ │ │ └── MavenWrapperDownloader.java │ │ ├── .gitignore │ │ └── pom.xml └── frontend │ ├── docs │ └── sample.txt │ └── src │ ├── src │ ├── App.css │ ├── react-app-env.d.ts │ ├── config │ │ └── Endpoint.tsx │ ├── Presenter │ │ ├── Main │ │ │ ├── naver_login.png │ │ │ ├── MainPresenter.scss │ │ │ └── MainPresenter.tsx │ │ └── SignUp │ │ │ ├── SignUpPresenter.scss │ │ │ └── SignUpPresenter.tsx │ ├── Container │ │ ├── index.tsx │ │ ├── SocialLoginingContainer.tsx │ │ ├── SignUpContainer.tsx │ │ └── MainContainer.tsx │ ├── setupTests.ts │ ├── App.test.tsx │ ├── index.css │ ├── index.tsx │ ├── App.tsx │ ├── logo.svg │ └── serviceWorker.ts │ ├── public │ ├── robots.txt │ ├── favicon.ico │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── index.html │ ├── .gitignore │ ├── tsconfig.json │ ├── package.json │ └── README.md ├── redistest ├── settings.gradle ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── donggeun │ │ │ └── redistest │ │ │ ├── Service │ │ │ ├── RedisService.java │ │ │ └── Impl │ │ │ │ └── RedisServiceImpl.java │ │ │ └── RedistestApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── donggeun │ │ └── redistest │ │ └── RedistestApplicationTests.java ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .gitignore ├── build.gradle └── gradlew.bat ├── authentication ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── authentication │ │ │ ├── WebSecurityConfigurer.java │ │ │ ├── AuthenticationApplication.java │ │ │ └── OAuth2config.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── authentication │ │ └── AuthenticationApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore └── pom.xml ├── springJPA ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── donggenun │ │ │ │ └── springJPA │ │ │ │ ├── MemberRepository.java │ │ │ │ ├── BoardRepository.java │ │ │ │ ├── SpringJpaApplication.java │ │ │ │ ├── Member.java │ │ │ │ └── Board.java │ │ └── resources │ │ │ └── application.properties │ └── test │ │ └── java │ │ └── com │ │ └── donggenun │ │ └── springJPA │ │ ├── SpringJpaApplicationTests.java │ │ ├── BoardRepositoryTest.java │ │ ├── RelationMappingTest.java │ │ └── QueryMethodTest.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── .gitignore └── pom.xml ├── eurekaclient1 ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── eurekaclient1 │ │ │ └── Eurekaclient1ApplicationTests.java │ └── main │ │ ├── resources │ │ └── application.yml │ │ └── java │ │ └── com │ │ └── example │ │ └── eurekaclient1 │ │ ├── TestController.java │ │ └── Eurekaclient1Application.java ├── .gitignore └── pom.xml ├── eurekaclient2 ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── eurekaclient2 │ │ │ └── Eurekaclient2ApplicationTests.java │ └── main │ │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── eurekaclient2 │ │ │ ├── ServiceConfig.java │ │ │ ├── ResourceServerConfiguration.java │ │ │ ├── EurekaClient1.java │ │ │ ├── SleepHelper.java │ │ │ ├── SimpleSourceBean.java │ │ │ ├── TestController.java │ │ │ ├── TestService.java │ │ │ └── Eurekaclient2Application.java │ │ └── resources │ │ └── application.yml ├── .gitignore └── pom.xml ├── eurekaserver ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── main │ │ ├── resources │ │ │ └── application.yml │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── eurekaserver │ │ │ └── EurekaserverApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── example │ │ └── eurekaserver │ │ └── EurekaserverApplicationTests.java ├── .gitignore └── pom.xml ├── springzuul ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── springzuul │ │ │ └── SpringzuulApplicationTests.java │ └── main │ │ ├── resources │ │ └── application.yml │ │ └── java │ │ └── com │ │ └── example │ │ └── springzuul │ │ ├── SpringzuulApplication.java │ │ ├── TrackingFilter.java │ │ └── ResponseFilter.java ├── .gitignore └── pom.xml ├── maven-jpa ├── .idea │ ├── compiler.xml │ ├── misc.xml │ └── workspace.xml ├── src │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── persistence.xml │ │ └── java │ │ └── com │ │ └── donggeun │ │ ├── BoardClient.java │ │ └── Board.java └── pom.xml └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # SpringBootWithJava -------------------------------------------------------------------------------- /Spring_React_Login/backend/data/sample.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/docs/sample.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/docs/sample.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/App.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /redistest/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'redistest' 2 | -------------------------------------------------------------------------------- /authentication/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 4040 -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/config/Endpoint.tsx: -------------------------------------------------------------------------------- 1 | export default { 2 | authServer : "http://localhost:8080" 3 | }; -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /redistest/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.cache.type=redis 2 | spring.redis: 3 | host=localhost 4 | port=6379 -------------------------------------------------------------------------------- /redistest/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehdrms2034/SpringBootWithJava/HEAD/redistest/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehdrms2034/SpringBootWithJava/HEAD/Spring_React_Login/frontend/src/public/favicon.ico -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehdrms2034/SpringBootWithJava/HEAD/Spring_React_Login/frontend/src/public/logo192.png -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehdrms2034/SpringBootWithJava/HEAD/Spring_React_Login/frontend/src/public/logo512.png -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/Presenter/Main/naver_login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ehdrms2034/SpringBootWithJava/HEAD/Spring_React_Login/frontend/src/src/Presenter/Main/naver_login.png -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/config/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.config; 2 | 3 | public enum UserRole { 4 | ROLE_NOT_PERMITTED, ROLE_USER, ROLE_MANAGER, ROLE_ADMIN 5 | } -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/Container/index.tsx: -------------------------------------------------------------------------------- 1 | export {default as MainPage} from './MainContainer'; 2 | export {default as SignUpPage} from './SignUpContainer'; 3 | export {default as SocialLoginingPage} from './SocialLoginingContainer'; -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/service/EmailService.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.service; 2 | 3 | public interface EmailService { 4 | 5 | void sendMail(String to, String sub, String text); 6 | } 7 | -------------------------------------------------------------------------------- /springJPA/src/main/java/com/donggenun/springJPA/MemberRepository.java: -------------------------------------------------------------------------------- 1 | package com.donggenun.springJPA; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | public interface MemberRepository extends CrudRepository { } 6 | -------------------------------------------------------------------------------- /springJPA/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /authentication/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /eurekaclient1/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /eurekaclient2/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /eurekaserver/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /springzuul/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /eurekaserver/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8761 3 | 4 | eureka: 5 | client: 6 | registerWithEureka: false 7 | fetchRegistry: false 8 | server: 9 | waitTimeInMsWhenSyncEmpty: 5 10 | serviceUrl: 11 | defaultZone: http://localhost:8761 -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /redistest/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat May 16 23:14:12 KST 2020 2 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip 3 | distributionBase=GRADLE_USER_HOME 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/repository/SaltRepository.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.repository; 2 | 3 | import com.donggeun.springSecurity.model.Salt; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | public interface SaltRepository extends CrudRepository { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /springJPA/src/test/java/com/donggenun/springJPA/SpringJpaApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.donggenun.springJPA; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringJpaApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/model/Request/RequestChangePassword2.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.model.Request; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter 7 | @Setter 8 | public class RequestChangePassword2 { 9 | String username; 10 | String password; 11 | } 12 | -------------------------------------------------------------------------------- /springzuul/src/test/java/com/example/springzuul/SpringzuulApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.springzuul; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class SpringzuulApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /eurekaserver/src/test/java/com/example/eurekaserver/EurekaserverApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaserver; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class EurekaserverApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /redistest/src/main/java/com/donggeun/redistest/Service/RedisService.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.redistest.Service; 2 | 3 | import java.time.Duration; 4 | 5 | public interface RedisService { 6 | String getData(String key); 7 | 8 | void setData(String key, String value); 9 | 10 | 11 | void setDataExpire(String key, String value, int duration); 12 | } 13 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/model/Request/RequestChangePassword1.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.model.Request; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter 7 | @Setter 8 | public class RequestChangePassword1 { 9 | private String username; 10 | private String email; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /eurekaclient1/src/test/java/com/example/eurekaclient1/Eurekaclient1ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient1; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Eurekaclient1ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /eurekaclient2/src/test/java/com/example/eurekaclient2/Eurekaclient2ApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient2; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class Eurekaclient2ApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/model/Request/RequestVerifyEmail.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.model.Request; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | @Setter 8 | @Getter 9 | @NoArgsConstructor 10 | public class RequestVerifyEmail { 11 | String username; 12 | } 13 | -------------------------------------------------------------------------------- /authentication/src/test/java/com/example/authentication/AuthenticationApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.example.authentication; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class AuthenticationApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /springzuul/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | eureka: 2 | instance: 3 | prefer-ip-address: true 4 | client: 5 | register-with-eureka: true 6 | fetch-registry: true 7 | serviceUrl: 8 | defaultZone: http://localhost:8761/eureka/ 9 | 10 | zuul: 11 | sensitive-headers: Cookie, Set-Cookie 12 | 13 | spring: 14 | application: 15 | name: gatewayserver 16 | profiles: 17 | active: default -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/repository/MemberRepository.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.repository; 2 | 3 | import com.donggeun.springSecurity.model.Member; 4 | import org.springframework.data.repository.CrudRepository; 5 | 6 | public interface MemberRepository extends CrudRepository { 7 | 8 | Member findByUsername(String username); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/SpringSecurityApplication.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class SpringSecurityApplication { 8 | 9 | public static void main(String[] args) 10 | { 11 | SpringApplication.run(SpringSecurityApplication.class, args); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /springJPA/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 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 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /redistest/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/ 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !**/src/main/** 6 | !**/src/test/** 7 | 8 | ### STS ### 9 | .apt_generated 10 | .classpath 11 | .factorypath 12 | .project 13 | .settings 14 | .springBeans 15 | .sts4-cache 16 | 17 | ### IntelliJ IDEA ### 18 | .idea 19 | *.iws 20 | *.iml 21 | *.ipr 22 | out/ 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | 31 | ### VS Code ### 32 | .vscode/ 33 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 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 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/model/Request/RequestLoginUser.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.model.Request; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter 7 | @Setter 8 | public class RequestLoginUser { 9 | private String username; 10 | private String password; 11 | 12 | public RequestLoginUser(String username, String password) { 13 | this.username = username; 14 | this.password = password; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/repository/SocialDataRepository.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.repository; 2 | 3 | import com.donggeun.springSecurity.model.SocialData; 4 | import org.springframework.data.repository.CrudRepository; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface SocialDataRepository extends CrudRepository { 9 | 10 | SocialData findByIdAndType(String username, String type); 11 | 12 | } -------------------------------------------------------------------------------- /redistest/src/main/java/com/donggeun/redistest/RedistestApplication.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.redistest; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cache.annotation.EnableCaching; 6 | 7 | @EnableCaching 8 | @SpringBootApplication 9 | public class RedistestApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(RedistestApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /springJPA/src/main/java/com/donggenun/springJPA/BoardRepository.java: -------------------------------------------------------------------------------- 1 | package com.donggenun.springJPA; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.repository.CrudRepository; 6 | 7 | import java.util.List; 8 | 9 | public interface BoardRepository extends CrudRepository { 10 | 11 | List findByTitle(String searchKeyword); 12 | 13 | Page findByTitleContaining(String keyword, Pageable paging); 14 | } 15 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render(, document.getElementById('root')); 8 | 9 | // If you want your app to work offline and load faster, you can change 10 | // unregister() to register() below. Note this comes with some pitfalls. 11 | // Learn more about service workers: https://bit.ly/CRA-PWA 12 | serviceWorker.unregister(); 13 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/model/Response.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.model; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter 7 | @Setter 8 | public class Response { 9 | private String response; 10 | private String message; 11 | private Object data; 12 | 13 | public Response(String response, String message, Object data) { 14 | this.response = response; 15 | this.message = message; 16 | this.data = data; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/model/Request/RequestSocialData.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.model.Request; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper; 7 | 8 | @Getter 9 | @Setter 10 | @NoArgsConstructor 11 | public class RequestSocialData { 12 | 13 | private String id; 14 | private String name; 15 | private String email; 16 | private String type; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /springzuul/src/main/java/com/example/springzuul/SpringzuulApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.springzuul; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 6 | 7 | @SpringBootApplication 8 | @EnableZuulProxy 9 | public class SpringzuulApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(SpringzuulApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /springJPA/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # DataSource setting 2 | spring.datasource.driver-class-name=org.h2.Driver 3 | spring.datasource.url=jdbc:h2:tcp://localhost/~/test 4 | spring.datasource.username=sa 5 | spring.datasource.password= 6 | 7 | #JPA Setting 8 | spring.jpa.hibernate.ddl-auto=create 9 | spring.jpa.generate-ddl=false 10 | spring.jpa.show-sql=true 11 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 12 | spring.jpa.properties.hibernate.format_sql=true 13 | 14 | #Logging Setting 15 | logging.level.org.hibernate=info -------------------------------------------------------------------------------- /springzuul/.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 | -------------------------------------------------------------------------------- /authentication/.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 | -------------------------------------------------------------------------------- /eurekaclient1/.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 | -------------------------------------------------------------------------------- /eurekaclient2/.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 | -------------------------------------------------------------------------------- /eurekaserver/.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 | -------------------------------------------------------------------------------- /eurekaserver/src/main/java/com/example/eurekaserver/EurekaserverApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaserver; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 6 | 7 | @SpringBootApplication 8 | @EnableEurekaServer 9 | public class EurekaserverApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(EurekaserverApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /eurekaclient2/src/main/java/com/example/eurekaclient2/ServiceConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient2; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.stereotype.Component; 8 | 9 | @Getter 10 | @Setter 11 | @Component 12 | public class ServiceConfig { 13 | 14 | @Value("${redis.server}") 15 | private String redisServer; 16 | 17 | @Value("${redis.port}") 18 | private String redisPort; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /eurekaclient2/src/main/java/com/example/eurekaclient2/ResourceServerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient2; 2 | 3 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 4 | import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; 5 | 6 | public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter { 7 | 8 | @Override 9 | public void configure(HttpSecurity http) throws Exception { 10 | http.authorizeRequests().anyRequest().authenticated(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/model/SecurityMember.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.model; 2 | 3 | import org.springframework.security.core.authority.AuthorityUtils; 4 | import org.springframework.security.core.userdetails.User; 5 | 6 | public class SecurityMember extends User { 7 | private static final long serialVersionUiD = 1L; 8 | 9 | public SecurityMember(Member member){ 10 | super(member.getUsername(),"{noop}"+ member.getPassword(), AuthorityUtils.createAuthorityList(member.getRole().toString())); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/service/SaltUtil.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.security.crypto.bcrypt.BCrypt; 5 | import org.springframework.stereotype.Service; 6 | 7 | @Service 8 | public class SaltUtil { 9 | 10 | public String encodePassword(String salt, String password){ 11 | return BCrypt.hashpw(password,salt); 12 | } 13 | 14 | public String genSalt(){ 15 | return BCrypt.gensalt(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /maven-jpa/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /maven-jpa/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/App.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import logo from './logo.svg'; 3 | import {Link, Route, BrowserRouter as Router} from "react-router-dom"; 4 | import {MainPage,SignUpPage, SocialLoginingPage} from "./Container"; 5 | 6 | function App() { 7 | return ( 8 |
9 | 10 | 11 | 12 | 13 | 14 |
15 | ); 16 | } 17 | 18 | export default App; 19 | -------------------------------------------------------------------------------- /springJPA/src/main/java/com/donggenun/springJPA/SpringJpaApplication.java: -------------------------------------------------------------------------------- 1 | package com.donggenun.springJPA; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.WebApplicationType; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | public class SpringJpaApplication { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication application = new SpringApplication(SpringJpaApplication.class); 12 | application.setWebApplicationType(WebApplicationType.NONE); 13 | application.run(args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /redistest/src/test/java/com/donggeun/redistest/RedistestApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.redistest; 2 | 3 | import com.donggeun.redistest.Service.RedisService; 4 | import org.junit.jupiter.api.Test; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | 8 | @SpringBootTest 9 | class RedistestApplicationTests { 10 | 11 | @Autowired 12 | private RedisService redisService; 13 | 14 | @Test 15 | void contextLoads() { 16 | } 17 | 18 | @Test 19 | void setData(){ 20 | redisService.setDataExpire("test","test",20); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "module": "esnext", 16 | "moduleResolution": "node", 17 | "resolveJsonModule": true, 18 | "isolatedModules": true, 19 | "noEmit": true, 20 | "jsx": "react" 21 | }, 22 | "include": [ 23 | "src" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/model/Salt.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.model; 2 | 3 | import com.sun.istack.NotNull; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | import org.hibernate.annotations.Cascade; 7 | 8 | import javax.annotation.Generated; 9 | import javax.persistence.*; 10 | 11 | @Entity 12 | @Getter 13 | @Setter 14 | public class Salt { 15 | 16 | @Id 17 | @GeneratedValue 18 | private int id; 19 | 20 | @NotNull() 21 | private String salt; 22 | 23 | public Salt() { 24 | } 25 | 26 | public Salt(String salt) { 27 | this.salt = salt; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /eurekaclient2/src/main/java/com/example/eurekaclient2/EurekaClient1.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient2; 2 | 3 | import org.springframework.cloud.openfeign.FeignClient; 4 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RequestMethod; 7 | 8 | import java.util.Map; 9 | 10 | @FeignClient("eurekaclient1") 11 | public interface EurekaClient1 { 12 | 13 | @RequestMapping(method = RequestMethod.GET, value = "/test",consumes = "application/json") 14 | Map getClient1Info(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /eurekaclient1/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: eurekaclient1 4 | profiles: 5 | active: default 6 | cloud: 7 | stream: 8 | bindings: 9 | input: 10 | destination : orgChangeTopic 11 | conetnt-type : application/json 12 | group: eurekaClient1 13 | binder: 14 | brokers: localhost 15 | zkNodes: localhost 16 | 17 | eureka: 18 | instance: 19 | prefer-ip-address: true 20 | client: 21 | register-with-eureka: true 22 | fetch-registry: true 23 | serviceUrl: 24 | defaultZone: http://localhost:8761/eureka/ 25 | 26 | 27 | 28 | server: 29 | port: 8181 -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/Presenter/SignUp/SignUpPresenter.scss: -------------------------------------------------------------------------------- 1 | @import '~antd/dist/antd.css'; 2 | 3 | .background{ 4 | width: 100vw; 5 | display: flex; 6 | justify-content: center; 7 | } 8 | 9 | .signup-presenter{ 10 | width: 1280px; 11 | height: 100vh; 12 | display: flex; 13 | flex-direction: column; 14 | align-items: center; 15 | justify-content: center; 16 | 17 | .login-form{ 18 | @extend .flex; 19 | width: 300px; 20 | padding : 15px; 21 | border : 1px solid rgba($color: #333333, $alpha: 0.3) 22 | } 23 | 24 | .submit{ 25 | margin-top: 35px; 26 | } 27 | 28 | } 29 | 30 | .flex{ 31 | display:flex; 32 | flex-direction: column; 33 | } -------------------------------------------------------------------------------- /eurekaclient1/src/main/java/com/example/eurekaclient1/TestController.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient1; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | import java.util.HashMap; 9 | 10 | @RestController 11 | public class TestController { 12 | 13 | @RequestMapping(method = RequestMethod.GET, value="/test") 14 | public ResponseEntity test(){ 15 | HashMap data = new HashMap<>(); 16 | data.put("text","나는 클라이언트 1에서 보내졌습니다."); 17 | return ResponseEntity.status(200).body(data); 18 | } 19 | } -------------------------------------------------------------------------------- /eurekaclient2/src/main/java/com/example/eurekaclient2/SleepHelper.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient2; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.stereotype.Component; 5 | 6 | import java.util.Random; 7 | 8 | @Component 9 | @Slf4j 10 | public class SleepHelper { 11 | public void RandomlyRunLong(){ 12 | Random random = new Random(); 13 | int randomNum = random.nextInt((3-1)+1)+1; 14 | if(randomNum==3) { 15 | log.info("슬립상태"); 16 | sleep(); 17 | } 18 | } 19 | 20 | private void sleep(){ 21 | try{ 22 | Thread.sleep(11000); 23 | }catch(InterruptedException e){ 24 | e.printStackTrace(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/config/WebConfig.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | @Configuration 8 | public class WebConfig implements WebMvcConfigurer { 9 | 10 | @Override 11 | public void addCorsMappings(CorsRegistry registry) { 12 | registry.addMapping("/**") 13 | .allowCredentials(true) 14 | .allowedOrigins("http://localhost:3000") 15 | .allowedMethods("*") 16 | .allowedHeaders("*"); 17 | } 18 | } -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/controller/TestController.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.controller; 2 | 3 | import com.donggeun.springSecurity.model.Response; 4 | import org.springframework.web.bind.annotation.GetMapping; 5 | import org.springframework.web.bind.annotation.RequestMapping; 6 | import org.springframework.web.bind.annotation.RestController; 7 | 8 | @RestController 9 | @RequestMapping("/test") 10 | public class TestController { 11 | 12 | @GetMapping("/login") 13 | String testLogin(){ 14 | return "Hello World"; 15 | } 16 | 17 | @GetMapping("/user") 18 | String user() {return "you are a user"; } 19 | 20 | @GetMapping("/admin") 21 | String admin() {return "you are a admin";} 22 | } -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/model/SocialData.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.model; 2 | 3 | import lombok.Getter; 4 | import lombok.NoArgsConstructor; 5 | import lombok.Setter; 6 | 7 | import javax.persistence.*; 8 | 9 | @Entity 10 | @Table 11 | @Getter 12 | @Setter 13 | @NoArgsConstructor 14 | public class SocialData { 15 | 16 | @Id 17 | @GeneratedValue 18 | private int id; 19 | 20 | private String socialId; 21 | private String email; 22 | private String type; 23 | 24 | @OneToOne(mappedBy = "social") 25 | private Member member; 26 | 27 | public SocialData(String socialId, String email, String type) { 28 | this.id = id; 29 | this.socialId = socialId; 30 | this.email = email; 31 | this.type = type; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/Presenter/Main/MainPresenter.scss: -------------------------------------------------------------------------------- 1 | @import '~antd/dist/antd.css'; 2 | 3 | .background{ 4 | width: 100vw; 5 | display: flex; 6 | justify-content: center; 7 | } 8 | 9 | .main-container{ 10 | width: 1280px; 11 | height: 99vh; 12 | display : flex; 13 | flex-direction: column; 14 | justify-content: center; 15 | align-items: center; 16 | 17 | .loginForm{ 18 | display: flex; 19 | flex-direction: column; 20 | margin-bottom: 30px; 21 | padding: 30px; 22 | border: 1px solid rgba($color: #333333, $alpha: 0.3); 23 | } 24 | .idInput{ 25 | width : 300px; 26 | } 27 | 28 | .buttonForm{ 29 | display: flex; 30 | margin-top: 35px; 31 | } 32 | 33 | .socialLoginForm{ 34 | display : flex; 35 | flex-direction: column; 36 | } 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /eurekaclient2/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | 2 | spring: 3 | application: 4 | name: eurekaclient2 5 | profiles: 6 | active: default 7 | cloud: 8 | stream: 9 | bindings: 10 | output: 11 | destination: orgChangeTopic 12 | content-type: application/json 13 | kafka: 14 | binder: 15 | brokers: localhost 16 | zkNodes: localhost 17 | 18 | eureka: 19 | instance: 20 | prefer-ip-address: true 21 | client: 22 | register-with-eureka: true 23 | fetch-registry: true 24 | serviceUrl: 25 | defaultZone: http://localhost:8761/eureka/ 26 | 27 | security: 28 | oauth2: 29 | resource: 30 | user-info-uri: http://localhost:4040/user 31 | 32 | 33 | server: 34 | port: 8182 35 | 36 | 37 | logging: 38 | level: debug 39 | 40 | redis: 41 | server: localhost 42 | port: 6379 -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/service/impl/EmailServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.service.impl; 2 | 3 | import com.donggeun.springSecurity.service.EmailService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.mail.SimpleMailMessage; 6 | import org.springframework.mail.javamail.JavaMailSender; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class EmailServiceImpl implements EmailService { 11 | @Autowired 12 | private JavaMailSender emailSender; 13 | 14 | @Override 15 | public void sendMail(String to,String sub, String text){ 16 | SimpleMailMessage message = new SimpleMailMessage(); 17 | message.setTo(to); 18 | message.setSubject(sub); 19 | message.setText(text); 20 | emailSender.send(message); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # mysql connection 2 | spring.datasource.url=jdbc:mysql://localhost:3306/springDB?characterEncoding=UTF-8&serverTimezone=UTC 3 | spring.datasource.username=아이디 4 | spring.datasource.password=비밀번호 5 | spring.jpa.hibernate.ddl-auto=create 6 | spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect 7 | logging.level.com.douggeun.springSecurity=debug 8 | # JWT Secret Key 9 | spring.jwt.secret=kimdonggeunkimdonggeunkimdonggeunkimdonggeunkimdonggeunkimdonggeunkimdonggeunkimdonggeun 10 | 11 | spring.cache.type=redis 12 | spring.redis.host =localhost 13 | spring.redis.port=6379 14 | 15 | ## Email Send Configuration_SMTP 16 | spring.mail.host=smtp.gmail.com 17 | spring.mail.port=587 18 | spring.mail.username= 아이디 19 | spring.mail.password= 비밀번호 20 | spring.mail.properties.mail.smtp.auth=true 21 | spring.mail.properties.mail.smtp.starttls.enable=true 22 | -------------------------------------------------------------------------------- /redistest/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.3.0.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.9.RELEASE' 4 | id 'java' 5 | } 6 | 7 | group = 'com.donggeun' 8 | version = '0.0.1-SNAPSHOT' 9 | sourceCompatibility = '1.8' 10 | 11 | configurations { 12 | compileOnly { 13 | extendsFrom annotationProcessor 14 | } 15 | } 16 | 17 | repositories { 18 | mavenCentral() 19 | } 20 | 21 | dependencies { 22 | implementation 'org.springframework.boot:spring-boot-starter-web' 23 | implementation 'org.springframework.boot:spring-boot-starter-data-redis' 24 | compileOnly 'org.projectlombok:lombok' 25 | developmentOnly 'org.springframework.boot:spring-boot-devtools' 26 | annotationProcessor 'org.projectlombok:lombok' 27 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 28 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 29 | } 30 | } 31 | 32 | test { 33 | useJUnitPlatform() 34 | } 35 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/service/CookieUtil.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.service; 2 | 3 | import org.springframework.stereotype.Service; 4 | 5 | import javax.servlet.http.Cookie; 6 | import javax.servlet.http.HttpServletRequest; 7 | 8 | @Service 9 | public class CookieUtil { 10 | 11 | public Cookie createCookie(String cookieName, String value){ 12 | Cookie token = new Cookie(cookieName,value); 13 | token.setHttpOnly(true); 14 | token.setMaxAge((int)JwtUtil.TOKEN_VALIDATION_SECOND); 15 | token.setPath("/"); 16 | return token; 17 | } 18 | 19 | public Cookie getCookie(HttpServletRequest req, String cookieName){ 20 | final Cookie[] cookies = req.getCookies(); 21 | if(cookies==null) return null; 22 | for(Cookie cookie : cookies){ 23 | if(cookie.getName().equals(cookieName)) 24 | return cookie; 25 | } 26 | return null; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/config/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.config; 2 | 3 | import com.google.common.base.Predicates; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import springfox.documentation.builders.PathSelectors; 7 | import springfox.documentation.builders.RequestHandlerSelectors; 8 | import springfox.documentation.spi.DocumentationType; 9 | import springfox.documentation.spring.web.plugins.Docket; 10 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 11 | 12 | @Configuration 13 | @EnableSwagger2 14 | public class SwaggerConfig { 15 | @Bean 16 | public Docket api(){ 17 | return new Docket(DocumentationType.SWAGGER_2).select() 18 | .apis(Predicates.not(RequestHandlerSelectors. 19 | basePackage("org.springframework.boot"))) 20 | .paths(PathSelectors.any()).build(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/Container/SocialLoginingContainer.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import {useEffect} from 'react'; 3 | import styled from 'styled-components'; 4 | import qs from 'query-string'; 5 | import Axios from 'axios'; 6 | 7 | interface SocialLoginingContainerProps{ 8 | location : Location 9 | } 10 | 11 | const SocialLoginingContainer = ( {location} : SocialLoginingContainerProps) => { 12 | 13 | 14 | useEffect(()=>{ 15 | const query = qs.parse(location.search); 16 | 17 | //https://nid.naver.com/oauth2.0/authorize?response_type=code&client_id=Rr5h5X4_s0B5nA3TlvQu&redirect_uri=http://localhost:3000/login/oauth 18 | const clientId = "Rr5h5X4_s0B5nA3TlvQu"; 19 | const secretKey = "BbIH2OsO0v" 20 | Axios.get("https://nid.naver.com/oauth2.0/token?grant_type=authorization_code&client_id="+clientId+"&client_secret="+secretKey+"&code="+query.code); 21 | },[]); 22 | 23 | return( 24 |
25 |
26 | ) 27 | 28 | } 29 | 30 | export default SocialLoginingContainer; -------------------------------------------------------------------------------- /springJPA/src/test/java/com/donggenun/springJPA/BoardRepositoryTest.java: -------------------------------------------------------------------------------- 1 | package com.donggenun.springJPA; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | 7 | import java.util.Date; 8 | 9 | @SpringBootTest 10 | public class BoardRepositoryTest { 11 | @Autowired 12 | private BoardRepository boardRepo; 13 | 14 | @Test 15 | public void testInsertBoard() { 16 | Board board = new Board(); 17 | board.setTitle("첫 번째 게시글"); 18 | // board.setWriter("테스터"); 19 | board.setContent("잘 등록되나요?"); 20 | board.setCreateDate(new Date()); 21 | board.setCnt(0L); 22 | 23 | boardRepo.save(board); 24 | } 25 | 26 | @Test 27 | public void testUpdateBoard(){ 28 | System.out.println("===1번 게시글 조회 ==="); 29 | Board board = boardRepo.findById(1L).get(); 30 | 31 | System.out.println("===1번 게시글 수정 ==="); 32 | board.setTitle("제목을 수정"); 33 | boardRepo.save(board); 34 | } 35 | 36 | } -------------------------------------------------------------------------------- /eurekaclient2/src/main/java/com/example/eurekaclient2/SimpleSourceBean.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient2; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.cloud.stream.messaging.Source; 7 | import org.springframework.messaging.support.MessageBuilder; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.HashMap; 11 | 12 | @Component 13 | public class SimpleSourceBean { 14 | private Source source; 15 | 16 | private static final Logger logger= LoggerFactory.getLogger(SimpleSourceBean.class); 17 | 18 | @Autowired 19 | public SimpleSourceBean(Source source){ 20 | this.source = source; 21 | } 22 | 23 | public void publishEu2Change(String action, String content){ 24 | logger.debug("Sending kafka message {} for Content: {}",action,content); 25 | 26 | HashMap map = new HashMap<>(); 27 | map.put("server","eureka1"); 28 | map.put("content",content); 29 | 30 | source.output().send(MessageBuilder.withPayload(map).build()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /eurekaclient1/src/main/java/com/example/eurekaclient1/Eurekaclient1Application.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient1; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | import org.springframework.cloud.stream.annotation.EnableBinding; 8 | import org.springframework.cloud.stream.annotation.StreamListener; 9 | import org.springframework.cloud.stream.messaging.Sink; 10 | import org.springframework.kafka.annotation.EnableKafka; 11 | 12 | import java.util.Map; 13 | 14 | @SpringBootApplication 15 | @EnableDiscoveryClient 16 | @EnableBinding(Sink.class) 17 | @EnableKafka 18 | @Slf4j 19 | public class Eurekaclient1Application { 20 | 21 | public static void main(String[] args) { 22 | SpringApplication.run(Eurekaclient1Application.class, args); 23 | } 24 | 25 | @StreamListener(Sink.INPUT) 26 | public void loggerSink(Map message){ 27 | log.info("Received an event for server {} , content : {}", message.get("server"),message.get("content")); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/service/MyUserDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.service; 2 | 3 | import com.donggeun.springSecurity.model.Member; 4 | import com.donggeun.springSecurity.repository.MemberRepository; 5 | import com.donggeun.springSecurity.model.SecurityMember; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.security.core.userdetails.UserDetails; 8 | import org.springframework.security.core.userdetails.UserDetailsService; 9 | import org.springframework.security.core.userdetails.UsernameNotFoundException; 10 | import org.springframework.stereotype.Service; 11 | 12 | @Service 13 | public class MyUserDetailsService implements UserDetailsService { 14 | 15 | @Autowired 16 | private MemberRepository memberRepository; 17 | 18 | @Override 19 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { 20 | 21 | Member member = memberRepository.findByUsername(username); 22 | if(member == null){ 23 | throw new UsernameNotFoundException(username + " : 사용자 존재하지 않음"); 24 | } 25 | 26 | return new SecurityMember(member); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/service/AuthService.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.service; 2 | 3 | import com.donggeun.springSecurity.config.UserRole; 4 | import com.donggeun.springSecurity.model.Member; 5 | import com.donggeun.springSecurity.model.Request.RequestSocialData; 6 | import javassist.NotFoundException; 7 | 8 | public interface AuthService { 9 | 10 | final String REDIS_CHANGE_PASSWORD_PREFIX="CPW"; 11 | 12 | void signUpUser(Member member); 13 | 14 | void signUpSocialUser(RequestSocialData member); 15 | 16 | Member loginSocialUser(String id, String type) throws NotFoundException; 17 | 18 | Member loginUser(String id, String password) throws Exception; 19 | 20 | Member findByUsername(String username) throws NotFoundException; 21 | 22 | void verifyEmail(String key) throws NotFoundException; 23 | 24 | void sendVerificationMail(Member member) throws NotFoundException; 25 | 26 | void modifyUserRole(Member member, UserRole userRole); 27 | 28 | boolean isPasswordUuidValidate(String key); 29 | 30 | void changePassword(Member member, String password) throws NotFoundException; 31 | 32 | void requestChangePassword(Member member) throws NotFoundException; 33 | } 34 | -------------------------------------------------------------------------------- /springzuul/src/main/java/com/example/springzuul/TrackingFilter.java: -------------------------------------------------------------------------------- 1 | package com.example.springzuul; 2 | 3 | import com.netflix.zuul.ZuulFilter; 4 | import com.netflix.zuul.context.RequestContext; 5 | import com.netflix.zuul.exception.ZuulException; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Component 12 | public class TrackingFilter extends ZuulFilter { 13 | private static final int FILTER_ORDER=1; 14 | private static final boolean SHOULD_FILTER = true; 15 | private static final Logger logger = LoggerFactory.getLogger(TrackingFilter.class); 16 | private static final String FILTER_TYPE = "pre"; 17 | 18 | @Override 19 | public String filterType() { 20 | return TrackingFilter.FILTER_TYPE; 21 | } 22 | 23 | @Override 24 | public int filterOrder() { 25 | return FILTER_ORDER; 26 | } 27 | 28 | @Override 29 | public boolean shouldFilter() { 30 | return SHOULD_FILTER; 31 | } 32 | 33 | @Override 34 | public Object run() throws ZuulException { 35 | 36 | RequestContext ctx = RequestContext.getCurrentContext(); 37 | logger.info("Processing Incoming request for" + ctx.getRequest().getRequestURI()); 38 | 39 | return null; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/service/RedisUtil.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.redis.core.StringRedisTemplate; 5 | import org.springframework.data.redis.core.ValueOperations; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.time.Duration; 9 | 10 | @Service 11 | public class RedisUtil { 12 | 13 | @Autowired 14 | private StringRedisTemplate stringRedisTemplate; 15 | 16 | public String getData(String key){ 17 | ValueOperations valueOperations = stringRedisTemplate.opsForValue(); 18 | return valueOperations.get(key); 19 | } 20 | 21 | public void setData(String key, String value){ 22 | ValueOperations valueOperations = stringRedisTemplate.opsForValue(); 23 | valueOperations.set(key,value); 24 | } 25 | 26 | public void setDataExpire(String key,String value,long duration){ 27 | ValueOperations valueOperations = stringRedisTemplate.opsForValue(); 28 | Duration expireDuration = Duration.ofSeconds(duration); 29 | valueOperations.set(key,value,expireDuration); 30 | } 31 | 32 | public void deleteData(String key){ 33 | stringRedisTemplate.delete(key); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /maven-jpa/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /springzuul/src/main/java/com/example/springzuul/ResponseFilter.java: -------------------------------------------------------------------------------- 1 | package com.example.springzuul; 2 | 3 | import brave.Tracer; 4 | import com.netflix.zuul.ZuulFilter; 5 | import com.netflix.zuul.context.RequestContext; 6 | import com.netflix.zuul.exception.ZuulException; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Component; 11 | 12 | @Component 13 | public class ResponseFilter extends ZuulFilter { 14 | private static final int FILTER_ORDER = 1; 15 | private static final boolean SHOULD_FILTER = true; 16 | private static final Logger logger = LoggerFactory.getLogger(ResponseFilter.class); 17 | 18 | 19 | 20 | @Autowired 21 | Tracer tracer; 22 | 23 | @Override 24 | public String filterType() { 25 | return "post"; 26 | } 27 | 28 | @Override 29 | public int filterOrder() { 30 | return FILTER_ORDER; 31 | } 32 | 33 | @Override 34 | public boolean shouldFilter() { 35 | return SHOULD_FILTER; 36 | } 37 | 38 | @Override 39 | public Object run() throws ZuulException { 40 | RequestContext ctx = RequestContext.getCurrentContext(); 41 | ctx.getResponse().addHeader("tmx-correlation-id",tracer.currentSpan().context().traceIdString()); 42 | return null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /maven-jpa/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.donggeun 8 | maven_jpa 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | 14 | org.apache.maven.plugins 15 | maven-compiler-plugin 16 | 17 | 8 18 | 8 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | org.hibernate 28 | hibernate-entitymanager 29 | 5.4.12.Final 30 | 31 | 32 | 33 | com.h2database 34 | h2 35 | 1.4.200 36 | test 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /redistest/src/main/java/com/donggeun/redistest/Service/Impl/RedisServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.redistest.Service.Impl; 2 | 3 | import com.donggeun.redistest.Service.RedisService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.data.redis.core.StringRedisTemplate; 6 | import org.springframework.data.redis.core.ValueOperations; 7 | import org.springframework.stereotype.Service; 8 | 9 | import java.time.Duration; 10 | 11 | @Service 12 | public class RedisServiceImpl implements RedisService { 13 | 14 | @Autowired 15 | private StringRedisTemplate stringRedisTemplate; 16 | 17 | @Override 18 | public String getData(String key) { 19 | ValueOperations valueOperations = stringRedisTemplate.opsForValue(); 20 | return valueOperations.get(key); 21 | } 22 | 23 | @Override 24 | public void setData(String key, String value) { 25 | ValueOperations valueOperations = stringRedisTemplate.opsForValue(); 26 | valueOperations.set(key,value); 27 | } 28 | 29 | @Override 30 | public void setDataExpire(String key, String value, int duration) { 31 | ValueOperations valueOperations = stringRedisTemplate.opsForValue(); 32 | Duration tempDuration = Duration.ofSeconds(duration); 33 | valueOperations.set(key,value,tempDuration); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/config/CustomAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.config; 2 | 3 | import com.donggeun.springSecurity.model.Response; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import org.springframework.security.core.AuthenticationException; 6 | import org.springframework.security.web.AuthenticationEntryPoint; 7 | import org.springframework.stereotype.Component; 8 | 9 | import javax.servlet.ServletException; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | import java.io.PrintWriter; 14 | 15 | @Component 16 | public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint { 17 | 18 | @Override 19 | public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException { 20 | ObjectMapper objectMapper = new ObjectMapper(); 21 | 22 | httpServletResponse.setStatus(200); 23 | httpServletResponse.setContentType("application/json;charset=utf-8"); 24 | Response response = new Response("error","로그인이 되지 않은 사용자입니다.",null); 25 | PrintWriter out = httpServletResponse.getWriter(); 26 | String jsonResponse = objectMapper.writeValueAsString(response); 27 | out.print(jsonResponse); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "front_logins", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.3.2", 8 | "@testing-library/user-event": "^7.1.2", 9 | "@types/jest": "^24.0.0", 10 | "@types/js-cookie": "^2.2.5", 11 | "@types/node": "^12.0.0", 12 | "@types/react": "^16.9.23", 13 | "@types/react-dom": "^16.9.5", 14 | "@types/react-router-dom": "^5.1.3", 15 | "@types/styled-components": "^5.1.1", 16 | "antd": "^4.0.2", 17 | "axios": "^0.19.2", 18 | "js-cookie": "^2.2.1", 19 | "node-sass": "^4.13.1", 20 | "query-string": "^6.13.1", 21 | "react": "^16.13.0", 22 | "react-dom": "^16.13.0", 23 | "react-login-by-naver": "^0.1.8", 24 | "react-router-dom": "^5.1.2", 25 | "react-scripts": "3.4.0", 26 | "styled-components": "^5.1.1", 27 | "typescript": "~3.7.2" 28 | }, 29 | "scripts": { 30 | "start": "react-scripts start", 31 | "build": "react-scripts build", 32 | "test": "react-scripts test", 33 | "eject": "react-scripts eject" 34 | }, 35 | "eslintConfig": { 36 | "extends": "react-app" 37 | }, 38 | "browserslist": { 39 | "production": [ 40 | ">0.2%", 41 | "not dead", 42 | "not op_mini all" 43 | ], 44 | "development": [ 45 | "last 1 chrome version", 46 | "last 1 firefox version", 47 | "last 1 safari version" 48 | ] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /eurekaclient2/src/main/java/com/example/eurekaclient2/TestController.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient2; 2 | 3 | import com.netflix.discovery.converters.Auto; 4 | import feign.Response; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestMethod; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | @RestController 15 | public class TestController { 16 | 17 | @Autowired 18 | private TestService testService; 19 | 20 | 21 | @RequestMapping(method = RequestMethod.GET, value="/test") 22 | public ResponseEntity test(){ 23 | HashMap data = new HashMap<>(); 24 | data.put("text","나는 클라이언트 2에서 보내졌습니다."); 25 | return ResponseEntity.status(200).body(data); 26 | } 27 | 28 | @RequestMapping(method = RequestMethod.GET,value="/eureka1") 29 | public ResponseEntity test2(){ 30 | Map data = testService.getMessageByClient1(); 31 | return ResponseEntity.status(200).body(data); 32 | } 33 | 34 | @RequestMapping(method = RequestMethod.GET, value = "/send") 35 | public ResponseEntity test3(){ 36 | testService.sendMessage("서버2에서 카프카로 전송하는 메시지입니다."); 37 | HashMap data = new HashMap<>(); 38 | data.put("text","서버2에서 카프카로 전송하는 메시지입니다."); 39 | return ResponseEntity.status(200).body(data); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /authentication/src/main/java/com/example/authentication/WebSecurityConfigurer.java: -------------------------------------------------------------------------------- 1 | package com.example.authentication; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.security.authentication.AuthenticationManager; 6 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 7 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 8 | import org.springframework.security.core.userdetails.UserDetailsService; 9 | import org.springframework.security.crypto.factory.PasswordEncoderFactories; 10 | import org.springframework.security.crypto.password.NoOpPasswordEncoder; 11 | import org.springframework.security.crypto.password.PasswordEncoder; 12 | 13 | @Configuration 14 | public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter { 15 | 16 | @Bean 17 | @Override 18 | public AuthenticationManager authenticationManagerBean() throws Exception { 19 | return super.authenticationManagerBean(); 20 | } 21 | 22 | @Override 23 | @Bean 24 | public UserDetailsService userDetailsServiceBean() throws Exception { 25 | return super.userDetailsServiceBean(); 26 | } 27 | 28 | @Override 29 | protected void configure(AuthenticationManagerBuilder auth) throws Exception { 30 | auth.inMemoryAuthentication() 31 | .withUser("admin1234").password("{noop}password1").roles("USER","ADMIN") 32 | .and() 33 | .withUser("test1234").password("{noop}password1").roles("USER"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /maven-jpa/src/main/java/com/donggeun/BoardClient.java: -------------------------------------------------------------------------------- 1 | package com.donggeun; 2 | 3 | import org.hibernate.HibernateError; 4 | 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.EntityManagerFactory; 7 | import javax.persistence.EntityTransaction; 8 | import javax.persistence.Persistence; 9 | import java.util.Date; 10 | import java.util.List; 11 | 12 | public class BoardClient { 13 | 14 | 15 | public static void main(String args[]){ 16 | EntityManagerFactory emf = Persistence.createEntityManagerFactory("chapters"); 17 | EntityManager em = emf.createEntityManager(); 18 | EntityTransaction tx = em.getTransaction(); 19 | try{ 20 | tx.begin(); 21 | Board board = new Board(); 22 | board.setTitle("제목"); 23 | board.setWriter("관리자"); 24 | board.setContent("JPA 글 등록 잘 되네요."); 25 | board.setCreateDate(new Date()); 26 | board.setCnt(0L); 27 | 28 | // Board board = em.find(Board.class,1L); 29 | // em.remove(board); 30 | 31 | em.persist(board); 32 | 33 | String jpql = "select b from Board b order by b.seq asc"; 34 | List boardList = em.createQuery(jpql, Board.class).getResultList(); 35 | 36 | for(Board brd : boardList) { 37 | System.out.println("--->"+ brd.toString()); 38 | } 39 | tx.commit(); 40 | } 41 | catch(Exception e){ 42 | e.printStackTrace(); 43 | tx.rollback(); 44 | } 45 | finally { 46 | em.close(); 47 | emf.close(); 48 | } 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /authentication/src/main/java/com/example/authentication/AuthenticationApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.authentication; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.security.authentication.AuthenticationManager; 7 | import org.springframework.security.core.authority.AuthorityUtils; 8 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; 9 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; 10 | import org.springframework.security.oauth2.provider.OAuth2Authentication; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestMethod; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | @SpringBootApplication 19 | @RestController 20 | @EnableAuthorizationServer 21 | @EnableResourceServer 22 | public class AuthenticationApplication { 23 | 24 | public static void main(String[] args) { 25 | SpringApplication.run(AuthenticationApplication.class, args); 26 | } 27 | 28 | @RequestMapping(value={"/user"},method = RequestMethod.GET) 29 | public Map user(OAuth2Authentication user){ 30 | Map userInfo = new HashMap<>(); 31 | userInfo.put("user",user.getUserAuthentication().getPrincipal()); 32 | userInfo.put("authorities", AuthorityUtils.authorityListToSet(user.getUserAuthentication().getAuthorities())); 33 | return userInfo; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /springJPA/src/main/java/com/donggenun/springJPA/Member.java: -------------------------------------------------------------------------------- 1 | package com.donggenun.springJPA; 2 | 3 | import javax.persistence.*; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | @Entity 8 | public class Member { 9 | @Id 10 | @Column(name = "MEMBER_ID") 11 | private String id; 12 | private String password; 13 | private String name; 14 | private String role; 15 | 16 | @OneToMany(mappedBy = "member", fetch = FetchType.EAGER) 17 | private List boardList = new ArrayList(); 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(String id) { 24 | this.id = id; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | public String getRole() { 44 | return role; 45 | } 46 | 47 | public void setRole(String role) { 48 | this.role = role; 49 | } 50 | 51 | public List getBoardList() { 52 | return boardList; 53 | } 54 | 55 | public void setBoardList(List boardList) { 56 | this.boardList = boardList; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return "Member{" + 62 | "id='" + id + '\'' + 63 | ", password='" + password + '\'' + 64 | ", name='" + name + '\'' + 65 | ", role='" + role + '\'' + 66 | ", boardList=" + boardList + 67 | '}'; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /eurekaclient2/src/main/java/com/example/eurekaclient2/TestService.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient2; 2 | 3 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; 4 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | @Service 12 | public class TestService { 13 | 14 | @Autowired 15 | private EurekaClient1 eurekaClient1; 16 | 17 | @Autowired 18 | private SleepHelper sleepHelper; 19 | 20 | @Autowired 21 | private SimpleSourceBean simpleSourceBean; 22 | 23 | @HystrixCommand(commandProperties = { 24 | @HystrixProperty( 25 | name = "execution.isolation.thread.timeoutInMilliseconds", 26 | value = "13000" 27 | )}, 28 | fallbackMethod = "buildFallbackMessageByClient1", 29 | threadPoolKey = "client1CommunicationThreadPool1", 30 | threadPoolProperties = { 31 | @HystrixProperty(name = "coreSize", value = "30"), 32 | @HystrixProperty(name = "maxQueueSize", value = "10")} 33 | ) 34 | public Map getMessageByClient1() { 35 | sleepHelper.RandomlyRunLong(); 36 | return eurekaClient1.getClient1Info(); 37 | } 38 | 39 | 40 | private Map buildFallbackMessageByClient1() { 41 | HashMap map = new HashMap<>(); 42 | map.put("text", "이것은 서버1과의 연결이 여의치 않아 보여주는 폴백 프로세싱 메시지 입니다."); 43 | return map; 44 | } 45 | 46 | public void sendMessage(String content){ 47 | simpleSourceBean.publishEu2Change("SEND",content); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /springJPA/src/test/java/com/donggenun/springJPA/RelationMappingTest.java: -------------------------------------------------------------------------------- 1 | package com.donggenun.springJPA; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.boot.test.context.SpringBootTest; 7 | import org.springframework.test.context.junit4.SpringRunner; 8 | 9 | import java.util.Date; 10 | 11 | @RunWith(SpringRunner.class) 12 | @SpringBootTest 13 | public class RelationMappingTest { 14 | 15 | @Autowired 16 | private BoardRepository boardRepo; 17 | 18 | @Autowired 19 | private MemberRepository memberRepo; 20 | 21 | @Test 22 | public void testManyToOneInsert(){ 23 | Member member1 = new Member(); 24 | member1.setId("member1"); 25 | member1.setPassword("member111"); 26 | member1.setName("둘리"); 27 | member1.setRole("User"); 28 | memberRepo.save(member1); 29 | 30 | Member member2 = new Member(); 31 | member2.setId("member2"); 32 | member2.setPassword("member222"); 33 | member2.setName("도우너"); 34 | member2.setRole("Admin"); 35 | memberRepo.save(member2); 36 | 37 | for(int i=1; i<=3; i++){ 38 | Board board = new Board(); 39 | board.setMember(member1); 40 | board.setTitle("둘리가 등록한 게시글 " + i); 41 | board.setContent("둘리가 등록한 게시글 내용 "+ i); 42 | board.setCreateDate(new Date()); 43 | board.setCnt(0L); 44 | boardRepo.save(board); 45 | } 46 | 47 | for(int i=1; i<=3; i++){ 48 | Board board = new Board(); 49 | board.setMember(member2); 50 | board.setTitle("도우너가 등록한 게시글"+ i); 51 | board.setContent("도우너가 등록한 게시글 내용 "+ i); 52 | board.setCreateDate(new Date()); 53 | board.setCnt(0L); 54 | boardRepo.save(board); 55 | } 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /eurekaclient2/src/main/java/com/example/eurekaclient2/Eurekaclient2Application.java: -------------------------------------------------------------------------------- 1 | package com.example.eurekaclient2; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; 7 | import org.springframework.cloud.openfeign.EnableFeignClients; 8 | import org.springframework.cloud.stream.annotation.EnableBinding; 9 | import org.springframework.cloud.stream.messaging.Source; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; 12 | import org.springframework.data.redis.core.RedisTemplate; 13 | import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; 14 | 15 | @SpringBootApplication 16 | @EnableFeignClients 17 | @EnableCircuitBreaker 18 | @EnableResourceServer 19 | @EnableBinding(Source.class) 20 | public class Eurekaclient2Application { 21 | 22 | @Autowired 23 | private ServiceConfig serviceConfig; 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(Eurekaclient2Application.class, args); 27 | } 28 | 29 | @Bean 30 | public JedisConnectionFactory jedisConnectionFactory() { 31 | JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(); 32 | jedisConnectionFactory.setHostName(serviceConfig.getRedisServer()); 33 | jedisConnectionFactory.setPort(Integer.parseInt(serviceConfig.getRedisPort())); 34 | return jedisConnectionFactory; 35 | } 36 | 37 | @Bean 38 | public RedisTemplate redisTemplate(){ 39 | RedisTemplate template = new RedisTemplate(); 40 | template.setConnectionFactory(jedisConnectionFactory()); 41 | return template; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/test/java/com/donggeun/springSecurity/AuthServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity; 2 | 3 | import com.donggeun.springSecurity.model.Member; 4 | import com.donggeun.springSecurity.model.Request.RequestLoginUser; 5 | import com.donggeun.springSecurity.service.AuthService; 6 | import com.donggeun.springSecurity.service.EmailService; 7 | import lombok.extern.slf4j.Slf4j; 8 | import org.junit.jupiter.api.BeforeEach; 9 | import org.junit.jupiter.api.Test; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | 13 | @SpringBootTest 14 | @Slf4j 15 | public class AuthServiceTest { 16 | 17 | @Autowired 18 | private AuthService authService; 19 | 20 | @Autowired 21 | private EmailService emailService; 22 | 23 | Member member; 24 | 25 | @BeforeEach() 26 | public void initMember(){ 27 | this.member = new Member(); 28 | this.member.setUsername("test5"); 29 | this.member.setPassword("test5"); 30 | this.member.setName("김동근"); 31 | this.member.setEmail("ehdrms2034@naver.com"); 32 | this.member.setAddress("대한민국 어디광역시 땡땡로 땡땡길 101동 1001호"); 33 | } 34 | 35 | @Test 36 | public void signUp() { 37 | authService.signUpUser(member); 38 | } 39 | 40 | @Test 41 | public void login() { 42 | RequestLoginUser loginUser = new RequestLoginUser(member.getUsername(), member.getPassword()); 43 | try { 44 | authService.loginUser(loginUser.getUsername(), loginUser.getPassword()); 45 | log.info("로그인 성공"); 46 | } catch (Exception e) { 47 | e.printStackTrace(); 48 | } 49 | } 50 | 51 | @Test 52 | public void modifyUserRole(){ 53 | 54 | } 55 | 56 | @Test 57 | public void sendFirstEmail(){ 58 | emailService.sendMail("ehdrms2034@naver.com","테스트메일입니다.","ㅇㅇㅇ"); 59 | } 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/test/java/com/donggeun/springSecurity/SpringSecurityApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity; 2 | 3 | import com.donggeun.springSecurity.model.Member; 4 | import com.donggeun.springSecurity.repository.MemberRepository; 5 | import com.donggeun.springSecurity.service.AuthService; 6 | import com.donggeun.springSecurity.service.JwtUtil; 7 | import com.zaxxer.hikari.util.IsolationLevel; 8 | import org.junit.jupiter.api.Test; 9 | import org.junit.runner.RunWith; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | import org.springframework.transaction.annotation.Isolation; 14 | 15 | import javax.transaction.Transactional; 16 | 17 | import static org.hamcrest.MatcherAssert.assertThat; 18 | import static org.hamcrest.core.Is.is; 19 | 20 | @RunWith(SpringRunner.class) 21 | @SpringBootTest 22 | class SpringSecurityApplicationTests { 23 | 24 | @Autowired 25 | private MemberRepository memberRepository; 26 | 27 | 28 | @Autowired 29 | private JwtUtil jwtUtil; 30 | 31 | @Test 32 | void contextLoads() { 33 | } 34 | 35 | @Test 36 | @Transactional() 37 | void testDB(){ 38 | Member member = new Member(); 39 | member.setUsername("user4"); 40 | member.setPassword("a1234"); 41 | member.setName("김동근"); 42 | member.setEmail("ehdrms2034@naver.com"); 43 | member.setAddress("부산광역시 부산진구 땡땡로 땡땡길 101동 1001호"); 44 | memberRepository.save(member); 45 | Member user1 = memberRepository.findByUsername("user4"); 46 | assertThat(user1.getName(),is("김동근")); 47 | memberRepository.delete(user1); 48 | } 49 | 50 | @Test 51 | void test(){ 52 | 53 | String username = jwtUtil.getUsername("eyJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImVoZHJtczIwMzQiLCJpYXQiOjE1ODQ2MTkzMTMsImV4cCI6MTU4NDYyMTExM30.llLcxtXVoI3xBROLrrru1IYXSAADywNwtb9IBMhXzfQ"); 54 | System.out.println(username); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /authentication/src/main/java/com/example/authentication/OAuth2config.java: -------------------------------------------------------------------------------- 1 | package com.example.authentication; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.beans.factory.annotation.Qualifier; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.authentication.AuthenticationManager; 7 | import org.springframework.security.core.userdetails.UserDetailsService; 8 | import org.springframework.security.crypto.factory.PasswordEncoderFactories; 9 | import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; 10 | import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; 11 | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; 12 | import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer; 13 | 14 | @Configuration 15 | public class OAuth2config extends AuthorizationServerConfigurerAdapter { 16 | 17 | @Autowired 18 | private AuthenticationManager authenticationManager; 19 | 20 | @Autowired 21 | @Qualifier("userDetailsServiceBean") 22 | private UserDetailsService userDetailsService; 23 | 24 | @Override 25 | public void configure(ClientDetailsServiceConfigurer clients) throws Exception { 26 | clients.inMemory() 27 | .withClient("eagleeye") 28 | .secret("{noop}thisissecret") 29 | .authorizedGrantTypes("refresh_token","password","client_credentials") 30 | .scopes("webclient","mobileclient"); 31 | } 32 | 33 | 34 | @Override 35 | public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { 36 | endpoints.authenticationManager(authenticationManager) 37 | .userDetailsService(userDetailsService); 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /springJPA/src/main/java/com/donggenun/springJPA/Board.java: -------------------------------------------------------------------------------- 1 | package com.donggenun.springJPA; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | public class Board { 8 | 9 | @Id 10 | @GeneratedValue 11 | private Long seq; 12 | private String title; 13 | // private String writer; 14 | private String content; 15 | @Temporal(value = TemporalType.TIMESTAMP) 16 | private Date createDate; 17 | private Long cnt; 18 | 19 | @ManyToOne 20 | @JoinColumn(name="MEMBER_ID") 21 | private Member member; 22 | 23 | public Long getSeq() { 24 | return seq; 25 | } 26 | 27 | public void setSeq(Long seq) { 28 | this.seq = seq; 29 | } 30 | 31 | public String getTitle() { 32 | return title; 33 | } 34 | 35 | public void setTitle(String title) { 36 | this.title = title; 37 | } 38 | 39 | public String getContent() { 40 | return content; 41 | } 42 | 43 | public void setContent(String content) { 44 | this.content = content; 45 | } 46 | 47 | public Date getCreateDate() { 48 | return createDate; 49 | } 50 | 51 | public void setCreateDate(Date createDate) { 52 | this.createDate = createDate; 53 | } 54 | 55 | public Long getCnt() { 56 | return cnt; 57 | } 58 | 59 | public void setCnt(Long cnt) { 60 | this.cnt = cnt; 61 | } 62 | 63 | public Member getMember() { 64 | return member; 65 | } 66 | 67 | public void setMember(Member member) { 68 | this.member = member; 69 | } 70 | 71 | @Override 72 | public String toString() { 73 | return "Board{" + 74 | "seq=" + seq + 75 | ", title='" + title + '\'' + 76 | ", content='" + content + '\'' + 77 | ", createDate=" + createDate + 78 | ", cnt=" + cnt + 79 | ", member=" + member + 80 | '}'; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/Container/SignUpContainer.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { useState } from 'react'; 3 | import SignUpPresenter from '../Presenter/SignUp/SignUpPresenter'; 4 | import Axios from 'axios'; 5 | import Endpoint from '../config/Endpoint'; 6 | import {useHistory} from 'react-router'; 7 | 8 | export type RequestSignUp = { 9 | username : string, 10 | password : string, 11 | name : string, 12 | email : string, 13 | address : string, 14 | } 15 | 16 | const SignUpContainer = () => { 17 | 18 | const [username, setUsername] = useState(""); 19 | const [password, setPassword] = useState(""); 20 | const [name, setName] = useState(""); 21 | const [email, setEmail] = useState(""); 22 | const [address, setAddress] = useState(""); 23 | const history = useHistory(); 24 | 25 | const handleSignUp = (signUpRequest : RequestSignUp) => { 26 | console.log("하위^^"); 27 | Axios.post(Endpoint.authServer+'/user/signup', 28 | { 29 | username : signUpRequest.name, 30 | password : signUpRequest.password, 31 | name : signUpRequest.name, 32 | email : signUpRequest.email, 33 | address : signUpRequest.address 34 | }) 35 | .then(response=>response.data) 36 | .then(data=> { 37 | if(data.response === "success"){ 38 | alert("회원가입이 완료됐습니다."); 39 | history.push("/"); 40 | } 41 | console.log(data); 42 | }) 43 | .catch(error=>{ 44 | alert("회원가입이 실패했습니다."); 45 | }) 46 | }; 47 | 48 | return ( 49 |
50 | 63 |
64 | ) 65 | } 66 | 67 | export default SignUpContainer -------------------------------------------------------------------------------- /springJPA/src/test/java/com/donggenun/springJPA/QueryMethodTest.java: -------------------------------------------------------------------------------- 1 | package com.donggenun.springJPA; 2 | 3 | import org.junit.Before; 4 | import org.junit.Test; 5 | import org.junit.runner.RunWith; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | import org.springframework.data.domain.Page; 9 | import org.springframework.data.domain.PageRequest; 10 | import org.springframework.data.domain.Pageable; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | 13 | import java.util.Date; 14 | import java.util.List; 15 | 16 | @RunWith(SpringRunner.class) 17 | @SpringBootTest 18 | public class QueryMethodTest { 19 | @Autowired 20 | private BoardRepository boardRepo; 21 | 22 | @Before 23 | public void dataPrepare() { 24 | for (int i = 1; i <= 200; i++) { 25 | Board board = new Board(); 26 | board.setTitle("테스트 제목 " + i); 27 | // board.setWriter("관리자"); 28 | board.setContent("테스트 내용 " + i); 29 | board.setCreateDate(new Date()); 30 | board.setCnt(0L); 31 | boardRepo.save(board); 32 | } 33 | } 34 | 35 | @Test 36 | public void testFindByTitle() { 37 | List boardList = boardRepo.findByTitle("테스트 제목 10"); 38 | System.out.println("검색 결과"); 39 | for(Board board : boardList){ 40 | System.out.println("---> " + board.toString()); 41 | } 42 | } 43 | 44 | @Test 45 | public void testFindByTitleContaining(){ 46 | Pageable paging = PageRequest.of(0,5); 47 | Page pageInfo = boardRepo.findByTitleContaining("12",paging); 48 | List boardList = pageInfo.getContent(); 49 | 50 | System.out.println(pageInfo.getSize()); 51 | System.out.println(pageInfo.getTotalPages()); 52 | System.out.println("검색 결과"); 53 | for(Board board : boardList){ 54 | System.out.println("---> " + board.toString()); 55 | } 56 | } 57 | 58 | 59 | } 60 | -------------------------------------------------------------------------------- /maven-jpa/src/main/java/com/donggeun/Board.java: -------------------------------------------------------------------------------- 1 | package com.donggeun; 2 | 3 | import javax.persistence.*; 4 | import java.util.Date; 5 | 6 | @Entity 7 | @TableGenerator( 8 | name = "BOARD_SEQ_GENERATOR", 9 | table = "ALL_SEQUENCES", 10 | pkColumnValue = "BOARD_SEQ", 11 | initialValue = 0, 12 | allocationSize = 1 13 | ) 14 | @Table(name = "BOARD") 15 | public class Board { 16 | @Id 17 | @GeneratedValue(strategy = GenerationType.TABLE, generator = "BOARD_SEQ_GENERATOR") 18 | private Long seq; 19 | private String title; 20 | private String writer; 21 | private String content; 22 | private Date createDate; 23 | private Long cnt; 24 | 25 | public Long getSeq() { 26 | return seq; 27 | } 28 | 29 | public void setSeq(Long seq) { 30 | this.seq = seq; 31 | } 32 | 33 | public String getTitle() { 34 | return title; 35 | } 36 | 37 | public void setTitle(String title) { 38 | this.title = title; 39 | } 40 | 41 | public String getWriter() { 42 | return writer; 43 | } 44 | 45 | public void setWriter(String writer) { 46 | this.writer = writer; 47 | } 48 | 49 | public String getContent() { 50 | return content; 51 | } 52 | 53 | public void setContent(String content) { 54 | this.content = content; 55 | } 56 | 57 | public Date getCreateDate() { 58 | return createDate; 59 | } 60 | 61 | public void setCreateDate(Date createDate) { 62 | this.createDate = createDate; 63 | } 64 | 65 | public Long getCnt() { 66 | return cnt; 67 | } 68 | 69 | public void setCnt(Long cnt) { 70 | this.cnt = cnt; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return "Board{" + 76 | "seq=" + seq + 77 | ", title='" + title + '\'' + 78 | ", writer='" + writer + '\'' + 79 | ", content='" + content + '\'' + 80 | ", createDate=" + createDate + 81 | ", cnt=" + cnt + 82 | '}'; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/Container/MainContainer.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { useState } from "react"; 3 | import MainPresenter from "../Presenter/Main/MainPresenter"; 4 | import axios from "axios"; 5 | import cookies from "js-cookie"; 6 | import Endpoint from "../config/Endpoint"; 7 | import { useHistory } from "react-router"; 8 | 9 | const MainContainer = () => { 10 | const [username, setUsername] = useState(""); 11 | const [password, setPassword] = useState(""); 12 | const history = useHistory(); 13 | 14 | const doLogin = (username: string, password: string) => { 15 | console.log(username, password); 16 | console.log(document.cookie); 17 | axios 18 | .post( 19 | "http://localhost:8080/user/login", 20 | { 21 | username, 22 | password, 23 | }, 24 | { withCredentials: true } 25 | ) 26 | .then((response) => { 27 | return response.data; 28 | }) 29 | .then((data) => { 30 | if (data.response === "success") { 31 | alert("로그인 성공"); 32 | } 33 | }) 34 | .catch((error) => { 35 | console.error(error); 36 | }); 37 | }; 38 | 39 | const doTest = () => { 40 | history.push("/signup"); 41 | }; 42 | 43 | const signUpByNaver = async (id: string, email: string,name : string, type: string) => { 44 | const response = await axios.post( 45 | "http://localhost:8080/oauth/signup/naver", 46 | { 47 | id, 48 | email, 49 | name, 50 | type, 51 | }, 52 | { withCredentials: true } 53 | ); 54 | const data = response.data; 55 | if (data.response === "success") { 56 | alert("성공적으로 회원가입이 됐습니다."); 57 | }else console.log(data); 58 | }; 59 | 60 | return ( 61 |
62 | 71 |
72 | ); 73 | }; 74 | 75 | export default MainContainer; 76 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `yarn start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `yarn test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `yarn build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `yarn eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | -------------------------------------------------------------------------------- /springJPA/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.5.RELEASE 9 | 10 | 11 | com.donggenun 12 | springJPA 13 | 0.0.1-SNAPSHOT 14 | springJPA 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-data-jpa 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-web 29 | 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-devtools 34 | runtime 35 | true 36 | 37 | 38 | com.h2database 39 | h2 40 | runtime 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | org.junit.vintage 49 | junit-vintage-engine 50 | 51 | 52 | 53 | 54 | 55 | junit 56 | junit 57 | 4.13 58 | test 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-maven-plugin 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/config/CustomAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.config; 2 | 3 | import com.donggeun.springSecurity.model.Response; 4 | import com.donggeun.springSecurity.model.SecurityMember; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.security.access.AccessDeniedException; 8 | import org.springframework.security.core.Authentication; 9 | import org.springframework.security.core.GrantedAuthority; 10 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 11 | import org.springframework.security.core.context.SecurityContextHolder; 12 | import org.springframework.security.web.access.AccessDeniedHandler; 13 | import org.springframework.stereotype.Component; 14 | 15 | import javax.servlet.ServletException; 16 | import javax.servlet.http.HttpServletRequest; 17 | import javax.servlet.http.HttpServletResponse; 18 | import java.io.IOException; 19 | import java.io.PrintWriter; 20 | import java.util.Collection; 21 | 22 | @Slf4j 23 | @Component 24 | public class CustomAccessDeniedHandler implements AccessDeniedHandler { 25 | @Override 26 | public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException { 27 | ObjectMapper objectMapper = new ObjectMapper(); 28 | 29 | httpServletResponse.setStatus(200); 30 | httpServletResponse.setContentType("application/json;charset=utf-8"); 31 | Response response = new Response("error","접근가능한 권한을 가지고 있지 않습니다.",null); 32 | 33 | Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); 34 | SecurityMember member = (SecurityMember)authentication.getPrincipal(); 35 | Collection authorities = member.getAuthorities(); 36 | 37 | if(hasRole(authorities,UserRole.ROLE_NOT_PERMITTED.name())){ 38 | response.setMessage("사용자 인증메일을 받지 않았습니다."); 39 | } 40 | 41 | PrintWriter out = httpServletResponse.getWriter(); 42 | String jsonResponse = objectMapper.writeValueAsString(response); 43 | out.print(jsonResponse); 44 | 45 | } 46 | 47 | private boolean hasRole(Collection authorites, String role){ 48 | return authorites.contains(new SimpleGrantedAuthority(role)); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/model/Member.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.model; 2 | 3 | 4 | import com.donggeun.springSecurity.config.UserRole; 5 | import lombok.Builder; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | import org.hibernate.annotations.CreationTimestamp; 9 | import org.hibernate.annotations.UpdateTimestamp; 10 | 11 | import javax.persistence.*; 12 | import javax.validation.constraints.NotBlank; 13 | import javax.validation.constraints.NotNull; 14 | import java.util.Date; 15 | 16 | @Entity 17 | @Table(name = "Members") 18 | @Getter 19 | @Setter 20 | public class Member { 21 | 22 | @Id 23 | @GeneratedValue 24 | private int seq; 25 | 26 | @Column(unique = true) 27 | @NotNull 28 | private String username; 29 | @NotNull 30 | private String password; 31 | @NotBlank 32 | private String name; 33 | @NotBlank 34 | private String email; 35 | @NotNull 36 | private String address; 37 | 38 | @OneToOne(cascade = CascadeType.ALL) 39 | @JoinColumn(name="social_id") 40 | private SocialData social; 41 | 42 | @Column(name = "role") 43 | @Enumerated(EnumType.STRING) 44 | private UserRole role = UserRole.ROLE_NOT_PERMITTED; 45 | 46 | @Temporal(TemporalType.TIMESTAMP) 47 | @CreationTimestamp 48 | private Date createAt; 49 | @Temporal(TemporalType.TIMESTAMP) 50 | @UpdateTimestamp 51 | private Date updateAt; 52 | 53 | @OneToOne(cascade = CascadeType.ALL) 54 | @JoinColumn(name = "salt_id") 55 | private Salt salt; 56 | 57 | public Member() { 58 | } 59 | 60 | public Member(@NotBlank String username, @NotBlank String password, @NotBlank String name, @NotBlank String email, @NotBlank String address) { 61 | this.username = username; 62 | this.password = password; 63 | this.name = name; 64 | this.email = email; 65 | this.address = address; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return "User{" + 71 | "seq=" + seq + 72 | ", id='" + username + '\'' + 73 | ", password='" + password + '\'' + 74 | ", name='" + name + '\'' + 75 | ", email='" + email + '\'' + 76 | ", address='" + address + '\'' + 77 | ", role=" + role + 78 | ", createAt=" + createAt + 79 | ", updateAt=" + updateAt + 80 | '}'; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/Presenter/SignUp/SignUpPresenter.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import "./SignUpPresenter.scss"; 3 | import { Button, Input, Form } from "antd"; 4 | import {RequestSignUp} from '../../Container/SignUpContainer'; 5 | 6 | type SignUpPresenterProps = { 7 | username: string, 8 | setUsername: Function, 9 | password: string, 10 | setPassword: Function, 11 | name: string, 12 | setName: Function, 13 | email: string, 14 | setEmail: Function, 15 | address : string, 16 | setAddress : Function, 17 | handleSignUp: Function, 18 | }; 19 | 20 | const SignUpPresenter = ({ 21 | username, 22 | password, 23 | name, 24 | email, 25 | address, 26 | setUsername, 27 | setPassword, 28 | setName, 29 | setEmail, 30 | setAddress, 31 | handleSignUp 32 | }: SignUpPresenterProps) => { 33 | return ( 34 |
35 |
36 |
{ 39 | const requestSignUp : RequestSignUp = { 40 | username,password,name,email,address 41 | } 42 | handleSignUp(requestSignUp); 43 | }} 44 | > 45 | 아이디 46 | 47 | setUsername(e.target.value)} 50 | required 51 | /> 52 | 53 | 비밀번호 54 | 55 | setPassword(e.target.value)} 58 | /> 59 | 60 | 이름 61 | 62 | setName(e.target.value)} /> 65 | 66 | 이메일 67 | 68 | setEmail(e.target.value)} /> 71 | 72 | 73 | 주소 74 | 75 | setAddress(e.target.value)}/> 78 | 79 | 80 | 81 | 84 | 85 |
86 |
87 |
88 | ); 89 | }; 90 | 91 | export default SignUpPresenter; 92 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/controller/OauthController.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.controller; 2 | 3 | import com.donggeun.springSecurity.model.Member; 4 | import com.donggeun.springSecurity.model.Request.RequestSocialData; 5 | import com.donggeun.springSecurity.model.Response; 6 | import com.donggeun.springSecurity.model.SocialData; 7 | import com.donggeun.springSecurity.service.AuthService; 8 | import com.donggeun.springSecurity.service.CookieUtil; 9 | import com.donggeun.springSecurity.service.JwtUtil; 10 | import com.donggeun.springSecurity.service.RedisUtil; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.*; 13 | 14 | import javax.servlet.http.Cookie; 15 | import javax.servlet.http.HttpServletRequest; 16 | import javax.servlet.http.HttpServletResponse; 17 | 18 | @RestController 19 | @RequestMapping("/oauth") 20 | public class OauthController { 21 | 22 | @Autowired 23 | private AuthService authService; 24 | 25 | @Autowired 26 | private JwtUtil jwtUtil; 27 | 28 | @Autowired 29 | private CookieUtil cookieUtil; 30 | 31 | @Autowired 32 | private RedisUtil redisUtil; 33 | 34 | @PostMapping("/signup/naver") 35 | public Response signUpNaverUser(@RequestBody RequestSocialData socialData){ 36 | Response response; 37 | try{ 38 | authService.signUpSocialUser(socialData); 39 | response = new Response("success","성공적으로 회원가입을 완료했습닌다.",null); 40 | }catch(Exception e){ 41 | response = new Response("error","회원가입 실패",e.getMessage()); 42 | } 43 | return response; 44 | } 45 | 46 | @GetMapping("/login/naver") 47 | public Response loginNaverUser(@RequestBody RequestSocialData socialData, HttpServletRequest req, HttpServletResponse res){ 48 | Response response; 49 | try{ 50 | final Member member = authService.loginSocialUser(socialData.getId(),socialData.getType()); 51 | final String token = jwtUtil.generateToken(member); 52 | final String refreshJwt = jwtUtil.generateRefreshToken(member); 53 | Cookie accessToken = cookieUtil.createCookie(JwtUtil.ACCESS_TOKEN_NAME, token); 54 | Cookie refreshToken = cookieUtil.createCookie(JwtUtil.REFRESH_TOKEN_NAME, refreshJwt); 55 | redisUtil.setDataExpire(refreshJwt, member.getUsername(), JwtUtil.REFRESH_TOKEN_VALIDATION_SECOND); 56 | res.addCookie(accessToken); 57 | res.addCookie(refreshToken); 58 | response = new Response("success", "로그인에 성공했습니다.", token); 59 | }catch(Exception e){ 60 | response = new Response("error", "로그인에 실패했습니다.", e.getMessage()); 61 | } 62 | return response; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.config; 2 | 3 | import com.donggeun.springSecurity.service.MyUserDetailsService; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.security.authentication.AuthenticationManager; 7 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 8 | import org.springframework.security.config.annotation.web.builders.WebSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 10 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 11 | import org.springframework.security.config.http.SessionCreationPolicy; 12 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 13 | 14 | @EnableWebSecurity 15 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 16 | 17 | @Autowired 18 | private MyUserDetailsService myUserDetailsService; 19 | 20 | @Autowired 21 | private JwtRequestFilter jwtRequestFilter; 22 | 23 | @Autowired 24 | private CustomAuthenticationEntryPoint customAuthenticationEntryPoint; 25 | 26 | @Autowired 27 | private CustomAccessDeniedHandler customAccessDeniedHandler; 28 | 29 | @Override 30 | protected void configure(HttpSecurity http) throws Exception { 31 | 32 | http.csrf().disable() 33 | .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) 34 | .and() 35 | .httpBasic() 36 | .authenticationEntryPoint(customAuthenticationEntryPoint) 37 | .and() 38 | .exceptionHandling().accessDeniedHandler(customAccessDeniedHandler) 39 | .and() 40 | .authorizeRequests() 41 | .antMatchers("/user/signup").permitAll() 42 | .antMatchers("/user/login").permitAll() 43 | .antMatchers("/user/verify/**").permitAll() 44 | .antMatchers("/oauth/**").permitAll() 45 | .antMatchers("/test/user").hasRole("USER") 46 | .antMatchers("/test/admin").hasRole("ADMIN") 47 | .anyRequest().authenticated(); 48 | 49 | http.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class); 50 | } 51 | 52 | @Override // ignore check swagger resource 53 | public void configure(WebSecurity web) { 54 | web.ignoring().antMatchers("/v2/api-docs", "/swagger-resources/**", 55 | "/swagger-ui.html", "/webjars/**", "/swagger/**"); 56 | } 57 | 58 | @Bean 59 | @Override 60 | public AuthenticationManager authenticationManagerBean() throws Exception { 61 | return super.authenticationManagerBean(); 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /eurekaserver/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.3.RELEASE 9 | 10 | 11 | com.example 12 | eurekaserver 13 | 0.0.1-SNAPSHOT 14 | eurekaserver 15 | Demo project for Spring Boot 16 | 17 | 18 | 11 19 | Hoxton.SR7 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-netflix-eureka-server 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-devtools 34 | runtime 35 | true 36 | 37 | 38 | org.projectlombok 39 | lombok 40 | true 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | org.junit.vintage 49 | junit-vintage-engine 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | org.springframework.cloud 59 | spring-cloud-dependencies 60 | ${spring-cloud.version} 61 | pom 62 | import 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-maven-plugin 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/service/JwtUtil.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.service; 2 | 3 | import com.donggeun.springSecurity.model.Member; 4 | import io.jsonwebtoken.Claims; 5 | import io.jsonwebtoken.ExpiredJwtException; 6 | import io.jsonwebtoken.Jwts; 7 | import io.jsonwebtoken.SignatureAlgorithm; 8 | import io.jsonwebtoken.security.Keys; 9 | import io.jsonwebtoken.security.SignatureException; 10 | import org.springframework.beans.factory.annotation.Value; 11 | import org.springframework.security.core.userdetails.UserDetails; 12 | import org.springframework.stereotype.Component; 13 | 14 | import java.nio.charset.StandardCharsets; 15 | import java.security.Key; 16 | import java.util.Date; 17 | 18 | @Component 19 | public class JwtUtil { 20 | 21 | public final static long TOKEN_VALIDATION_SECOND = 1000L * 10; 22 | public final static long REFRESH_TOKEN_VALIDATION_SECOND = 1000L * 60 * 24 * 2; 23 | 24 | final static public String ACCESS_TOKEN_NAME = "accessToken"; 25 | final static public String REFRESH_TOKEN_NAME = "refreshToken"; 26 | 27 | @Value("${spring.jwt.secret}") 28 | private String SECRET_KEY; 29 | 30 | private Key getSigningKey(String secretKey) { 31 | byte[] keyBytes = secretKey.getBytes(StandardCharsets.UTF_8); 32 | return Keys.hmacShaKeyFor(keyBytes); 33 | } 34 | 35 | public Claims extractAllClaims(String token) throws ExpiredJwtException { 36 | return Jwts.parserBuilder() 37 | .setSigningKey(getSigningKey(SECRET_KEY)) 38 | .build() 39 | .parseClaimsJws(token) 40 | .getBody(); 41 | } 42 | 43 | public String getUsername(String token) { 44 | return extractAllClaims(token).get("username", String.class); 45 | } 46 | 47 | public Boolean isTokenExpired(String token) { 48 | final Date expiration = extractAllClaims(token).getExpiration(); 49 | return expiration.before(new Date()); 50 | } 51 | 52 | public String generateToken(Member member) { 53 | return doGenerateToken(member.getUsername(), TOKEN_VALIDATION_SECOND); 54 | } 55 | 56 | public String generateRefreshToken(Member member) { 57 | return doGenerateToken(member.getUsername(), REFRESH_TOKEN_VALIDATION_SECOND); 58 | } 59 | 60 | public String doGenerateToken(String username, long expireTime) { 61 | 62 | Claims claims = Jwts.claims(); 63 | claims.put("username", username); 64 | 65 | String jwt = Jwts.builder() 66 | .setClaims(claims) 67 | .setIssuedAt(new Date(System.currentTimeMillis())) 68 | .setExpiration(new Date(System.currentTimeMillis() + expireTime)) 69 | .signWith(getSigningKey(SECRET_KEY), SignatureAlgorithm.HS256) 70 | .compact(); 71 | 72 | return jwt; 73 | } 74 | 75 | public Boolean validateToken(String token, UserDetails userDetails) { 76 | final String username = getUsername(token); 77 | 78 | return (username.equals(userDetails.getUsername()) && !isTokenExpired(token)); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/node,java,react,java-web 2 | # Edit at https://www.gitignore.io/?templates=node,java,react,java-web 3 | 4 | ### Java ### 5 | # Compiled class file 6 | *.class 7 | 8 | # Log file 9 | *.log 10 | 11 | # BlueJ files 12 | *.ctxt 13 | 14 | # Mobile Tools for Java (J2ME) 15 | .mtj.tmp/ 16 | 17 | # Package Files # 18 | *.jar 19 | *.war 20 | *.nar 21 | *.ear 22 | *.zip 23 | *.tar.gz 24 | *.rar 25 | 26 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 27 | hs_err_pid* 28 | 29 | ### Java-Web ### 30 | ## ignoring target file 31 | target/ 32 | 33 | ### Node ### 34 | # Logs 35 | logs 36 | npm-debug.log* 37 | yarn-debug.log* 38 | yarn-error.log* 39 | lerna-debug.log* 40 | 41 | # Diagnostic reports (https://nodejs.org/api/report.html) 42 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 43 | 44 | # Runtime data 45 | pids 46 | *.pid 47 | *.seed 48 | *.pid.lock 49 | 50 | # Directory for instrumented libs generated by jscoverage/JSCover 51 | lib-cov 52 | 53 | # Coverage directory used by tools like istanbul 54 | coverage 55 | *.lcov 56 | 57 | # nyc test coverage 58 | .nyc_output 59 | 60 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 61 | .grunt 62 | 63 | # Bower dependency directory (https://bower.io/) 64 | bower_components 65 | 66 | # node-waf configuration 67 | .lock-wscript 68 | 69 | # Compiled binary addons (https://nodejs.org/api/addons.html) 70 | build/Release 71 | 72 | # Dependency directories 73 | node_modules/ 74 | jspm_packages/ 75 | 76 | # TypeScript v1 declaration files 77 | typings/ 78 | 79 | # TypeScript cache 80 | *.tsbuildinfo 81 | 82 | # Optional npm cache directory 83 | .npm 84 | 85 | # Optional eslint cache 86 | .eslintcache 87 | 88 | # Optional REPL history 89 | .node_repl_history 90 | 91 | # Output of 'npm pack' 92 | *.tgz 93 | 94 | # Yarn Integrity file 95 | .yarn-integrity 96 | 97 | # dotenv environment variables file 98 | .env 99 | .env.test 100 | 101 | # parcel-bundler cache (https://parceljs.org/) 102 | .cache 103 | 104 | # next.js build output 105 | .next 106 | 107 | # nuxt.js build output 108 | .nuxt 109 | 110 | # rollup.js default build output 111 | dist/ 112 | 113 | # Uncomment the public line if your project uses Gatsby 114 | # https://nextjs.org/blog/next-9-1#public-directory-support 115 | # https://create-react-app.dev/docs/using-the-public-folder/#docsNav 116 | # public 117 | 118 | # Storybook build outputs 119 | .out 120 | .storybook-out 121 | 122 | # vuepress build output 123 | .vuepress/dist 124 | 125 | # Serverless directories 126 | .serverless/ 127 | 128 | # FuseBox cache 129 | .fusebox/ 130 | 131 | # DynamoDB Local files 132 | .dynamodb/ 133 | 134 | # Temporary folders 135 | tmp/ 136 | temp/ 137 | 138 | ### react ### 139 | .DS_* 140 | **/*.backup.* 141 | **/*.back.* 142 | 143 | node_modules 144 | 145 | *.sublime* 146 | 147 | psd 148 | thumb 149 | sketch 150 | 151 | # End of https://www.gitignore.io/api/node,java,react,java-web 152 | Spring_React_Login/backend/src/src/main/resources/application.properties 153 | -------------------------------------------------------------------------------- /authentication/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.3.RELEASE 9 | 10 | 11 | com.example 12 | authentication 13 | 0.0.1-SNAPSHOT 14 | authentication 15 | Demo project for Spring Boot 16 | 17 | 18 | 11 19 | Hoxton.SR7 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-starter-oauth2 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-devtools 40 | runtime 41 | true 42 | 43 | 44 | org.projectlombok 45 | lombok 46 | true 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-starter-test 51 | test 52 | 53 | 54 | org.junit.vintage 55 | junit-vintage-engine 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | org.springframework.cloud 65 | spring-cloud-dependencies 66 | ${spring-cloud.version} 67 | pom 68 | import 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /redistest/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | @rem Execute Gradle 88 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 89 | 90 | :end 91 | @rem End local scope for the variables with windows NT shell 92 | if "%ERRORLEVEL%"=="0" goto mainEnd 93 | 94 | :fail 95 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 96 | rem the _cmd.exe /c_ return code! 97 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 98 | exit /b 1 99 | 100 | :mainEnd 101 | if "%OS%"=="Windows_NT" endlocal 102 | 103 | :omega 104 | -------------------------------------------------------------------------------- /springzuul/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.3.RELEASE 9 | 10 | 11 | com.example 12 | springzuul 13 | 0.0.1-SNAPSHOT 14 | springzuul 15 | Demo project for Spring Boot 16 | 17 | 18 | 11 19 | Hoxton.SR7 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-netflix-zuul 30 | 31 | 32 | org.springframework.cloud 33 | spring-cloud-starter-netflix-eureka-client 34 | 2.2.4.RELEASE 35 | 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-sleuth 40 | 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-sleuth-zipkin 45 | 46 | 47 | 48 | org.springframework.boot 49 | spring-boot-devtools 50 | runtime 51 | true 52 | 53 | 54 | org.projectlombok 55 | lombok 56 | true 57 | 58 | 59 | org.springframework.boot 60 | spring-boot-starter-test 61 | test 62 | 63 | 64 | org.junit.vintage 65 | junit-vintage-engine 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | org.springframework.cloud 75 | spring-cloud-dependencies 76 | ${spring-cloud.version} 77 | pom 78 | import 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | org.springframework.boot 87 | spring-boot-maven-plugin 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /eurekaclient1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.3.RELEASE 9 | 10 | 11 | com.example 12 | eurekaclient1 13 | 0.0.1-SNAPSHOT 14 | eurekaclient1 15 | Demo project for Spring Boot 16 | 17 | 18 | 11 19 | Hoxton.SR7 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.cloud 29 | spring-cloud-starter-netflix-eureka-client 30 | 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-stream 35 | 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-stream-kafka 40 | 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-sleuth 45 | 46 | 47 | 48 | org.springframework.cloud 49 | spring-cloud-sleuth-zipkin 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-devtools 55 | runtime 56 | true 57 | 58 | 59 | org.projectlombok 60 | lombok 61 | true 62 | 63 | 64 | org.springframework.boot 65 | spring-boot-starter-test 66 | test 67 | 68 | 69 | org.junit.vintage 70 | junit-vintage-engine 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | org.springframework.cloud 80 | spring-cloud-dependencies 81 | ${spring-cloud.version} 82 | pom 83 | import 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | org.springframework.boot 92 | spring-boot-maven-plugin 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/Presenter/Main/MainPresenter.tsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import { Input, Button, Form, Result } from "antd"; 3 | import "./MainPresenter.scss"; 4 | import NaverLogin from "react-login-by-naver"; 5 | import styled from "styled-components"; 6 | import naverImg from "./naver_login.png"; 7 | 8 | type MainPresenterProps = { 9 | username: string; 10 | setUsername: Function; 11 | password: string; 12 | setPassword: Function; 13 | doLogin: Function; 14 | doTest: Function; 15 | signUpByNaver: Function; 16 | }; 17 | 18 | const NaverBtn = styled.div` 19 | margin-top: 10px; 20 | width: 300px; 21 | height: 50px; 22 | background: #11c800; 23 | color: #ffffff; 24 | font-weight: bold; 25 | display: flex; 26 | justify-content: center; 27 | align-items: center; 28 | `; 29 | 30 | const MainPresenter = ({ 31 | username, 32 | password, 33 | setUsername, 34 | setPassword, 35 | doLogin, 36 | doTest, 37 | signUpByNaver, 38 | }: MainPresenterProps) => { 39 | return ( 40 |
41 |
{ 44 | doLogin(username, password); 45 | }} 46 | > 47 |
48 | 아이디 49 | 53 | setUsername(e.target.value)} 57 | /> 58 | 59 | 비밀번호 60 | 64 | setPassword(e.target.value)} 67 | /> 68 | 69 | 70 | 82 | 83 | 86 | 87 | 88 | 89 | {/* { 93 | console.log(result); 94 | }} 95 | onFailure={() => { 96 | console.error(); 97 | }} 98 | render={(props) => ( 99 | 100 | 네이버 아이디로 로그인 101 | 102 | )} 103 | > */} 104 | 105 | { 109 | signUpByNaver(result.id,result.email,result.name,"naver"); 110 | }} 111 | onFailure={() => { 112 | alert("하이"); 113 | console.error(); 114 | }} 115 | render={(props) => ( 116 | 117 | 네이버 아이디로 회원가입 118 | 119 | )} 120 | /> 121 | 122 |
123 |
124 |
125 | ); 126 | }; 127 | 128 | export default MainPresenter; 129 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/config/JwtRequestFilter.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.config; 2 | 3 | import com.donggeun.springSecurity.model.Member; 4 | import com.donggeun.springSecurity.service.CookieUtil; 5 | import com.donggeun.springSecurity.service.JwtUtil; 6 | import com.donggeun.springSecurity.service.MyUserDetailsService; 7 | import com.donggeun.springSecurity.service.RedisUtil; 8 | import io.jsonwebtoken.ExpiredJwtException; 9 | import io.jsonwebtoken.Jwt; 10 | import lombok.extern.slf4j.Slf4j; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 13 | import org.springframework.security.core.context.SecurityContextHolder; 14 | import org.springframework.security.core.userdetails.UserDetails; 15 | import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; 16 | import org.springframework.stereotype.Component; 17 | import org.springframework.web.filter.OncePerRequestFilter; 18 | 19 | import javax.servlet.FilterChain; 20 | import javax.servlet.ServletException; 21 | import javax.servlet.http.Cookie; 22 | import javax.servlet.http.HttpServletRequest; 23 | import javax.servlet.http.HttpServletResponse; 24 | import java.io.IOException; 25 | 26 | @Slf4j 27 | @Component 28 | public class JwtRequestFilter extends OncePerRequestFilter { 29 | 30 | @Autowired 31 | private MyUserDetailsService userDetailsService; 32 | 33 | @Autowired 34 | private JwtUtil jwtUtil; 35 | 36 | @Autowired 37 | private CookieUtil cookieUtil; 38 | 39 | @Autowired 40 | private RedisUtil redisUtil; 41 | 42 | @Override 43 | protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException { 44 | 45 | final Cookie jwtToken = cookieUtil.getCookie(httpServletRequest,JwtUtil.ACCESS_TOKEN_NAME); 46 | 47 | String username = null; 48 | String jwt = null; 49 | String refreshJwt = null; 50 | String refreshUname = null; 51 | 52 | try{ 53 | if(jwtToken != null){ 54 | jwt = jwtToken.getValue(); 55 | username = jwtUtil.getUsername(jwt); 56 | } 57 | if(username!=null){ 58 | UserDetails userDetails = userDetailsService.loadUserByUsername(username); 59 | 60 | if(jwtUtil.validateToken(jwt,userDetails)){ 61 | UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userDetails,null,userDetails.getAuthorities()); 62 | usernamePasswordAuthenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest)); 63 | SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken); 64 | } 65 | } 66 | }catch (ExpiredJwtException e){ 67 | Cookie refreshToken = cookieUtil.getCookie(httpServletRequest,JwtUtil.REFRESH_TOKEN_NAME); 68 | if(refreshToken!=null){ 69 | refreshJwt = refreshToken.getValue(); 70 | } 71 | }catch(Exception e){ 72 | 73 | } 74 | 75 | try{ 76 | if(refreshJwt != null){ 77 | refreshUname = redisUtil.getData(refreshJwt); 78 | 79 | if(refreshUname.equals(jwtUtil.getUsername(refreshJwt))){ 80 | UserDetails userDetails = userDetailsService.loadUserByUsername(refreshUname); 81 | UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(userDetails,null,userDetails.getAuthorities()); 82 | usernamePasswordAuthenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest)); 83 | SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken); 84 | 85 | Member member = new Member(); 86 | member.setUsername(refreshUname); 87 | String newToken =jwtUtil.generateToken(member); 88 | 89 | Cookie newAccessToken = cookieUtil.createCookie(JwtUtil.ACCESS_TOKEN_NAME,newToken); 90 | httpServletResponse.addCookie(newAccessToken); 91 | } 92 | } 93 | }catch(ExpiredJwtException e){ 94 | 95 | } 96 | 97 | filterChain.doFilter(httpServletRequest,httpServletResponse); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /eurekaclient2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.3.3.RELEASE 9 | 10 | 11 | com.example 12 | eurekaclient2 13 | 0.0.1-SNAPSHOT 14 | eurekaclient2 15 | Demo project for Spring Boot 16 | 17 | 18 | 11 19 | Hoxton.SR7 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | 29 | org.springframework.cloud 30 | spring-cloud-starter-netflix-eureka-client 31 | 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-starter-openfeign 36 | 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-netflix-hystrix 41 | 42 | 43 | 44 | org.springframework.cloud 45 | spring-cloud-starter-sleuth 46 | 47 | 48 | 49 | org.springframework.cloud 50 | spring-cloud-sleuth-zipkin 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-devtools 56 | runtime 57 | true 58 | 59 | 60 | org.projectlombok 61 | lombok 62 | true 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-starter-test 67 | test 68 | 69 | 70 | org.junit.vintage 71 | junit-vintage-engine 72 | 73 | 74 | 75 | 76 | 77 | org.springframework.cloud 78 | spring-cloud-starter-oauth2 79 | 80 | 81 | 82 | org.springframework.cloud 83 | spring-cloud-stream 84 | 85 | 86 | 87 | org.springframework.cloud 88 | spring-cloud-starter-stream-kafka 89 | 90 | 91 | 92 | org.springframework.data 93 | spring-data-redis 94 | 95 | 96 | 97 | redis.clients 98 | jedis 99 | 100 | 101 | 102 | org.apache.commons 103 | commons-pool2 104 | 105 | 106 | 107 | 108 | 109 | 110 | org.springframework.cloud 111 | spring-cloud-dependencies 112 | ${spring-cloud.version} 113 | pom 114 | import 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | org.springframework.boot 123 | spring-boot-maven-plugin 124 | 125 | 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.5.RELEASE 9 | 10 | 11 | com.donggeun 12 | springSecurity 13 | 0.0.1-SNAPSHOT 14 | springSecurity 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-data-jpa 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-security 29 | 30 | 31 | org.springframework.boot 32 | spring-boot-starter-oauth2-client 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-thymeleaf 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-web 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-data-redis 45 | 46 | 47 | org.springframework.boot 48 | spring-boot-starter-mail 49 | 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-devtools 54 | runtime 55 | true 56 | 57 | 58 | mysql 59 | mysql-connector-java 60 | runtime 61 | 62 | 63 | 64 | org.projectlombok 65 | lombok 66 | 1.18.12 67 | provided 68 | 69 | 70 | 71 | 72 | io.jsonwebtoken 73 | jjwt-api 74 | 0.11.1 75 | 76 | 77 | io.jsonwebtoken 78 | jjwt-impl 79 | 0.11.1 80 | runtime 81 | 82 | 83 | io.jsonwebtoken 84 | jjwt-jackson 85 | 0.11.1 86 | runtime 87 | 88 | 89 | 90 | org.springframework.boot 91 | spring-boot-starter-test 92 | test 93 | 94 | 95 | org.junit.vintage 96 | junit-vintage-engine 97 | 98 | 99 | 100 | 101 | org.springframework.security 102 | spring-security-test 103 | test 104 | 105 | 106 | 107 | junit 108 | junit 109 | 4.13 110 | test 111 | 112 | 113 | 114 | io.springfox 115 | springfox-swagger2 116 | 117 | 2.9.2 118 | 119 | 120 | 121 | io.springfox 122 | springfox-swagger-ui 123 | 124 | 2.9.2 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | org.springframework.boot 133 | spring-boot-maven-plugin 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /springJPA/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /springzuul/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /authentication/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /eurekaclient1/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /eurekaclient2/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /eurekaserver/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /maven-jpa/.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 44 | 45 | 46 | 47 | 59 | 60 | 61 | 72 | 73 | 74 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 1583829660111 119 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /Spring_React_Login/backend/src/src/main/java/com/donggeun/springSecurity/service/impl/AuthServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.donggeun.springSecurity.service.impl; 2 | 3 | import com.donggeun.springSecurity.config.UserRole; 4 | import com.donggeun.springSecurity.model.Member; 5 | import com.donggeun.springSecurity.model.Request.RequestSocialData; 6 | import com.donggeun.springSecurity.model.Salt; 7 | import com.donggeun.springSecurity.model.SocialData; 8 | import com.donggeun.springSecurity.repository.MemberRepository; 9 | import com.donggeun.springSecurity.repository.SocialDataRepository; 10 | import com.donggeun.springSecurity.service.AuthService; 11 | import com.donggeun.springSecurity.service.EmailService; 12 | import com.donggeun.springSecurity.service.RedisUtil; 13 | import com.donggeun.springSecurity.service.SaltUtil; 14 | import javassist.NotFoundException; 15 | import lombok.extern.slf4j.Slf4j; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.stereotype.Service; 18 | 19 | import javax.transaction.Transactional; 20 | import java.util.UUID; 21 | 22 | @Service 23 | @Slf4j 24 | public class AuthServiceImpl implements AuthService { 25 | 26 | 27 | @Autowired 28 | private MemberRepository memberRepository; 29 | 30 | @Autowired 31 | private EmailService emailService; 32 | 33 | @Autowired 34 | private SaltUtil saltUtil; 35 | 36 | @Autowired 37 | private RedisUtil redisUtil; 38 | 39 | @Autowired 40 | private SocialDataRepository socialDataRepository; 41 | 42 | @Override 43 | @Transactional 44 | public void signUpUser(Member member) { 45 | String password = member.getPassword(); 46 | String salt = saltUtil.genSalt(); 47 | member.setSalt(new Salt(salt)); 48 | member.setPassword(saltUtil.encodePassword(salt,password)); 49 | memberRepository.save(member); 50 | } 51 | 52 | @Override 53 | @Transactional 54 | public void signUpSocialUser(RequestSocialData member){ 55 | Member newMember = new Member(); 56 | newMember.setUsername(member.getId()); 57 | newMember.setPassword(""); 58 | newMember.setEmail(member.getEmail()); 59 | newMember.setName(member.getName()); 60 | newMember.setAddress(""); 61 | newMember.setSocial(new SocialData(member.getId(),member.getEmail(),member.getType())); 62 | memberRepository.save(newMember); 63 | } 64 | 65 | @Override 66 | public Member loginSocialUser(String id, String type) throws NotFoundException{ 67 | SocialData socialData = socialDataRepository.findByIdAndType(id,type); 68 | if(socialData==null) throw new NotFoundException("멤버가 조회되지 않음"); 69 | return socialData.getMember(); 70 | } 71 | 72 | @Override 73 | public Member loginUser(String id, String password) throws Exception{ 74 | Member member = memberRepository.findByUsername(id); 75 | if(member==null) throw new Exception ("멤버가 조회되지 않음"); 76 | String salt = member.getSalt().getSalt(); 77 | password = saltUtil.encodePassword(salt,password); 78 | if(!member.getPassword().equals(password)) 79 | throw new Exception ("비밀번호가 틀립니다."); 80 | if(member.getSocial()!=null) 81 | throw new Exception ("소셜 계정으로 로그인 해주세요."); 82 | return member; 83 | } 84 | 85 | @Override 86 | public Member findByUsername(String username) throws NotFoundException { 87 | Member member = memberRepository.findByUsername(username); 88 | if(member == null) throw new NotFoundException("멤버가 조회되지 않음"); 89 | return member; 90 | } 91 | 92 | @Override 93 | public void verifyEmail(String key) throws NotFoundException { 94 | String memberId = redisUtil.getData(key); 95 | Member member = memberRepository.findByUsername(memberId); 96 | if(member==null) throw new NotFoundException("멤버가 조회되지않음"); 97 | modifyUserRole(member,UserRole.ROLE_USER); 98 | redisUtil.deleteData(key); 99 | } 100 | 101 | @Override 102 | public void sendVerificationMail(Member member) throws NotFoundException { 103 | String VERIFICATION_LINK = "http://localhost:8080/user/verify/"; 104 | if(member==null) throw new NotFoundException("멤버가 조회되지 않음"); 105 | UUID uuid = UUID.randomUUID(); 106 | redisUtil.setDataExpire(uuid.toString(),member.getUsername(), 60 * 30L); 107 | emailService.sendMail(member.getEmail(),"[김동근 스프링] 회원가입 인증메일입니다.",VERIFICATION_LINK+uuid.toString()); 108 | } 109 | 110 | @Override 111 | public void modifyUserRole(Member member, UserRole userRole){ 112 | member.setRole(userRole); 113 | memberRepository.save(member); 114 | } 115 | 116 | @Override 117 | public boolean isPasswordUuidValidate(String key){ 118 | String memberId = redisUtil.getData(key); 119 | return !memberId.equals(""); 120 | } 121 | 122 | @Override 123 | public void changePassword(Member member,String password) throws NotFoundException{ 124 | if(member == null) throw new NotFoundException("changePassword(),멤버가 조회되지 않음"); 125 | String salt = saltUtil.genSalt(); 126 | member.setSalt(new Salt(salt)); 127 | member.setPassword(saltUtil.encodePassword(salt,password)); 128 | memberRepository.save(member); 129 | } 130 | 131 | 132 | @Override 133 | public void requestChangePassword(Member member) throws NotFoundException{ 134 | String CHANGE_PASSWORD_LINK = "http://localhost:8080/user/password/"; 135 | if(member == null) throw new NotFoundException("멤버가 조회되지 않음."); 136 | String key = REDIS_CHANGE_PASSWORD_PREFIX+UUID.randomUUID(); 137 | redisUtil.setDataExpire(key,member.getUsername(),60 * 30L); 138 | emailService.sendMail(member.getEmail(),"[김동근 스프링] 사용자 비밀번호 안내 메일",CHANGE_PASSWORD_LINK+key); 139 | } 140 | 141 | 142 | } -------------------------------------------------------------------------------- /Spring_React_Login/frontend/src/src/serviceWorker.ts: -------------------------------------------------------------------------------- 1 | // This optional code is used to register a service worker. 2 | // register() is not called by default. 3 | 4 | // This lets the app load faster on subsequent visits in production, and gives 5 | // it offline capabilities. However, it also means that developers (and users) 6 | // will only see deployed updates on subsequent visits to a page, after all the 7 | // existing tabs open on the page have been closed, since previously cached 8 | // resources are updated in the background. 9 | 10 | // To learn more about the benefits of this model and instructions on how to 11 | // opt-in, read https://bit.ly/CRA-PWA 12 | 13 | const isLocalhost = Boolean( 14 | window.location.hostname === 'localhost' || 15 | // [::1] is the IPv6 localhost address. 16 | window.location.hostname === '[::1]' || 17 | // 127.0.0.0/8 are considered localhost for IPv4. 18 | window.location.hostname.match( 19 | /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ 20 | ) 21 | ); 22 | 23 | type Config = { 24 | onSuccess?: (registration: ServiceWorkerRegistration) => void; 25 | onUpdate?: (registration: ServiceWorkerRegistration) => void; 26 | }; 27 | 28 | export function register(config?: Config) { 29 | if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { 30 | // The URL constructor is available in all browsers that support SW. 31 | const publicUrl = new URL( 32 | process.env.PUBLIC_URL, 33 | window.location.href 34 | ); 35 | if (publicUrl.origin !== window.location.origin) { 36 | // Our service worker won't work if PUBLIC_URL is on a different origin 37 | // from what our page is served on. This might happen if a CDN is used to 38 | // serve assets; see https://github.com/facebook/create-react-app/issues/2374 39 | return; 40 | } 41 | 42 | window.addEventListener('load', () => { 43 | const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; 44 | 45 | if (isLocalhost) { 46 | // This is running on localhost. Let's check if a service worker still exists or not. 47 | checkValidServiceWorker(swUrl, config); 48 | 49 | // Add some additional logging to localhost, pointing developers to the 50 | // service worker/PWA documentation. 51 | navigator.serviceWorker.ready.then(() => { 52 | console.log( 53 | 'This web app is being served cache-first by a service ' + 54 | 'worker. To learn more, visit https://bit.ly/CRA-PWA' 55 | ); 56 | }); 57 | } else { 58 | // Is not localhost. Just register service worker 59 | registerValidSW(swUrl, config); 60 | } 61 | }); 62 | } 63 | } 64 | 65 | function registerValidSW(swUrl: string, config?: Config) { 66 | navigator.serviceWorker 67 | .register(swUrl) 68 | .then(registration => { 69 | registration.onupdatefound = () => { 70 | const installingWorker = registration.installing; 71 | if (installingWorker == null) { 72 | return; 73 | } 74 | installingWorker.onstatechange = () => { 75 | if (installingWorker.state === 'installed') { 76 | if (navigator.serviceWorker.controller) { 77 | // At this point, the updated precached content has been fetched, 78 | // but the previous service worker will still serve the older 79 | // content until all client tabs are closed. 80 | console.log( 81 | 'New content is available and will be used when all ' + 82 | 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' 83 | ); 84 | 85 | // Execute callback 86 | if (config && config.onUpdate) { 87 | config.onUpdate(registration); 88 | } 89 | } else { 90 | // At this point, everything has been precached. 91 | // It's the perfect time to display a 92 | // "Content is cached for offline use." message. 93 | console.log('Content is cached for offline use.'); 94 | 95 | // Execute callback 96 | if (config && config.onSuccess) { 97 | config.onSuccess(registration); 98 | } 99 | } 100 | } 101 | }; 102 | }; 103 | }) 104 | .catch(error => { 105 | console.error('Error during service worker registration:', error); 106 | }); 107 | } 108 | 109 | function checkValidServiceWorker(swUrl: string, config?: Config) { 110 | // Check if the service worker can be found. If it can't reload the page. 111 | fetch(swUrl, { 112 | headers: { 'Service-Worker': 'script' } 113 | }) 114 | .then(response => { 115 | // Ensure service worker exists, and that we really are getting a JS file. 116 | const contentType = response.headers.get('content-type'); 117 | if ( 118 | response.status === 404 || 119 | (contentType != null && contentType.indexOf('javascript') === -1) 120 | ) { 121 | // No service worker found. Probably a different app. Reload the page. 122 | navigator.serviceWorker.ready.then(registration => { 123 | registration.unregister().then(() => { 124 | window.location.reload(); 125 | }); 126 | }); 127 | } else { 128 | // Service worker found. Proceed as normal. 129 | registerValidSW(swUrl, config); 130 | } 131 | }) 132 | .catch(() => { 133 | console.log( 134 | 'No internet connection found. App is running in offline mode.' 135 | ); 136 | }); 137 | } 138 | 139 | export function unregister() { 140 | if ('serviceWorker' in navigator) { 141 | navigator.serviceWorker.ready 142 | .then(registration => { 143 | registration.unregister(); 144 | }) 145 | .catch(error => { 146 | console.error(error.message); 147 | }); 148 | } 149 | } 150 | --------------------------------------------------------------------------------