Home

0

Spring Security - Security 설정을 위한 WebSecurityConfigurerAdatper

목차 Spring Security 권한 계층 사용하기 - @RoleHierarcy Spring Security - DelegateFilterProxy Spring Security - Remember Me와 관련된 인증 API - RememberMeConfigurer Spring Security - RembmerMeAuthenticationFilter Spring Security - SessionManagementFilter & ConcurrentSessionFilter Spring Security - 인가 API ExpressionUrlAuthorizationConfigurer Spring Security - Security 설정을 위한 WebSecurityConfigurerAdatper Spring Security - AuthenticationProvider Spring Security - AuthenticationManager Spring Security - UsernamePasswordAuthenticationFilter & AbstractAuthenticationProcessingFilter Spring Security - SecurityContextHolder 와 SecurityContext Spring Security - Authentication 객체 Spring Security 설정하기 - WebSecurityConfigurerAdatper스프링 Scurity에 대한 설정은 WebSecurityConfigurer 인터페이스 구현하거나 WebSecurityConfigurerAdapter 클래스를 상속해 설정을 할 수 있다. 인증 방식 설정 configure(AuthenticationManagerBuilder auth) 인증 방식과 관련된 설정을 하기 위한 메소드 AuthenticationManagerBuilder는 인증객체(AuthenticationManager)를 생성하기 위한 클래스이다. In Memory authentication나 UserDetailsService를 사용하는 다양한 인증 방식을 손 쉽게 구축할 수 있도록 지원한다. configure(AuthenticationManagerBuilder auth) private final CustomUserDetailsService customUserDetailsService;@Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(customUserDetailsService);}

0

백준 1406 - 후위표기식

https://www.acmicpc.net/problem/1918 문제 해설문제를 해결할 때 후위 표기식에 대한 명확한 이해와 연산자 우선순위에 대해 고려 해야 한다. 연산자를 별도의 stack에 쌓아가면서 후위 표기식을 만든다. stack에 연산자를 넣기 전에 연산자 비교를 통해 stack에 넣을 려는 연산자 우선순위 보다 stack에 있는 연산자의 우선순위가 작을 때까지 계속해서 stack에서 연산자를 꺼내 후위 표기식에 추가해준다. 연산자 우선순위 (가 제일 높은 우선순위다. * 와 /가 그 다음 우선순위 + 와 -가 다음 우선순위를 갖고 있다. )가 제일 낮은 우선순위다. (를 만날때까지 모든 연산자를 stack에서 꺼낸다. 소스 코드#include <bits/stdc++.h>using namespace std;string str;string result;int main(void) { cin >> str; stack<char> operation; for (int i = 0; i < str.length(); i++) { char cntChar = str[i]; if (cntChar == '(') { operation.push(cntChar); } else if (cntChar == '*' || cntChar == '/') { while (!operation.empty() && (operation.top() == '*' || operation.top() == '/')) { result += operation.top(); operation.pop(); } operation.push(cntChar); } else if (cntChar == '+' || cntChar == '-') { while (!operation.empty() && (operation.top() != '(')) { result += operation.top(); operation.pop(); } operation.push(cntChar); } else if (cntChar == ')') { while (!operation.empty() && operation.top() != '(') { result += operation.top(); operation.pop(); } operation.pop(); } else { result += cntChar; } } while (!operation.empty()) { result += operation.top(); operation.pop(); } cout << result << '\n'; return 0;}

0

프로그래머스 - 수식 최대화 (Cpp)

https://programmers.co.kr/learn/courses/30/lessons/67257 문제 해설경우의 수 문제이다. 모든 경우의 연산자 우선순위를 만들어 해당 연산자 우선순위를 이용해 연산을 진행하면 된다. 중위표기식으로 나타난 식을 후위 표기식으로 바꿔서 문제를 해결 했다. 경우의 수 만들기만들 수 있는 모든 연산자 우선순위를 만들어줘야 한다. DFS를 이용해 모든 경우의 수를 만들어 줬다. void makeAllCase(int depth) { if (depth == 3) { allCase.push_back(cntCase); } for (int i = 0; i < 3; i++) { int cntOper = operation[i]; if (check[i] == false) { check[i] = true; cntCase[depth] = cntOper; makeAllCase(depth + 1); check[i] = false; } }} 연산자 우선순위를 가반으로 한 연산 가장 높은 우선순위의 연산자가 들어왔을 때 Stack을 확인해 같은 먼저 들어온 같은 우선순위의 연산자가 있는지 확인한다. 같은 우선순위의 연산자가 Stack에 있는 경우 pop 해서 해당 연산을 진행한 후 지금 들어온 연산자를 push한다. 없는 경우에는 Stack에 push 한다. 두번째 우선 순위가 연산자가 들어온 경우 Stack을 확인해 우선순위가 같거나 큰 연산자가 없어질 때까지 연산을 진행한 후 pop 한다. Stack에 우선순위가 같거나 큰 연산자가 없을 경우에는 Stack에 push 한다. 세번째 우선 순위의 연산자가 들어온 경우 Stack을 확인해 우선순위가 같거나 큰 연산자가 없어질 때까지 연산을 진행한 후 pop 한다. Stack에 우선순위가 같거나 큰 연산자가 없을 경우에는 Stack에 push 한다.

