본문 바로가기

전체 글

(129)
[Java] 제네릭(Generic) 분석 T extends 클래스 상속을 이용해서 T의 자료형을 제한함 클래스 선언시 사용하며 인스턴스 생성시 특정 클래스를 상속받은 클래스형만 인스턴스 내부에서 사용할 수 있도록 함 특정 인터페이스를 구현한 클래스만 사용하려는 경우에도 사용 가능 public interface Behavior { void displayName(); } public class Car implements Behavior{ @Override public void displayName() { System.out.println("This is a car."); } } public class Bus implements Behavior{ @Override public void displayName() { System.out.println("..
[Spring boot] Spring Security 분석 - 메소드 Security 설정은 아래와 같이 SecurityConfig 클래스에 어노테이션을 붙여준다. prePostEnabled의 속성은 Spring Security @PreAuthorize, @PostAuthorize 사용 가능 securedEnabled 경우 @Secured 사용 가능 jsr250Enabled의 경우 @RoleAllowed 어노테이션 사용 가능 @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity( securedEnabled = true, jsr250Enabled = true, prePostEnabled = true ) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowi..
[Spring boot] refresh token 갱신 시 DB 저장값과 Cookie 값 안맞을 경우 Interceptor에서 preHandle로 request를 잡아서 refresh token을 재 생성하여 response의 cookie를 변경할경우 cookie write 완료 전에 들어온 request들은 새로 변한 값이 아닌 이전 값으로 올때가 있다. 즉 http request가 동시에 여러개가 올 경우에는 reponse 변경값이 적용되기 전에 요청이 올수가 있다. 이럴 경우에는 refresh token 변조 확인을 위해 DB의 token 값을 읽을 때 생성된지 얼마 안된 토큰은 skip하고 일정 threshold (예: 2초) 지난후 token부터 진위여부를 체크한다. public ApiResponse refreshToken(HttpServletRequest request, HttpServletR..
[Gitlab] Gitlab backup, restore Gitlab container에 터미널 접속 root@MyFriends:~# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d0a1cac82f0f gitlab/gitlab-ce:latest "/assets/wrapper" 3 months ago Up 3 hours (healthy) 0.0.0.0:40002->22/tcp, 0.0.0.0:40000->80/tcp, 0.0.0.0:40001->443/tcp gitlab-gitlab-ce1 root@MyFriends:~# docker exec -it gitlab-gitlab-ce1 bash root@gitlab-gitlab-ce1:/# gitlab 버전 12.2 이상 gitlab-backup ..
[Oracle] 오라클 기본 명령어 #1 데이터 베이스 내 모든 테이블 DELETE 명령어 추출 SELECT 'DELETE FROM "' || TABLE_NAME || '";' FROM user_tables; 데이터 베이스 내 모든 테이블 DROP 명령어 추출 SELECT 'DROP TABLE "' || TABLE_NAME || '" CASCADE CONSTRAINTS;' FROM user_tables; 전체 테이블 DROP 후 시퀀스 삭제 purge recyclebin;
[Spring boot] @ConfigurationProperties 사용하기 @ConfigurationProperties 는 Spring Boot 에서 application.properties 파일에 정의된 프로퍼티들을 POJO 에 매핑하여 Bean 으로 만들수 있게 해주는 어노테이션이다. 아래의 application.properties에 정의된 값들을 Pojo제 받기 위해 ConfugurationProperties를 작성한다. application-dev.properties app.auth.tokenSecret=04ca023b39512e46d0c2cf4b48d5aac61d34302994c87ed4eff225dcf3b0a218739f3897051a057f9b846a69ea2927a587044164b7bae5e1306219d50b588cb1 app.auth.tokenExpirati..
[Spring boot] JSP embedded tomcat (tomcat-embedded-jasper) 동작 원리 JSP를 실행하면 실제로는 JSP로부터 생성된 서블릿이 실행된다. ① 클라이언트가 JSP를 실행을 요청하면 서블릿 컨테이너는 JSP 파일에 대응하는 자바 서블릿을 찾아서 실행한다. ② 대응하는 서블릿이 없거나 JSP 파일이 변경됐으면 JSP 엔진을 통해 서블릿 자바 소스를 생성한다. ③ 자바 컴파일러가 서블릿 자바 소스를 클래스 파일로 컴파일한다. (JSP 파일이 변경될때마다 반복) ④ JSP로부터 생성된 서블릿은 서블릿 구동 방식에 의해 service() 메소드가 호출되고 서블릿이 생성한 HTML 화면을 웹 브라우저로 보낸다. Spring boot에서 embedded tomcat으로 jsp 구동시 compiled 된 jsp 파일 위치 Spring boot로 윈도우즈에서 embedded tomcat으로 ..
[Spring boot] Spring Security Authentication 개념 AuthenticationEntryPoint @Override protected void configure(HttpSecurity http) throws Exception { http .cors() .and() .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS) .and() .csrf() .disable() .formLogin() .disable() .httpBasic() .disable() .exceptionHandling() .authenticationEntryPoint(new RestAuthenticationEntryPoint()) .and() package com.example.springsocial.securi..