0

백준 1406 - 에디터

https://www.acmicpc.net/problem/1406 문제 해설Stack을 이용한 문제 풀이기본적인 자료구조를 사용해 문제를 해결하는 문제이다. 두개의 스택을 이용해서 커서를 기점으로 커서 왼쪽에 있는 것들은 left 스택에 커서 오른쪽에 있는 단어들은 right 스택에 넣어서 관리를 한다. import java.io.IOException;import java.util.Scanner;import java.util.Stack;public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); Stack<Character> left = new Stack<>(); Stack<Character> right = new Stack<>(); for (int i = 0; i < str.length(); i++) { left.push(str.charAt(i)); } int numOfCmd = sc.nextInt(); for (int i = 0; i < numOfCmd; i++) { String cmd = sc.next(); if (cmd.equals("L")) { if (!left.isEmpty()) { right.push(left.peek()); left.pop(); } } else if (cmd.equals("D")) { if (!right.isEmpty()) { left.push(right.peek()); right.pop(); } } else if (cmd.equals("B")) { if (!left.isEmpty()) { left.pop(); } } else if (cmd.equals("P")) { char value = sc.next().charAt(0); left.push(value); } } while (!left.isEmpty()) { right.push(left.peek()); left.pop(); } StringBuilder stringBuilder = new StringBuilder(); while (!right.isEmpty()) { stringBuilder.append(right.peek()); right.pop(); } System.out.println(stringBuilder.toString()); }} LinkedList와 ListIterator를 이용한 문제 풀이해당 문제는 LinkedList를 이용해서도 문제를 해결할 수 있다. LinkedList의 원소에 List로 접근을 하게 되면 O(n) 의 시간이 걸려 시간 초과가 뜨게 된다. 때문에 다행이 문제는 Cursor위치를 한칸씩 밖에 못 움직이므로 ListIterator 라는 객체를 이용해 LinkedList를 관리하도록 한다. public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(System.out)); String[] str = br.readLine().split(""); List<Character> charList = new LinkedList<>(); ListIterator<Character> iter = charList.listIterator(); for (int i = 0; i < str.length; i++) { iter.add(str[i].charAt(0)); } int index = charList.size(); int numOfCmd = Integer.parseInt(br.readLine()); for (int i = 0; i < numOfCmd; i++) { char[] inputs = br.readLine().toCharArray(); if (inputs[0] == 'L') { if (iter.hasPrevious()) { iter.previous(); } } else if (inputs[0] == 'D') { if (iter.hasNext()) { iter.next(); } } else if (inputs[0] == 'B') { if (iter.hasPrevious()) { iter.previous(); iter.remove(); } } else if (inputs[0] == 'P') { char value = inputs[2]; iter.add(value); } } for (char c : charList) { wr.write(c); } wr.flush(); }}

0

Spring-JWT(JSON Web Token) - 4. JWT 다루기

4. JWT 다루기목차 Spring-JWT(JSON Web Token) - 4. JWT 다루기 Spring-JWT(JSON Web Token) - 3. Spring Security 적용하기 Spring-JWT(JSON Web Token) - 2. 회원가입 Spring-JWT(JSON Web Token) - 1. JWT 알아보기 JWT를 다루기 위한 Util Class만들기 JwtUtil 객체는 Jwts.builder를 이용해 JWT를 생성하고 Jwts.parserBuilder를 이용해 Token을 JWT로 변환시켜 데이터를 가져오도록 한다. Jwts.builder(JwtBuilder) setHeader JWT의 Header 에 대한 설정을 위한 메소드 setSubject, setExpiration, setIssuer, setAudience, setNotBefore, setIssuedAt Registed Payload는 각각에 해당하는 set 메소드들이 제공된다. setClaims JWT의 Claim 데이터 를 추가하기 위한 메소드 signWith Header와 Payload를 갖고 Secret Key 로 서명한다. 암호화 알고리즘으로는 보통 HMAC or RSA 알고리즘을 사용한다. Jwts.parserBuilder(JwtParser) setSigningKey 데이터 위변조 확인을 위해 secretKey를 이용해 JWS에 대한 유효성 검증을 한다. secretKey를 이용한 검증 실패시 해당 JWT는 사용하지 못한다. parseClaimsJws token을 JWS로 파싱해준다.

0

Spring-JWT(JSON Web Token) - 3. Spring Security 적용하기

3. 로그인목차 Spring-JWT(JSON Web Token) - 4. JWT 다루기 Spring-JWT(JSON Web Token) - 3. Spring Security 적용하기 Spring-JWT(JSON Web Token) - 2. 회원가입 Spring-JWT(JSON Web Token) - 1. JWT 알아보기 의존성 추가Spring Boot에 Security를 적용하기 위해 Spring Security 의존성과 JWT를 사용하기위해 jjwt 의존성을 추가해주도록 한다. build.gradle dependencies { .... implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' // https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.9.1' ....} Security 설정하기Spring Security는 인증에 필요한 사용자 정보를 저장할 때 비밀번호는 PasswordEncoder 객체를 이용해 암호화된 Password로 저장돼야 한다. 현재 프로젝트에서는 PasswordEncoder를 구현한 BcryptPasswordEncoder 객체를 이용해 암호화를 할 것이다.

0

Spring-JWT(JSON Web Token) - 2. 회원가입

2. 회원가입목차 Spring-JWT(JSON Web Token) - 4. JWT 다루기 Spring-JWT(JSON Web Token) - 3. Spring Security 적용하기 Spring-JWT(JSON Web Token) - 2. 회원가입 Spring-JWT(JSON Web Token) - 1. JWT 알아보기 의존성 관계build.gradle dependencies { implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' runtimeOnly 'com.h2database:h2' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' testImplementation 'org.springframework.security:spring-security-test'} 회원가입을 위한 DTO 만들기SignUpRequest.java @Data@AllArgsConstructor@NoArgsConstructorpublic class SignUpRequest { private String username; private String password;}

0

메모리 관리

메모리 관리 기본적인 메모리 관리 swapping 가상 메모리 Page replacement 알고리즘 세그멘테이션 프로그래머들이 가장 바라는 메모리는 바로 크고 빠르고 비 휘발성인것을 원한다. Memory Manager(메모리 관리자) 메모리 계층을 관리하는 운영체제의 일부분 사용하고 있는 메모리와 사용하고있지 않는 메모리를 계속해서 추적한다. 메모리를 프로세스에 할당하고 해제한다. 프로세스의 용량이 커서 메모리에 용량이 작을 경우 메모리와 디스크를 swapping한다. 기본적인 메모리 관리 기법paging이나 swapping이 없는 단일 프로그램메모리보다 더 큰 Program의 등장프로그램이 점점 커지다 보니 우리가 사용하는 메인 메모리보다 큰 프로그램이 생겨나게 됐다.이를 해결하기 위한 방법으로 overlay와 virtual memory 방법이 나왔다.

0

네트워크 - TCP

TCP(Transmission Control Protocol) TCP 서비스 연결 지향의 신뢰성이 있는 바이트 스트림 서비스를 제공한다. 양방향 통신을 지원한다.(Full-Duplex Communication) 흐름제어와 에러제어, 그리고 혼잡제어를 제공한다.(신뢰성 있는 전송) 신뢰성 있는 전송이란? 데이터가 손실, 중복되지 않고 순서가 어긋나지 않는 전송방식 바이트 스트림 서비스란? 데이터 송 수신시 버퍼 기능을 이용해 Byte 단위로 처리

0

클라우드 서비스

클라우드 서비스 종류IaaS(Infrastructure as a Service)인프라를 제공하는 방식 - 컴퓨터를 대여해주는 거라고 생각하면 이해하기 쉽다. 아마존의 AWS, MS의 Azure, 구글의 GCP Platform as a Service플랫폼을 제공하는 방식 - IaaS 서비스에 Runtime환경까지 설정이 이미 되어 있기 때문에 Software as a Service특정 소프트웨어를 제공하는 방식 - 드랍박스, 구글 Docs, 오피스365 장점 컴퓨팅 환경을 빠르게 구축할 수 있다는 장점이 있다. 사용한 만큼만 돈을 지불하면 된다. 특정기간 트래픽이 폭주하는 경우에 자원의 리소스 추가와 삭제가 기존의 on-premise방식에 비해 용이하다. 서버를 관리하기 위한 물리적 공간과 인적 자원에 대해 신경쓸 필요가 없어진다.